Package ninja.leaping.configurate.loader
Class AbstractConfigurationLoader<NodeType extends ConfigurationNode>
java.lang.Object
ninja.leaping.configurate.loader.AbstractConfigurationLoader<NodeType>
- Type Parameters:
- NodeType- The- ConfigurationNodetype produced by the loader
- All Implemented Interfaces:
- ConfigurationLoader<NodeType>
- Direct Known Subclasses:
- GsonConfigurationLoader,- HoconConfigurationLoader,- JSONConfigurationLoader,- XMLConfigurationLoader,- YAMLConfigurationLoader
public abstract class AbstractConfigurationLoader<NodeType extends ConfigurationNode> extends Object implements ConfigurationLoader<NodeType>
Base class for many stream-based configuration loaders. This class provides conversion from a variety of input
 sources to CharSource/Sink objects, 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.
- 
Nested Class SummaryNested Classes Modifier and Type Class Description protected static classAbstractConfigurationLoader.Builder<T extends AbstractConfigurationLoader.Builder<T>>An abstract builder implementation forAbstractConfigurationLoaders.
- 
Field SummaryFields Modifier and Type Field Description static StringCONFIGURATE_LINE_SEPARATORThe escape sequence used by Configurate to separate comment linesprotected static SplitterLINE_SPLITTERASplitterfor splitting comment linesprotected @Nullable Callable<BufferedWriter>sinkThe writer sink for this loader.protected @Nullable Callable<BufferedReader>sourceThe reader source for this loader.protected static StringSYSTEM_LINE_SEPARATORThe line separator used by the system
- 
Constructor SummaryConstructors Modifier Constructor Description protectedAbstractConfigurationLoader(@NonNull AbstractConfigurationLoader.Builder<?> builder, @NonNull CommentHandler[] commentHandlers)
- 
Method SummaryModifier and Type Method Description booleancanLoad()Gets if this loader is capable of loading configurations.booleancanSave()Gets if this loader is capable of saving configurations.@NonNull CommentHandlergetDefaultCommentHandler()Gets the primaryCommentHandlerused by this loader.@NonNull ConfigurationOptionsgetDefaultOptions()Gets the defaultConfigurationOptionsused by the loader.@NonNull NodeTypeload(@NonNull ConfigurationOptions options)Attempts to load aConfigurationNodeusing this loader, from the defined source.protected abstract voidloadInternal(NodeType node, BufferedReader reader)voidsave(@NonNull ConfigurationNode node)Attempts to save aConfigurationNodeusing this loader, to the defined sink.protected abstract voidsaveInternal(ConfigurationNode node, Writer writer)protected voidwriteHeaderInternal(Writer writer)Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ninja.leaping.configurate.loader.ConfigurationLoadercreateEmptyNode, createEmptyNode, load, loadToReference
- 
Field Details- 
CONFIGURATE_LINE_SEPARATORThe escape sequence used by Configurate to separate comment lines- See Also:
- Constant Field Values
 
- 
LINE_SPLITTERASplitterfor splitting comment lines
- 
SYSTEM_LINE_SEPARATORThe line separator used by the system- See Also:
- System.lineSeparator()
 
- 
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(@NonNull AbstractConfigurationLoader.Builder<?> builder, @NonNull CommentHandler[] commentHandlers)
 
- 
- 
Method Details- 
getDefaultCommentHandlerGets the primaryCommentHandlerused by this loader.- Returns:
- The default comment handler
 
- 
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<NodeType extends ConfigurationNode>
- Parameters:
- options- The options to load with
- Returns:
- The newly constructed node
- Throws:
- IOException- if any sort of error occurs with reading or parsing the configuration
 
- 
loadInternal- Throws:
- IOException
 
- 
saveDescription copied from interface:ConfigurationLoaderAttempts to save aConfigurationNodeusing this loader, to the defined sink.- Specified by:
- savein interface- ConfigurationLoader<NodeType extends ConfigurationNode>
- Parameters:
- node- The node to save
- Throws:
- IOException- if any sort of error occurs with writing or generating the configuration
 
- 
writeHeaderInternal- Throws:
- IOException
 
- 
saveInternal- Throws:
- IOException
 
- 
getDefaultOptionsDescription copied from interface:ConfigurationLoaderGets the defaultConfigurationOptionsused by the loader.New nodes will be created using the default options if a specific set is not defined. - Specified by:
- getDefaultOptionsin interface- ConfigurationLoader<NodeType extends ConfigurationNode>
- Returns:
- The default options
 
- 
canLoadDescription copied from interface:ConfigurationLoaderGets if this loader is capable of loading configurations.- Specified by:
- canLoadin interface- ConfigurationLoader<NodeType extends ConfigurationNode>
- Returns:
- If this loader can load
 
- 
canSaveDescription copied from interface:ConfigurationLoaderGets if this loader is capable of saving configurations.- Specified by:
- canSavein interface- ConfigurationLoader<NodeType extends ConfigurationNode>
- Returns:
- If this loader can save
 
 
-