Class YAMLPropertyWriter
java.lang.Object
java.io.Writer
java.io.FilterWriter
org.bytemechanics.config.manager.internal.commons.io.YAMLPropertyWriter
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.Appendable
,java.lang.AutoCloseable
public class YAMLPropertyWriter
extends java.io.FilterWriter
Property writer to yaml
- Author:
- afarre
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
YAMLPropertyWriter.Property
Input propertyprotected static class
YAMLPropertyWriter.YamlEntry
Internal class to store each property tree name with the key and value -
Field Summary
-
Constructor Summary
Constructors Constructor Description YAMLPropertyWriter(java.io.Writer _writer)
Default constructor with ignoreListLength set trueYAMLPropertyWriter(java.io.Writer _writer, boolean _ignoreListLength)
Constructor capable to define ignoreListLength value -
Method Summary
Modifier and Type Method Description protected void
append(int _depth, java.lang.String _name, java.lang.String _value, boolean _isList)
Append to the underlaying stream the correct yaml format for the given fieldsvoid
append(YAMLPropertyWriter.Property _property)
Write down the given propertyprotected void
append(YAMLPropertyWriter.YamlEntry _yamlEntry)
Write down the given yaml entryprotected int
calculateTabs()
Accumulate the current entryPathCache tabulation considering that each list counts doubleprotected boolean
filterLength(YAMLPropertyWriter.Property _property)
Return true if ignoreListLength is disabled or the property is not length (ends with [*].length)protected java.util.stream.Stream<YAMLPropertyWriter.YamlEntry>
splitPath(YAMLPropertyWriter.Property _property)
Divide the given _property into a stream of YamlEntryvoid
write(java.util.stream.Stream<YAMLPropertyWriter.Property> _stream)
Write down all stream elements until end of stream IMPORTANT: its mandatory to provide the stream ordered, otherwise will have unexpected results
-
Constructor Details
-
YAMLPropertyWriter
public YAMLPropertyWriter(java.io.Writer _writer)Default constructor with ignoreListLength set true- Parameters:
_writer
- parent reader
-
YAMLPropertyWriter
public YAMLPropertyWriter(java.io.Writer _writer, boolean _ignoreListLength)Constructor capable to define ignoreListLength value- Parameters:
_writer
- parent reader_ignoreListLength
- ignore list length and do not append it
-
-
Method Details
-
append
protected final void append(int _depth, java.lang.String _name, java.lang.String _value, boolean _isList) throws java.io.IOExceptionAppend to the underlaying stream the correct yaml format for the given fields- Parameters:
_depth
- number of tabs to use (double space)_name
- key name_value
- value_isList
- flag to indicate if is a list- Throws:
java.io.IOException
- if something happens
-
calculateTabs
protected int calculateTabs()Accumulate the current entryPathCache tabulation considering that each list counts double- Returns:
- number of tabs in entryPathCache counting lists as double
-
append
Write down the given yaml entry- Parameters:
_yamlEntry
- property to append
-
filterLength
Return true if ignoreListLength is disabled or the property is not length (ends with [*].length)- Parameters:
_property
- property to validate- Returns:
- true if and only if ignoreListLength is disabled or the property is not length
-
splitPath
protected java.util.stream.Stream<YAMLPropertyWriter.YamlEntry> splitPath(YAMLPropertyWriter.Property _property)Divide the given _property into a stream of YamlEntry- Parameters:
_property
- property to convert- Returns:
- stream of YamlEntry corresponding to the given _property
-
write
Write down all stream elements until end of stream IMPORTANT: its mandatory to provide the stream ordered, otherwise will have unexpected results- Parameters:
_stream
- stream of properties to append
-
append
Write down the given property- Parameters:
_property
- property to append
-