Package space.arim.dazzleconf.factory
Class HumanReadableConfigurationFactory<C>
java.lang.Object
space.arim.dazzleconf.factory.ConfigurationFormatFactory<C>
space.arim.dazzleconf.factory.HumanReadableConfigurationFactory<C>
- Type Parameters:
C- the type of the configuration
- All Implemented Interfaces:
ConfigurationFactory<C>
Extension of
ConfigurationFormatFactory which turns ReadableByteChannel and
InputStream into Reader and WritableByteChannel and OutputStream
into Writer. Performs buffering as well.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHumanReadableConfigurationFactory(Class<C> configClass, ConfigurationOptions options) Creates from a config class and config options -
Method Summary
Modifier and TypeMethodDescriptionabstract Charsetcharset()Gets the charset which will be used to create readers and writersloadMap(InputStream inputStream) Loads a map of config values from an input stream.Loads a map of config values from a readerloadMap(ReadableByteChannel readChannel) Loads a map of config values from an input channel.final voidwriteMap(Map<String, Object> config, OutputStream outputStream) Writes a map of config values to an output streamabstract voidWrites a map of config values to a writerfinal voidwriteMap(Map<String, Object> config, WritableByteChannel writeChannel) Writes a map of config values to an output channelMethods inherited from class space.arim.dazzleconf.factory.ConfigurationFormatFactory
getConfigClass, getHeader, getOptions, load, load, load, load, loadDefaults, pseudoCommentsSuffix, supportsCommentsThroughWrapper, write, write
-
Constructor Details
-
HumanReadableConfigurationFactory
Creates from a config class and config options- Parameters:
configClass- the config classoptions- configuration options- Throws:
NullPointerException- ifconfigClassoroptionsis nullIllegalArgumentException- ifconfigClassis not an interfaceIllDefinedConfigException- if the configuration entries defined in the config class are invalid
-
-
Method Details
-
charset
Gets the charset which will be used to create readers and writers- Returns:
- the charset
-
loadMap
public final Map<String,Object> loadMap(ReadableByteChannel readChannel) throws IOException, InvalidConfigException Description copied from class:ConfigurationFormatFactoryLoads a map of config values from an input channel.- Specified by:
loadMapin classConfigurationFormatFactory<C>- Parameters:
readChannel- the channel from which to read- Returns:
- the hierarchical configuration map
- Throws:
IOException- if an I/O error occursInvalidConfigException- if the configuration format dictates the data is not valid syntax. UsuallyConfigFormatSyntaxException
-
loadMap
public final Map<String,Object> loadMap(InputStream inputStream) throws IOException, InvalidConfigException Description copied from class:ConfigurationFormatFactoryLoads a map of config values from an input stream.- Specified by:
loadMapin classConfigurationFormatFactory<C>- Parameters:
inputStream- the stream from which to read- Returns:
- the hierarchical configuration map
- Throws:
IOException- if an I/O error occursInvalidConfigException- if the configuration format dictates the data is not valid syntax. UsuallyConfigFormatSyntaxException
-
loadMap
public abstract Map<String,Object> loadMap(Reader reader) throws IOException, InvalidConfigException Loads a map of config values from a reader- Parameters:
reader- the reader- Returns:
- the hierarchical configuration map
- Throws:
IOException- if an I/O error occursInvalidConfigException- if the configuration format dictates the data is not valid syntax. * UsuallyConfigFormatSyntaxException
-
writeMap
public final void writeMap(Map<String, Object> config, WritableByteChannel writeChannel) throws IOExceptionDescription copied from class:ConfigurationFormatFactoryWrites a map of config values to an output channel- Specified by:
writeMapin classConfigurationFormatFactory<C>- Parameters:
config- the hierarchical configuration mapwriteChannel- the channel to which to write- Throws:
IOException- if an I/O error occurs
-
writeMap
Description copied from class:ConfigurationFormatFactoryWrites a map of config values to an output stream- Specified by:
writeMapin classConfigurationFormatFactory<C>- Parameters:
config- the hierarchical configuration mapoutputStream- the stream to which to write- Throws:
IOException- if an I/O error occurs
-
writeMap
Writes a map of config values to a writer- Parameters:
config- the hierarchical configuration mapwriter- the writer- Throws:
IOException- if an I/O error occurs
-