Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
How To
Syntax
FAQ
License

Adding properties



This article explains how to add properties to be supported by the tool.

To support a new property, you will need to:
  • Add the property key to be used in the command-line options and the configuration file in the org.docgene.parser.properties.PropertiesKeys class
  • Add the property default value in the org.docgene.parser.properties.PropertiesDefaults class
  • Add the property key in the keys which are handled by the parsers value in the org.docgene.parser.properties.ConfigurationPropertiesParser class, and return the parsed value of the property for its key
  • Add a field for the property in the org.docgene.main.LaunchOption class
  • Add a field an accessor for the property in the org.docgene.main.Configuration class
  • Parse the property in the org.docgene.main.LaunchOptionParser class
  • Parse the property in the org.docgene.parser.ConfigurationParser class

Example

Suppose the allowMediawiki property to specify if the mediawiki format is allowed (it is a boolean value).

Add the property key

We add the key in the org.docgene.parser.properties.PropertiesKeys class:
   public interface PropertiesKeys {
      public String ALLOW_MEDIAWIKI = "allowMediawiki";
   }

Add the property default value

We add the default value in the org.docgene.parser.properties.PropertiesDefaults class:
   public interface PropertiesDefaults {
      public boolean ALLOW_MEDIAWIKI_DEFAULT = false;
   }

Specify that the property is handled

We specify that the property is handled in the org.docgene.parser.properties.ConfigurationPropertiesParser class:
   public abstract class ConfigurationPropertiesParser implements PropertiesKeys {
      public boolean handleProperty(String key) {
        switch (key) {
          ...
          case ALLOW_MEDIAWIKI:
             return true;
          ...
        }
      }
   }
We parse the property (we must return a boolean value):
   public abstract class ConfigurationPropertiesParser implements PropertiesKeys {
      public Object parseProperty(String key, String value) {
        switch (key) {
          ...
          case ALLOW_MEDIAWIKI:
            return parseBooleanValue(value);
          ...
        }
      }
   }

Categories: development

docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.