Class BaseRepresenter
- java.lang.Object
-
- org.snakeyaml.engine.v2.representer.BaseRepresenter
-
- Direct Known Subclasses:
StandardRepresenter
public abstract class BaseRepresenter extends Object
Represent basic YAML structures: scalar, sequence, mapping
-
-
Field Summary
Fields Modifier and Type Field Description protected FlowStyledefaultFlowStyleflow style for collectionsprotected ScalarStyledefaultScalarStylescalar styleprotected RepresentToNodenullRepresenterin Java 'null' is not a type.protected ObjectobjectToRepresentthe current object to be converted to Nodeprotected Map<Class<?>,RepresentToNode>parentClassRepresentersKeep representers which match a parent of the class to be representedprotected Map<Object,org.snakeyaml.engine.v2.nodes.Node>representedObjectsKeep references of already represented instances.protected Map<Class<?>,RepresentToNode>representersKeep representers which must match the class exactly
-
Constructor Summary
Constructors Constructor Description BaseRepresenter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Optional<RepresentToNode>findRepresenterFor(Object data)Find the representer which is suitable to represent the internal structure of the provided instance to a Nodeorg.snakeyaml.engine.v2.nodes.Noderepresent(Object data)Represent the provided Java instance to a Nodeprotected org.snakeyaml.engine.v2.nodes.NoderepresentData(Object data)Find the representer and use it to create the Node from instanceprotected org.snakeyaml.engine.v2.nodes.NoderepresentMapping(org.snakeyaml.engine.v2.nodes.Tag tag, Map<?,?> mapping, FlowStyle flowStyle)Create Node for the provided Mapprotected org.snakeyaml.engine.v2.nodes.NodeTuplerepresentMappingEntry(Map.Entry<?,?> entry)Create a tuple for one key pairprotected org.snakeyaml.engine.v2.nodes.NoderepresentScalar(org.snakeyaml.engine.v2.nodes.Tag tag, String value)Create Node for string using PLAIN scalar style if possibleprotected org.snakeyaml.engine.v2.nodes.NoderepresentScalar(org.snakeyaml.engine.v2.nodes.Tag tag, String value, ScalarStyle style)Create Scalar Node from stringprotected org.snakeyaml.engine.v2.nodes.NoderepresentSequence(org.snakeyaml.engine.v2.nodes.Tag tag, Iterable<?> sequence, FlowStyle flowStyle)Create Node
-
-
-
Field Detail
-
representers
protected final Map<Class<?>,RepresentToNode> representers
Keep representers which must match the class exactly
-
parentClassRepresenters
protected final Map<Class<?>,RepresentToNode> parentClassRepresenters
Keep representers which match a parent of the class to be represented
-
representedObjects
protected final Map<Object,org.snakeyaml.engine.v2.nodes.Node> representedObjects
Keep references of already represented instances. The order is important (map can be also a sequence of key-values)
-
nullRepresenter
protected RepresentToNode nullRepresenter
in Java 'null' is not a type. So we have to keep the null representer separately
-
defaultScalarStyle
protected ScalarStyle defaultScalarStyle
scalar style
-
defaultFlowStyle
protected FlowStyle defaultFlowStyle
flow style for collections
-
objectToRepresent
protected Object objectToRepresent
the current object to be converted to Node
-
-
Method Detail
-
represent
public org.snakeyaml.engine.v2.nodes.Node represent(Object data)
Represent the provided Java instance to a Node- Parameters:
data- - Java instance to be represented- Returns:
- The Node to be serialized
-
findRepresenterFor
protected Optional<RepresentToNode> findRepresenterFor(Object data)
Find the representer which is suitable to represent the internal structure of the provided instance to a Node- Parameters:
data- - the data to be serialized- Returns:
- RepresentToNode to call to create a Node
-
representData
protected final org.snakeyaml.engine.v2.nodes.Node representData(Object data)
Find the representer and use it to create the Node from instance- Parameters:
data- - the source- Returns:
- Node for the provided source
-
representScalar
protected org.snakeyaml.engine.v2.nodes.Node representScalar(org.snakeyaml.engine.v2.nodes.Tag tag, String value, ScalarStyle style)Create Scalar Node from string- Parameters:
tag- - the tag in Nodevalue- - the sourcestyle- - the style- Returns:
- Node for string
-
representScalar
protected org.snakeyaml.engine.v2.nodes.Node representScalar(org.snakeyaml.engine.v2.nodes.Tag tag, String value)Create Node for string using PLAIN scalar style if possible- Parameters:
tag- - the tag for Nodevalue- - the surce- Returns:
- Node for string
-
representSequence
protected org.snakeyaml.engine.v2.nodes.Node representSequence(org.snakeyaml.engine.v2.nodes.Tag tag, Iterable<?> sequence, FlowStyle flowStyle)Create Node- Parameters:
tag- - tag to use in Nodesequence- - the sourceflowStyle- - the flow style- Returns:
- the Node from the source iterable
-
representMappingEntry
protected org.snakeyaml.engine.v2.nodes.NodeTuple representMappingEntry(Map.Entry<?,?> entry)
Create a tuple for one key pair- Parameters:
entry- - Map entry- Returns:
- the tuple where both key and value are converted to Node
-
representMapping
protected org.snakeyaml.engine.v2.nodes.Node representMapping(org.snakeyaml.engine.v2.nodes.Tag tag, Map<?,?> mapping, FlowStyle flowStyle)Create Node for the provided Map- Parameters:
tag- - the tag for Nodemapping- - the sourceflowStyle- - the style of Node- Returns:
- Node for the source Map
-
-