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
ModifierConstructorDescriptionprotected
HumanReadableConfigurationFactory(Class<C> configClass, ConfigurationOptions options)
Creates from a config class and config options -
Method Summary
Modifier and TypeMethodDescriptionabstract Charset
charset()
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.void
writeMap(Map<String,Object> config, OutputStream outputStream)
Writes a map of config values to an output streamabstract void
Writes a map of config values to a writervoid
writeMap(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
- ifconfigClass
oroptions
is nullIllegalArgumentException
- ifconfigClass
is 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, InvalidConfigExceptionDescription copied from class:ConfigurationFormatFactory
Loads a map of config values from an input channel.- Specified by:
loadMap
in 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, InvalidConfigExceptionDescription copied from class:ConfigurationFormatFactory
Loads a map of config values from an input stream.- Specified by:
loadMap
in 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, InvalidConfigExceptionLoads 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:ConfigurationFormatFactory
Writes a map of config values to an output channel- Specified by:
writeMap
in classConfigurationFormatFactory<C>
- Parameters:
config
- the hierarchical configuration mapwriteChannel
- the channel to which to write- Throws:
IOException
- if an I/O error occurs
-
writeMap
public final void writeMap(Map<String,Object> config, OutputStream outputStream) throws IOExceptionDescription copied from class:ConfigurationFormatFactory
Writes a map of config values to an output stream- Specified by:
writeMap
in 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
-