Top Description Fields Constructors Methods
org.snakeyaml.engine.v2.representer

public abstract Class BaseRepresenter

extends Object
Class Inheritance
Known Direct Subclasses
org.snakeyaml.engine.v2.representer.StandardRepresenter
Imports
java.util.ArrayList, .HashMap, .IdentityHashMap, .LinkedHashMap, .List, .Map, .Optional, org.snakeyaml.engine.v2.api.RepresentToNode, org.snakeyaml.engine.v2.common.FlowStyle, .ScalarStyle, org.snakeyaml.engine.v2.exceptions.YamlEngineException, org.snakeyaml.engine.v2.nodes.AnchorNode, .MappingNode, .Node, .NodeTuple, .ScalarNode, .SequenceNode, .Tag

Represent basic YAML structures: scalar, sequence, mapping

Field Summary

Modifier and TypeField and Description
protected FlowStyle
defaultFlowStyle

flow style for collections

protected ScalarStyle
defaultScalarStyle

scalar style

protected RepresentToNode
nullRepresenter

in Java 'null' is not a type.

protected Object
objectToRepresent

the current object to be converted to Node

protected final Map<Class<?>, RepresentToNode>
parentClassRepresenters

Keep representers which match a parent of the class to be represented

protected final Map<Object, Node>
representedObjects

Keep references of already represented instances.

protected final Map<Class<?>, RepresentToNode>
representers

Keep representers which must match the class exactly

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected Optional<RepresentToNode>

Returns:

RepresentToNode to call to create a Node
findRepresenterFor
(Object
- the data to be serialized
data
)

Find the representer which is suitable to represent the internal structure of the provided instance to a Node

public Node

Returns:

The Node to be serialized
represent
(Object
- Java instance to be represented
data
)

Represent the provided Java instance to a Node

protected final Node

Returns:

Node for the provided source
representData
(Object
- the source
data
)

Find the representer and use it to create the Node from instance

protected Node

Returns:

Node for the source Map
representMapping
(Tag
- the tag for Node
tag
,
Map<?, ?>
- the source
mapping
,
FlowStyle
- the style of Node
flowStyle
)

Create Node for the provided Map

protected NodeTuple

Returns:

the tuple where both key and value are converted to Node
representMappingEntry
(Map.Entry<?, ?>
- Map entry
entry
)

Create a tuple for one key pair

protected Node

Returns:

Node to emit
representScalar
(Tag
- the tag to emit
tag
,
String
- the value to emit
value
,
ScalarStyle
- scalar style when preferred
style
)

Create scalar node for the provided string object.

protected Node

Returns:

Node for string
representScalar
(Tag
- the tag for Node
tag
,
String
- the surce
value
)

Create Node for string using PLAIN scalar style if possible

protected Node

Returns:

the Node from the source iterable
representSequence
(Tag
- tag to use in Node
tag
,
Iterable<?>
- the source
sequence
,
FlowStyle
- the flow style
flowStyle
)

Create Node

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultFlowStyleback to summary
protected FlowStyle defaultFlowStyle

flow style for collections

defaultScalarStyleback to summary
protected ScalarStyle defaultScalarStyle

scalar style

nullRepresenterback to summary
protected RepresentToNode nullRepresenter

in Java 'null' is not a type. So we have to keep the null representer separately

objectToRepresentback to summary
protected Object objectToRepresent

the current object to be converted to Node

parentClassRepresentersback to summary
protected final Map<Class<?>, RepresentToNode> parentClassRepresenters

Keep representers which match a parent of the class to be represented

representedObjectsback to summary
protected final Map<Object, Node> representedObjects

Keep references of already represented instances. The order is important (map can be also a sequence of key-values)

representersback to summary
protected final Map<Class<?>, RepresentToNode> representers

Keep representers which must match the class exactly

Constructor Detail

BaseRepresenterback to summary
public BaseRepresenter()

Method Detail

findRepresenterForback to summary
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:Object

- the data to be serialized

Returns:Optional<RepresentToNode>

RepresentToNode to call to create a Node

representback to summary
public Node represent(Object data)

Represent the provided Java instance to a Node

Parameters
data:Object

- Java instance to be represented

Returns:Node

The Node to be serialized

representDataback to summary
protected final Node representData(Object data)

Find the representer and use it to create the Node from instance

Parameters
data:Object

- the source

Returns:Node

Node for the provided source

representMappingback to summary
protected Node representMapping(Tag tag, Map<?, ?> mapping, FlowStyle flowStyle)

Create Node for the provided Map

Parameters
tag:Tag

- the tag for Node

mapping:Map<?, ?>

- the source

flowStyle:FlowStyle

- the style of Node

Returns:Node

Node for the source Map

representMappingEntryback to summary
protected NodeTuple representMappingEntry(Map.Entry<?, ?> entry)

Create a tuple for one key pair

Parameters
entry:Map.Entry<?, ?>

- Map entry

Returns:NodeTuple

the tuple where both key and value are converted to Node

representScalarback to summary
protected Node representScalar(Tag tag, String value, ScalarStyle style)

Create scalar node for the provided string object.

Parameters
tag:Tag

- the tag to emit

value:String

- the value to emit

style:ScalarStyle

- scalar style when preferred

Returns:Node

Node to emit

representScalarback to summary
protected Node representScalar(Tag tag, String value)

Create Node for string using PLAIN scalar style if possible

Parameters
tag:Tag

- the tag for Node

value:String

- the surce

Returns:Node

Node for string

representSequenceback to summary
protected Node representSequence(Tag tag, Iterable<?> sequence, FlowStyle flowStyle)

Create Node

Parameters
tag:Tag

- tag to use in Node

sequence:Iterable<?>

- the source

flowStyle:FlowStyle

- the flow style

Returns:Node

the Node from the source iterable