![Latest Tag](https://img.shields.io/github/tag/Torchmind/Candle.svg?style=flat-square&label=Latest Tag)
![Latest Release](https://img.shields.io/github/release/Torchmind/Candle.svg?style=flat-square&label=Latest Release)
A simple human readable configuration file format.
- IRC #Akkarin on irc.spi.gt (alternatively #Akkarin on esper.net)
- GitHub
When running maven you may simply add a new dependency along with our repository to your pom.xml
:
<repository>
<id>torchmind</id>
<url>https://maven.torchmind.com/snapshot/</url>
</repository>
<dependencies>
<dependency>
<groupId>com.torchmind.candle</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
Loading a configuration file by using the Candle implementation:
Candle candle = new Candle ();
candle.read (new File("configuration.cndl"));
if (candle.getBoolean ("some.test.node")) {
System.out.println ("I'm doing things!");
}
Creating a configuration file by using the Candle implementation:
Candle candle = new Candle ();
ContainerNode container1 = new ObjectNode ("some");
ContainerNode container2 = new ObjectNode ("test");
container1.append (container2);
candle.append (container1);
CommentNode comment = new CommentNode ("This is a test configuration file!");
container2.append (comment);
BooleanNode value = new BooleanPropertyNode ("node", true);
container2.append (value);
candle.write (new File ("configuration.cndl"));
Above examples would load/produce the following configuration file:
some {
test {
// This is a test configuration file!
node = true
}
}
Reading/Writing a configuration file by using the Candle Object Mapper:
public class Configuration {
private final CandleMapper mapper = new CandleMapper (this);
@Property
@Comment ("First root-level test variable")
private boolean value = true;
@Property ("some.test.node")
@Comment ("First lower-level test variable")
private int value = 42;
// Injection Method
public void load (File file) throws CandleException, IOException {
this.mapper.inject (file);
}
public void save (File file) throws CandleException, IOException {
this.mapper.write (file);
}
// Construction Method
public static Configuration load (File file) {
CandleMapper mapper = new CandleMapper (Configuration.class);
return mapper.construct (file);
}
}
You encountered problems with the library or have a suggestion? Create an issue!
- Make sure your issue has not been fixed in a newer version (check the list of closed issues
- Create a new issue from the issues page
- Enter your issue's title (something that summarizes your issue) and create a detailed description containing:
- What is the expected result?
- What problem occurs?
- How to reproduce the problem?
- Crash Log (Please use a Pastebin service)
- Click "Submit" and wait for further instructions
- Clone this repository via
git clone https://github.com/Torchmind/Candle.git
or download a zip - Build the modification by running
mvn clean install
- The resulting jars can be found in
api/target
,core/target
andmapper/target
Before you add any major changes to the library you may want to discuss them with us (see Contact) as we may choose to reject your changes for various reasons. All contributions are applied via Pull-Requests. Patches will not be accepted. Also be aware that all of your contributions are made available under the terms of the Apache License 2.0. Please read the Contribution Guidelines for more information.