Class AbstractCanonicalMapFactory

java.lang.Object
org.refcodes.struct.ext.factory.AbstractCanonicalMapFactory
All Implemented Interfaces:
org.refcodes.factory.MarshalTypeFactory<org.refcodes.struct.CanonicalMap,String>, org.refcodes.factory.MarshalTypeFactory.MarshalTypeFactoryComplement<org.refcodes.struct.CanonicalMap,InputStream>, org.refcodes.factory.MarshalTypeFactory.MarshalTypeFactoryComposite<org.refcodes.struct.CanonicalMap,String,InputStream>, org.refcodes.factory.UnmarshalTypeFactory<org.refcodes.struct.CanonicalMap.CanonicalMapBuilder,String>, org.refcodes.factory.UnmarshalTypeFactory.UnmarshalTypeFactoryComplement<org.refcodes.struct.CanonicalMap.CanonicalMapBuilder,InputStream>, org.refcodes.factory.UnmarshalTypeFactory.UnmarshalTypeFactoryComposite<org.refcodes.struct.CanonicalMap.CanonicalMapBuilder,String,InputStream>, CanonicalMapFactory
Direct Known Subclasses:
HtmlCanonicalMapFactory, JavaCanonicalMapFactory, JsonCanonicalMapFactory, TomlCanonicalMapFactory, XmlCanonicalMapFactory, YamlCanonicalMapFactory

public abstract class AbstractCanonicalMapFactory extends Object implements CanonicalMapFactory
Base class for the CanonicalMapFactory providing base functionality.
  • Constructor Details

    • AbstractCanonicalMapFactory

      public AbstractCanonicalMapFactory()
  • Method Details

    • postProcess

      protected void postProcess(org.refcodes.struct.CanonicalMap.CanonicalMapBuilder aProperties)
      This method takes care on giving nodes with children an own value: E.g. "yaml" files cannot have a value for a node which has sub-nodes, same applies to "json" and "xml" which makes using the "mixed content" mechanism hard. When we require a value for a node (path) which may have sub-nodes (sub-paths), then e.g. a this sub-node assigns a value to it's parent node. E.g. For "xml", the attribute this="value" attached to an element takes care on giving an XML element with children an own value. See THIS_ATTRIBUTES.
      Parameters:
      aProperties - The properties where the "this" children are to assign a value to their parents.
    • toString

      protected String toString(InputStream aInputStream) throws IOException
      Converts the given InputStream to a String.
      Parameters:
      aInputStream - The InputStream to be converted.
      Returns:
      The according String.
      Throws:
      IOException - thrown in case conversion failed.
    • toInputStream

      protected InputStream toInputStream(String aString)
      Converts the given String to an InputStream.
      Parameters:
      aString - The String to be converted.
      Returns:
      The according InputStream.
    • toDelimiter

      protected char toDelimiter(Map<String,String> aProperties, char aDefaultDelimiter)
      Retrieves the delimiter to be used for the data structure.
      Parameters:
      aProperties - The properties from which to retrieve the delimiter.
      aDefaultDelimiter - The delimiter to be used when there is none in the properties defined.
      Returns:
      The according delimiter or the PathMap.DELIMITER if none was provided in the properties.
    • toSupportedDelimiters

      protected char[] toSupportedDelimiters(Map<String,String> aProperties)
      Retrieves the supported delimiters to be used when unmarshaling an external representation.
      Parameters:
      aProperties - The properties from which to retrieve the supported delimiters. Them delimiters are provided in a String.
      Returns:
      The according supported delimiters or the PathMap.DELIMITER if none was provided in the properties.
    • toComment

      protected String toComment(Map<String,String> aProperties)
      Retrieves the comment to be used in the header of the marshaled representation.
      Parameters:
      aProperties - The properties from which to retrieve the comment.
      Returns:
      The according delimiter or the CanonicalMapFactory.COMMENT_PROPERTY if none was provided in the properties.
    • toXml

      protected static String toXml(org.refcodes.struct.CanonicalMap aCanonicalMap)
      Converts a CanonicalMap to XML.
      Parameters:
      aCanonicalMap - The CanonicalMap to marshal.
      Returns:
      The resulting XML.