Skip to content
This repository has been archived by the owner on May 24, 2019. It is now read-only.
/ Candle Public archive

A simple human-readable configuration file format

License

Notifications You must be signed in to change notification settings

Torchmind/Candle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License ![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)

Candle Configuration Format

Table of Contents

About

A simple human readable configuration file format.

Contacts

Using

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);
        }
}

Issues

You encountered problems with the library or have a suggestion? Create an issue!

  1. Make sure your issue has not been fixed in a newer version (check the list of closed issues
  2. Create a new issue from the issues page
  3. 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)
  4. Click "Submit" and wait for further instructions

Building

  1. Clone this repository via git clone https://github.com/Torchmind/Candle.git or download a zip
  2. Build the modification by running mvn clean install
  3. The resulting jars can be found in api/target, core/target and mapper/target

Contributing

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.

About

A simple human-readable configuration file format

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages