[Index]

JHPropertyTyped Tools



Tools and helper classes/methods which can make your day much easier.

Class Method(s) Short description Java Doc Description
dk.heick.properties.collections.PropertyCollectionUtil getPropertyNameGroups(...) Group property names This methods returns a list of group names, which the properties can de divided into.
This typically used with view a list of properties on a web pages/gui, where it can be a nice feature to group them a bit.
This is done by group all property names by the part of property name which is before the subNameDivider.

Example where subNameDivider is [.] :
  • awt.toolkit -> awt
  • java.class.path -> java
  • java.version -> java
  • os.name -> os
  • user.name -> user


dk.heick.properties.collections.PropertyCollectionUtil getPropertyListStartWiths(...) Filter properties Retrieves a list of properties which name starts with a specific string.



dk.heick.properties.collections.PropertyCollectionPrinter generatePropertyFileContents(...) Generate dummy property file contents This class can "print" an PropertyCollection. This is a tool class where you as a developer take a PropertyCollection instance and it will
print the property.name = default.value to a Writer or a PrintStream.
This can be used for generation initial properties files for further modification


For a property with a not null but valid default value the resulting line is:
  property.name = getDefaultValueAsString() 


For a property with a not null but invalid default value the resulting line is:
  property.name = Default value invalid:exception.message


For a property with a null as default value the resulting line is:
  property.name = [NULL]


dk.heick.properties.collections.PropertiesJavaDefinitionPrinter generateJavaDefinition(...) Generate dummy Property java definitions This will take a Properties instance a generate public static final Property.... definitions.

This is a convenient method when converting your existing properties handling to use this library.

If suggestType is true and the value not null, it will try an analyze the value to see which matches best and output that type.

Otherwise it will make a "dummy" definition which do not compile since the generator have no idea of type, default values and PropertyIO.

The line it will generate for each property found will look like this:

    public final static Property<Type> NAME = new Property<Type>("name",new PropertyType());

or if suggestion found:

//Value=[sun.awt.windows.WPrinterJob]
  public final static Property<Class<?>> JAVA_AWT_PRINTERJOB = new Property<Class<?>>("java.awt.printerjob",new ClassnamePropertyType());

The output is written to "System.out" per default.
See more at PropertiesJavaDefinitionPrinter
See more at CommentedProperties
See more at PrintLines

public static void main(String[] args) {
	BasicConfigurator.configure();
	PropertyFrameworkGlobals.setLogFileValidations(false);
	PropertyFrameworkGlobals.setAutoEncryptPasswords(false);
	List<String> lines = PropertiesJavaDefinitionPrinter.generateJavaDefinitionsAsList(System.getProperties(),true);
	PrintLines.print(lines);
}

OR

public static void main(String[] args) {
	BasicConfigurator.configure();
	PropertyFrameworkGlobals.setLogFileValidations(false);
	PropertyFrameworkGlobals.setAutoEncryptPasswords(false);
	List<String> lines = PropertiesJavaDefinitionPrinter.generateJavaDefinitionsAsList(new File("myproperties.properties"),true,true,true,true,true);
	PrintLines.print(lines);
}




dk.heick.properties.io.FilePropertyIOFactory createFilePropertyIO(...) Search for a property file and create a FilePropertyIO. This will search for property file by name, in a directory and its sub directories, and create a FilePropertyIO with the first file which matches.


dk.heick.properties.io.CompositePropertyIOFactory create(...) Create a CompositePropertyIO with many FilePropertyIO's. Create a CompositePropertyIO either with many files or by search for many files.


package dk.heick.properties.types.utils.*     A lot of nice utilities methods, many with generic capabilities - I like good Utils classes, I collect them.


dk.heick.properties.io.xml.XMLFileIO<T>     Generic JAXB File IO Utility - File to Class instance and Class instance to File
dk.heick.properties.types.utils.GenericFilter<T>     An interface which determines if the object of type T should be accepted.
dk.heick.properties.types.utils.GenericFilterUtils     Static method utilities for GenericFilter.
dk.heick.properties.types.utils.GeoUtils     Large library of Latitude/Longitude utilitiy methods.
dk.heick.properties.types.utils.ListUtils     Static methods to convert X to sorted instances of List<T>.
dk.heick.properties.types.utils.MapUtils     Static utility methods for Hashtables, HashMaps, HashSets and Map.
dk.heick.properties.types.utils.MathUtils     Different Math utilities methods.
dk.heick.properties.types.utils.StringList     Convenience class for a list of strings, extension of ArrayList<String>.
dk.heick.properties.types.utils.StringUtils     Assorted string utility methods.
dk.heick.properties.types.utils.XMLUtils     Assorted XML utility methods.
dk.heick.properties.types.utils.ArrayUtils     Assorted utility methods for arrays, usually with generics.
Class Method(s) Short description Java Doc Description