Class SimpleYamlImplementation
java.lang.Object
org.simpleyaml.configuration.implementation.api.YamlImplementationCommentable
org.simpleyaml.configuration.implementation.snakeyaml.SnakeYamlImplementation
org.simpleyaml.configuration.implementation.SimpleYamlImplementation
- All Implemented Interfaces:
Commentable,YamlImplementation
Default YAML implementation using snakeyaml high-level API and a custom comment parser / dumper.
-
Field Summary
Fields inherited from class org.simpleyaml.configuration.implementation.snakeyaml.SnakeYamlImplementation
dumperOptions, loaderOptions, resolver, yaml, yamlConstructor, yamlRepresenterFields inherited from class org.simpleyaml.configuration.implementation.api.YamlImplementationCommentable
options, yamlCommentMapper -
Constructor Summary
ConstructorsConstructorDescriptionSimpleYamlImplementation(SnakeYamlConstructor yamlConstructor, SnakeYamlRepresenter yamlRepresenter) SimpleYamlImplementation(SnakeYamlConstructor yamlConstructor, SnakeYamlRepresenter yamlRepresenter, org.yaml.snakeyaml.resolver.Resolver resolver) SimpleYamlImplementation(SnakeYamlRepresenter yamlRepresenter) SimpleYamlImplementation(org.yaml.snakeyaml.LoaderOptions loaderOptions, org.yaml.snakeyaml.DumperOptions dumperOptions) -
Method Summary
Modifier and TypeMethodDescriptionvoidconfigure(YamlConfigurationOptions options) Apply the configuration options to this implementation.voiddump(Writer writer, ConfigurationSection section) Dump section values to Yaml.voidload(Reader reader, ConfigurationSection section) Load Yaml to a configuration section.voidload(SupplierIO.Reader readerSupplier, ConfigurationSection section) Load Yaml to a configuration section.parseComments(Reader reader) Parse comments from a reader.voidsetComment(String path, String comment, CommentType type) Set a comment to the section or value selected by path.Methods inherited from class org.simpleyaml.configuration.implementation.snakeyaml.SnakeYamlImplementation
dumpYaml, getConstructor, getDumperOptions, getLoaderOptions, getName, getRepresenter, getResolver, getYaml, hasContent, resolveAnchor, sectionToMapping, setCommentsMapping, setCommentsSequence, trackMapping, trackSequenceMethods inherited from class org.simpleyaml.configuration.implementation.api.YamlImplementationCommentable
getComment, getCommentMapperMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.simpleyaml.configuration.comments.Commentable
getComment, setCommentMethods inherited from interface org.simpleyaml.configuration.implementation.api.YamlImplementation
dump, load
-
Constructor Details
-
SimpleYamlImplementation
public SimpleYamlImplementation() -
SimpleYamlImplementation
public SimpleYamlImplementation(org.yaml.snakeyaml.LoaderOptions loaderOptions, org.yaml.snakeyaml.DumperOptions dumperOptions) -
SimpleYamlImplementation
-
SimpleYamlImplementation
public SimpleYamlImplementation(SnakeYamlConstructor yamlConstructor, SnakeYamlRepresenter yamlRepresenter) -
SimpleYamlImplementation
public SimpleYamlImplementation(SnakeYamlConstructor yamlConstructor, SnakeYamlRepresenter yamlRepresenter, org.yaml.snakeyaml.resolver.Resolver resolver)
-
-
Method Details
-
setComment
Description copied from interface:CommentableSet a comment to the section or value selected by path. Comment will be indented automatically. Multi-line comments can be provided using \n character.- Specified by:
setCommentin interfaceCommentable- Overrides:
setCommentin classSnakeYamlImplementation- Parameters:
path- path of desired section or keycomment- the comment to add, # symbol is not neededtype- either above (BLOCK) or SIDE
-
load
public void load(SupplierIO.Reader readerSupplier, ConfigurationSection section) throws IOException, InvalidConfigurationException Description copied from interface:YamlImplementationLoad Yaml to a configuration section.- Parameters:
readerSupplier- a function providing a reader of Yaml contents to loadsection- the configuration to fill with the contents- Throws:
IOException- if cannot read contents.InvalidConfigurationException- if contents is not a valid Yaml configuration
-
load
public void load(Reader reader, ConfigurationSection section) throws IOException, InvalidConfigurationException Description copied from interface:YamlImplementationLoad Yaml to a configuration section.- Specified by:
loadin interfaceYamlImplementation- Overrides:
loadin classSnakeYamlImplementation- Parameters:
reader- a reader of Yaml contents to loadsection- the configuration to fill with the contents- Throws:
IOException- if cannot read contents.InvalidConfigurationException- if contents is not a valid Yaml configuration
-
dump
Description copied from interface:YamlImplementationDump section values to Yaml.- Specified by:
dumpin interfaceYamlImplementation- Overrides:
dumpin classSnakeYamlImplementation- Parameters:
writer- writer to dump valuessection- section with values to dump- Throws:
IOException
-
parseComments
Parse comments from a reader.- Parameters:
reader- Reader of a Configuration to parse.- Returns:
- a comment mapper with comments parsed
- Throws:
InvalidConfigurationException- if it hasn't been possible to read the contents
-
configure
Description copied from interface:YamlImplementationApply the configuration options to this implementation.- Specified by:
configurein interfaceYamlImplementation- Overrides:
configurein classSnakeYamlImplementation- Parameters:
options- yaml options
-