Package org.refcodes.struct.ext.factory
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
Base class for the CanonicalMapFactory providing base functionality.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.factory.MarshalTypeFactory
org.refcodes.factory.MarshalTypeFactory.MarshalTypeFactoryComplement<T extends Object,
C extends Object>, org.refcodes.factory.MarshalTypeFactory.MarshalTypeFactoryComposite<T extends Object, SRC extends Object, C extends Object> Nested classes/interfaces inherited from interface org.refcodes.factory.UnmarshalTypeFactory
org.refcodes.factory.UnmarshalTypeFactory.UnmarshalTypeFactoryComplement<T extends Object,
C extends Object>, org.refcodes.factory.UnmarshalTypeFactory.UnmarshalTypeFactoryComposite<T extends Object, SRC extends Object, C extends Object> -
Field Summary
Fields inherited from interface org.refcodes.struct.ext.factory.CanonicalMapFactory
COMMENT_PROPERTY, DELIMITER_PROPERTY, SUPPORTED_DELIMITERS_PROPERTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
postProcess
(org.refcodes.struct.CanonicalMap.CanonicalMapBuilder aProperties) This method takes care on giving nodes with children an own value: E.g.protected String
Retrieves the comment to be used in the header of the marshaled representation.protected char
toDelimiter
(Map<String, String> aProperties, char aDefaultDelimiter) Retrieves the delimiter to be used for the data structure.protected InputStream
toInputStream
(String aString) Converts the givenString
to anInputStream
.protected String
toString
(InputStream aInputStream) Converts the givenInputStream
to aString
.protected char[]
toSupportedDelimiters
(Map<String, String> aProperties) Retrieves the supported delimiters to be used when unmarshaling an external representation.protected static String
toXml
(org.refcodes.struct.CanonicalMap aCanonicalMap) Converts aCanonicalMap
to XML.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.refcodes.struct.ext.factory.CanonicalMapFactory
toMarshaled, toMarshaled, toUnmarshaled, toUnmarshaled
Methods inherited from interface org.refcodes.factory.MarshalTypeFactory.MarshalTypeFactoryComplement
fromUnmarshaled, fromUnmarshaled
Methods inherited from interface org.refcodes.factory.UnmarshalTypeFactory.UnmarshalTypeFactoryComplement
fromMarshaled, fromMarshaled
-
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. athis
sub-node assigns a value to it's parent node. E.g. For "xml", the attributethis="value"
attached to an element takes care on giving an XML element with children an own value. SeeTHIS_ATTRIBUTES
.- Parameters:
aProperties
- The properties where the "this" children are to assign a value to their parents.
-
toString
Converts the givenInputStream
to aString
.- Parameters:
aInputStream
- TheInputStream
to be converted.- Returns:
- The according
String
. - Throws:
IOException
- thrown in case conversion failed.
-
toInputStream
Converts the givenString
to anInputStream
.- Parameters:
aString
- TheString
to be converted.- Returns:
- The according
InputStream
.
-
toDelimiter
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
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 aString
.- Returns:
- The according supported delimiters or the
PathMap.DELIMITER
if none was provided in the properties.
-
toComment
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
Converts aCanonicalMap
to XML.- Parameters:
aCanonicalMap
- TheCanonicalMap
to marshal.- Returns:
- The resulting XML.
-