Class AbstractConfigurationLoader<N extends ScopedConfigurationNode<N>>
- Type Parameters:
- N- the- ConfigurationNodetype produced by the loader
- All Implemented Interfaces:
- ConfigurationNodeFactory<N>,- ConfigurationLoader<N>
- Direct Known Subclasses:
- GsonConfigurationLoader,- HoconConfigurationLoader,- JacksonConfigurationLoader,- XmlConfigurationLoader,- YamlConfigurationLoader
BufferedReader
 suppliers, providing a consistent API for loaders to read from and write to.
 Either the source or sink may be null. If this is true, this loader may
 not support either loading or saving. In this case, implementing classes are
 expected to throw an IOException for the unsupported operation.
- Since:
- 4.0.0
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classAbstractConfigurationLoader.Builder<T extends AbstractConfigurationLoader.Builder<T,L>, L extends AbstractConfigurationLoader<?>> An abstract builder implementation forAbstractConfigurationLoaders.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final PatternA pattern that will match line breaks in comments.static final StringThe escape sequence used by Configurate to separate comment lines.protected final @Nullable Callable<BufferedWriter>The writer sink for this loader.protected final @Nullable Callable<BufferedReader>The reader source for this loader.protected static final StringThe line separator used by the system.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedAbstractConfigurationLoader(AbstractConfigurationLoader.Builder<?, ?> builder, CommentHandler[] commentHandlers) Create a loader instance from a builder.
- 
Method SummaryModifier and TypeMethodDescriptionfinal booleancanLoad()Gets if this loader is capable of loading configurations.final booleancanSave()Gets if this loader is capable of saving configurations.protected voidPerform format-specific validation of a node.Gets the primaryCommentHandlerused by this loader.Default options for the types of nodes created by this factory.load(ConfigurationOptions options) Attempts to load aConfigurationNodeusing this loader, from the defined source.protected abstract voidloadInternal(N node, BufferedReader reader) Using a created node, attempt to read a configuration file.Attempts to load data from the defined source into aConfigurationReference.voidsave(ConfigurationNode node) Attempts to save aConfigurationNodeusing this loader, to the defined sink.protected abstract voidsaveInternal(ConfigurationNode node, Writer writer) Perform a save of the node to the provided writer.protected voidwriteHeaderInternal(Writer writer) Write out any implementation-specific file header.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.spongepowered.configurate.loader.ConfigurationLoaderloadMethods inherited from interface org.spongepowered.configurate.ConfigurationNodeFactorycreateNode, createNode, createNode, createNode, toListCollector, toListCollector, toMapCollector, toMapCollector
- 
Field Details- 
CONFIGURATE_LINE_SEPARATORThe escape sequence used by Configurate to separate comment lines.- See Also:
 
- 
CONFIGURATE_LINE_PATTERNA pattern that will match line breaks in comments.
- 
SYSTEM_LINE_SEPARATORThe line separator used by the system.- See Also:
 
- 
sourceThe reader source for this loader.Can be null (for loaders which don't support loading!) 
- 
sinkThe writer sink for this loader.Can be null (for loaders which don't support saving!) 
 
- 
- 
Constructor Details- 
AbstractConfigurationLoaderprotected AbstractConfigurationLoader(AbstractConfigurationLoader.Builder<?, ?> builder, CommentHandler[] commentHandlers) Create a loader instance from a builder.- Parameters:
- builder- the user-configured builder
- commentHandlers- supported comment formats for extracting the configuration header
- Since:
- 4.0.0
 
 
- 
- 
Method Details- 
defaultCommentHandlerGets the primaryCommentHandlerused by this loader.- Returns:
- the default comment handler
- Since:
- 4.0.0
 
- 
loadToReferenceDescription copied from interface:ConfigurationLoaderAttempts to load data from the defined source into aConfigurationReference. The returned reference will not reload automatically.- Specified by:
- loadToReferencein interface- ConfigurationLoader<N extends ScopedConfigurationNode<N>>
- Returns:
- the created reference
- Throws:
- ConfigurateException- when an error occurs within the loader
- See Also:
 
- 
loadDescription copied from interface:ConfigurationLoaderAttempts to load aConfigurationNodeusing this loader, from the defined source.The resultant node represents the root of the configuration being loaded. - Specified by:
- loadin interface- ConfigurationLoader<N extends ScopedConfigurationNode<N>>
- Parameters:
- options- the options to load with
- Returns:
- the newly constructed node
- Throws:
- ParsingException
 
- 
loadInternal@ForOverride protected abstract void loadInternal(N node, BufferedReader reader) throws ParsingException Using a created node, attempt to read a configuration file.The header will already have been read if applicable. - Parameters:
- node- node to load into
- reader- reader to load from
- Throws:
- ParsingException- if an error occurs at any stage of loading
- Since:
- 4.0.0
 
- 
saveDescription copied from interface:ConfigurationLoaderAttempts to save aConfigurationNodeusing this loader, to the defined sink.- Specified by:
- savein interface- ConfigurationLoader<N extends ScopedConfigurationNode<N>>
- Parameters:
- node- the node to save
- Throws:
- ConfigurateException- if any sort of error occurs with writing or generating the configuration
 
- 
checkCanWritePerform format-specific validation of a node.This method will be called before a writer is opened, allowing the loader to perform any basic validation it may need to before it opens a writer replacing an existing file. - Parameters:
- node- the node to write
- Throws:
- ConfigurateException- if any invalid data is present
- Since:
- 4.1.0
 
- 
writeHeaderInternalWrite out any implementation-specific file header.- Parameters:
- writer- writer to output to
- Throws:
- IOException- if an error occurs in the implementation
- Since:
- 4.0.0
 
- 
saveInternal@ForOverride protected abstract void saveInternal(ConfigurationNode node, Writer writer) throws ConfigurateException Perform a save of the node to the provided writer.- Parameters:
- node- node to save
- writer- writer to output to
- Throws:
- ConfigurateException- if any of the node's data is unsavable
- Since:
- 4.0.0
 
- 
defaultOptionsDescription copied from interface:ConfigurationNodeFactoryDefault options for the types of nodes created by this factory.All values must match what a created node will see, but some values may be determined by this factory to be non user-modifiable. These should be documented for any factory implementation. - Specified by:
- defaultOptionsin interface- ConfigurationNodeFactory<N extends ScopedConfigurationNode<N>>
- Returns:
- default options
 
- 
canLoadDescription copied from interface:ConfigurationLoaderGets if this loader is capable of loading configurations.- Specified by:
- canLoadin interface- ConfigurationLoader<N extends ScopedConfigurationNode<N>>
- Returns:
- if this loader can load
 
- 
canSaveDescription copied from interface:ConfigurationLoaderGets if this loader is capable of saving configurations.- Specified by:
- canSavein interface- ConfigurationLoader<N extends ScopedConfigurationNode<N>>
- Returns:
- if this loader can save
 
 
-