Lib-Properties

Lib-Properties is a library for easy loading properties files in a JavaFX & Maven desktop application. See https://github.com/Naoghuman/lib-properties for more details.

License

License

GroupId

GroupId

com.github.naoghuman
ArtifactId

ArtifactId

lib-properties
Last Version

Last Version

0.5.1
Release Date

Release Date

Type

Type

jar
Description

Description

Lib-Properties
Lib-Properties is a library for easy loading properties files in a JavaFX & Maven desktop application. See https://github.com/Naoghuman/lib-properties for more details.
Project URL

Project URL

https://github.com/Naoghuman/lib-properties.git
Source Code Management

Source Code Management

https://github.com/Naoghuman/lib-properties.git

Download lib-properties

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.naoghuman/lib-properties/ -->
<dependency>
    <groupId>com.github.naoghuman</groupId>
    <artifactId>lib-properties</artifactId>
    <version>0.5.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.naoghuman/lib-properties/
implementation 'com.github.naoghuman:lib-properties:0.5.1'
// https://jarcasting.com/artifacts/com.github.naoghuman/lib-properties/
implementation ("com.github.naoghuman:lib-properties:0.5.1")
'com.github.naoghuman:lib-properties:jar:0.5.1'
<dependency org="com.github.naoghuman" name="lib-properties" rev="0.5.1">
  <artifact name="lib-properties" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.naoghuman', module='lib-properties', version='0.5.1')
)
libraryDependencies += "com.github.naoghuman" % "lib-properties" % "0.5.1"
[com.github.naoghuman/lib-properties "0.5.1"]

Dependencies

compile (1)

Group / Artifact Type Version
com.github.naoghuman : lib-logger jar 0.5.1

Project Modules

There are no modules declared in this project.

Lib-Properties

Build Status license: GPL v3 GitHub release

Intention

Lib-Properties is a library for easy loading properties files in a JavaFX & Maven desktop application.

Image: UML Lib-Properties
UML-diagram_Lib-Properties_v0.5.0_2017-07-17_21-17.png

Hint
The UML diagram is created with the Online Modeling Platform GenMyModel.

Current version is 0.5.1 (01.02.2018 / MM.dd.yyyy).

Content

Examples

How to register a resource bundle

public interface IApplicationConfiguration {
    ...
    public static final String DBW__RESOURCE_BUNDLE = "/de/pro/dbw/application/DreamBetterWorlds.properties"; // NOI18N
}

public class DreamBetterWorlds extends Application implements IApplicationConfiguration, IPreferencesConfiguration {
    @Override
    public void init() throws Exception {
        PropertiesFacade.getDefault().register(DBW__RESOURCE_BUNDLE);
        ...
    }

    ...
}

How to access a value from the resource bundle

public class DreamBetterWorlds extends Application implements IApplicationConfiguration, IPreferencesConfiguration {
    private static final String KEY__APPLICATION__TITLE = "application.title"; // NOI18N
    ...

    @Override
    public void start(Stage stage) throws Exception {
        stage.setTitle(this.getProperty(KEY__APPLICATION__TITLE));
        ...
    }

    private String getProperty(String propertyKey) {
        return PropertiesFacade.getDefault().getProperty(DBW__RESOURCE_BUNDLE, propertyKey);
    }
    ...
}

Api

com.github.naoghuman.lib.properties.core.PropertiesFacade

/**
 * The facade {@link com.github.naoghuman.lib.properties.core.PropertiesFacade} 
 * provides access to the methods from the {@code Interface} 
 * {@link com.github.naoghuman.lib.properties.core.SimpleProperties}.
 * <p>
 * The usage from the facade is preferred over the directly usage through instanziation
 * from the {@code Class} {@link com.github.naoghuman.lib.properties.internal.DefaultSimpleProperties}.
 *
 * @author Naoghuman
 * @see    com.github.naoghuman.lib.properties.core.SimpleProperties
 * @see    com.github.naoghuman.lib.properties.internal.DefaultSimpleProperties
 */
public final class PropertiesFacade implements SimpleProperties
/**
 * Returns a singleton instance from the {@code Class} {@code PropertiesFacade}.
 * 
 * @return a singleton instance from the {@code Class} {@code PropertiesFacade}.
 */
public static final PropertiesFacade getDefault()

com.github.naoghuman.lib.properties.core.SimpleProperties

/**
 * The {@code Interface} for the default {@code Implementation} 
 * {@link com.github.naoghuman.lib.properties.internal.DefaultSimpleProperties}.
 * <p>
 * Over the facade {@link com.github.naoghuman.lib.properties.core.PropertiesFacade} 
 * the developer can access to the methods from this {@code Interface}, which is the 
 * preferred way (and not the usage through instanziation from the {@code Class} 
 * {@code DefaultSimpleProperties}).
 *
 * @author Naoghuman
 * @see    com.github.naoghuman.lib.properties.core.PropertiesFacade
 * @see    com.github.naoghuman.lib.properties.internal.DefaultSimpleProperties
 */
public interface SimpleProperties
/**
 * Searches for the property with the specified key in this property list.<br>
 * If the key is not found in this property list, the default property list,
 * and its defaults, recursively, are then checked. The method returns
 * {@code null} if the property is not found.
 * 
 * @param pathWithBundle The properties where value is stored.
 * @param key            The property key.
 * @return               The value in this property list with the specified 
 *                       key value.
 */
public String getProperty(final String pathWithBundle, final String key);
/**
 * Searches for the property with the specified key in this property list.<br>
 * If the key is not found in this property list, the default property list,
 * and its defaults, recursively, are then checked. The method returns the
 * default value argument if the property is not found.
 * 
 * @param pathWithBundle The properties where value is stored.
 * @param key            The property key.
 * @param defaultValue   If the key-value pair not stored in the properties  
 *                       then the {@code defaultValue} will be returned.
 * @return               The value in this property list with the specified 
 *                       key value.
 */
public String getProperty(final String pathWithBundle, final String key, final String defaultValue);
/**
 * Allowed access to the {@code System} properties. Gets the system property 
 * indicated by the specified key.
 * <p>
 * First, if there is a security manager, its {@code checkPropertyAccess} method 
 * is called with the key as its argument. This may result in a SecurityException.
 * <p>
 * If there is no current set of system properties, a set of system properties 
 * is first created and initialized in the same manner as for the {@code getProperties} 
 * method.
 * 
 * @param key The name of the system property.
 * @return    The string value of the system property, or {@code null} if 
 *            there is no property with that key.
 * @throws SecurityException If a security manager exists and its 
 *                           {@code checkPropertyAccess} method doesn't allow 
 *                           access to the specified system property.
 * @throws NullPointerException     If {@code key} is {@code null}.
 * @throws IllegalArgumentException If {@code key} is empty.
 * @see #setSystemProperty(java.lang.String, java.lang.String)
 */
public String getSystemProperty(final String key) throws SecurityException, NullPointerException, IllegalArgumentException;
/**
 * Allowed access to the {@code System} properties. Checks if the system property 
 * value equals the parameter value.
 * <p>
 * First, if there is a security manager, its {@code checkPropertyAccess} method 
 * is called with the key as its argument. This may result in a SecurityException.
 * <p>
 * If there is no current set of system properties, a set of system properties 
 * is first created and initialized in the same manner as for the {@code getProperties} 
 * method.
 * 
 * @param key   The name of the system property.
 * @param value The value which should checked against the value from the system.
 * @return      If the value from the key equals the parameter value.
 * @throws SecurityException  If a security manager exists and its 
 *         {@code checkPropertyAccess} method doesn't allow access to the 
 *         specified system property.
 * @throws NullPointerException     If {@code key}is {@code null}.
 * @throws IllegalArgumentException If {@code key} is empty.
 * @see #getSystemProperty(java.lang.String)
 * @see #setSystemProperty(java.lang.String, java.lang.String)
 */
public Boolean isSystemProperty(final String key, final String value) throws SecurityException, NullPointerException, IllegalArgumentException;
/**
 * Register with this method your {@code .properties} file.<br>
 * The parameter {@code pathWithBundle} have the format:<br>
 * {@code /your/package/path/to/your/FileToLoad.properties}.
 * <p>
 * The file should be in the {@code src/main/resources} folder with the 
 * previous named packaged structure in the specific maven module.
 * 
 * @param pathWithBundle The properties which should be register. If the 
 *                       properties always register nothing happen.
 */
public void register(final String pathWithBundle);
/**
 * Register with this method your {@code .properties} files.<br>
 * The parameter in {@code pathWithBundles} should have the format:<br>
 * {@code /your/package/path/to/your/FileToLoad.properties}.
 * <p>
 * The files should be in the {@code src/main/resources} folder with the 
 * previous named packaged structure in the specific maven module.
 * 
 * @param pathWithBundles The properties which should be register. If the 
 *                        properties always register nothing happen.
 */
public void register(final ArrayList<String> pathWithBundles);
/**
 * Register the given {@link java.util.List} as {@code System}properties.
 * Every entry in the {@link java.util.List} will splitted with the regex to 
 * a {@code System} property pair (key, value).
 * 
 * @param regex   The delimiting regular expression.
 * @param unnamed The {@link java.util.List} which will splitted.
 * @throws SecurityException If a security manager exists and its 
 *         {@code checkPropertyAccess} method doesn't allow access to the 
 *         specified system property.
 * @throws NullPointerException     If {@code key}or {@code value} is {@code null}.
 * @throws IllegalArgumentException If {@code key}is empty.
 */
public void registerSystemProperties(final String regex, final List<String> unnamed) throws SecurityException, NullPointerException, IllegalArgumentException;
/**
 * Allowed access to the {@code System} properties. Sets the system property 
 * indicated by the specified key.
 * <p>
 * First, if a security manager exists, its {@code SecurityManager.checkPermission}
 * method is called with a {@code PropertyPermission(key, "write")}
 * permission. This may result in a SecurityException being thrown. If no 
 * exception is thrown, the specified property is set to the given value.
 * 
 * @param key   The name of the system property.
 * @param value The value of the system property.
 * @throws SecurityException If a security manager exists and its 
 *         {@code checkPropertyAccess} method doesn't allow access to the 
 *         specified system property.
 * @throws NullPointerException     If {@code key} or {@code value}is {@code null}.
 * @throws IllegalArgumentException If {@code key} is empty.
 * @see #getSystemProperty(java.lang.String)
 */
public void setSystemProperty(final String key, final String value) throws SecurityException, NullPointerException, IllegalArgumentException;

Download

Current version is 0.5.1. Main points in this release are:

  • This is a minor update.
  • Update dependencies and the documentation.

Maven coordinates

<dependencies>
    <dependency>
        <groupId>com.github.naoghuman</groupId>
        <artifactId>lib-properties</artifactId>
        <version>0.5.1</version>
    </dependency>
</dependencies>

Download:

An overview about all existings releases can be found here:

Requirements

In the library are following libraries registered as dependencies:

Installation

Documentation

  • In section Api you can see the main point(s) to access the functionality in this library.
  • For additional information see the JavaDoc in the library itself.

Contribution

License

The project Lib-Properties is licensed under General Public License 3.0.

Autor

The project Lib-Properties is maintained by me, Peter Rogge. See Contact.

Contact

You can reach me under peter.rogge@yahoo.de.

Versions

Version
0.5.1
0.5.0
0.4.1
0.4.0