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 property
    protected static class  YAMLPropertyWriter.YamlEntry
    Internal class to store each property tree name with the key and value
  • Field Summary

    Fields inherited from class java.io.FilterWriter

    out

    Fields inherited from class java.io.Writer

    lock
  • Constructor Summary

    Constructors 
    Constructor Description
    YAMLPropertyWriter​(java.io.Writer _writer)
    Default constructor with ignoreListLength set true
    YAMLPropertyWriter​(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 fields
    void append​(YAMLPropertyWriter.Property _property)
    Write down the given property
    protected void append​(YAMLPropertyWriter.YamlEntry _yamlEntry)
    Write down the given yaml entry
    protected int calculateTabs()
    Accumulate the current entryPathCache tabulation considering that each list counts double
    protected 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 YamlEntry
    void 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

    Methods inherited from class java.io.FilterWriter

    close, flush, write, write, write

    Methods inherited from class java.io.Writer

    append, append, append, nullWriter, write, write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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.IOException
      Append 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

      protected void append​(YAMLPropertyWriter.YamlEntry _yamlEntry)
      Write down the given yaml entry
      Parameters:
      _yamlEntry - property to append
    • filterLength

      protected final boolean filterLength​(YAMLPropertyWriter.Property _property)
      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

      public void 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
      Parameters:
      _stream - stream of properties to append
    • append

      public void append​(YAMLPropertyWriter.Property _property)
      Write down the given property
      Parameters:
      _property - property to append