Package org.yaml.snakeyaml.representer
Class Representer
- java.lang.Object
-
- org.yaml.snakeyaml.representer.BaseRepresenter
-
- org.yaml.snakeyaml.representer.Representer
-
public class Representer extends BaseRepresenter
Represent JavaBeans
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classRepresenter.RepresentJavaBean
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.Class<? extends java.lang.Object>,Tag>classTagsstatic java.util.regex.PatternMULTILINE_PATTERNprotected DumperOptions.NonPrintableStylenonPrintableStyleprotected java.util.TimeZonetimeZoneprotected java.util.Map<java.lang.Class<? extends java.lang.Object>,TypeDescription>typeDefinitions-
Fields inherited from class org.yaml.snakeyaml.representer.BaseRepresenter
defaultFlowStyle, defaultScalarStyle, multiRepresenters, nullRepresenter, objectToRepresent, representedObjects, representers
-
-
Constructor Summary
Constructors Constructor Description Representer()Representer(DumperOptions options)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TagaddClassTag(java.lang.Class<? extends java.lang.Object> clazz, Tag tag)Define a tag for theClassto serialize.TypeDescriptionaddTypeDescription(TypeDescription td)protected voidcheckGlobalTag(Property property, Node node, java.lang.Object object)Remove redundant global tag for a type safe (generic) collection if it is the same as defined by the JavaBean propertyprotected java.util.Set<Property>getProperties(java.lang.Class<? extends java.lang.Object> type)Get JavaBean properties to be serialised.protected TaggetTag(java.lang.Class<?> clazz, Tag defaultTag)java.util.TimeZonegetTimeZone()protected MappingNoderepresentJavaBean(java.util.Set<Property> properties, java.lang.Object javaBean)Tag logic: - explicit root tag is set in serializer - if there is a predefined class tag it is used - a global tag with class name is always used as tag.protected NodeTuplerepresentJavaBeanProperty(java.lang.Object javaBean, Property property, java.lang.Object propertyValue, Tag customTag)Represent one JavaBean property.voidsetPropertyUtils(PropertyUtils propertyUtils)voidsetTimeZone(java.util.TimeZone timeZone)-
Methods inherited from class org.yaml.snakeyaml.representer.BaseRepresenter
getDefaultFlowStyle, getDefaultScalarStyle, getPropertyUtils, isExplicitPropertyUtils, represent, representData, representMapping, representScalar, representScalar, representSequence, setDefaultFlowStyle, setDefaultScalarStyle
-
-
-
-
Field Detail
-
typeDefinitions
protected java.util.Map<java.lang.Class<? extends java.lang.Object>,TypeDescription> typeDefinitions
-
classTags
protected java.util.Map<java.lang.Class<? extends java.lang.Object>,Tag> classTags
-
timeZone
protected java.util.TimeZone timeZone
-
nonPrintableStyle
protected DumperOptions.NonPrintableStyle nonPrintableStyle
-
MULTILINE_PATTERN
public static java.util.regex.Pattern MULTILINE_PATTERN
-
-
Constructor Detail
-
Representer
public Representer()
-
Representer
public Representer(DumperOptions options)
-
-
Method Detail
-
addTypeDescription
public TypeDescription addTypeDescription(TypeDescription td)
-
setPropertyUtils
public void setPropertyUtils(PropertyUtils propertyUtils)
- Overrides:
setPropertyUtilsin classBaseRepresenter
-
representJavaBean
protected MappingNode representJavaBean(java.util.Set<Property> properties, java.lang.Object javaBean)
Tag logic: - explicit root tag is set in serializer - if there is a predefined class tag it is used - a global tag with class name is always used as tag. The JavaBean parent of the specified JavaBean may set another tag (tag:yaml.org,2002:map) when the property class is the same as runtime class- Parameters:
properties- JavaBean gettersjavaBean- instance for Node- Returns:
- Node to get serialized
-
representJavaBeanProperty
protected NodeTuple representJavaBeanProperty(java.lang.Object javaBean, Property property, java.lang.Object propertyValue, Tag customTag)
Represent one JavaBean property.- Parameters:
javaBean- - the instance to be representedproperty- - the property of the instancepropertyValue- - value to be representedcustomTag- - user defined Tag- Returns:
- NodeTuple to be used in a MappingNode. Return null to skip the property
-
checkGlobalTag
protected void checkGlobalTag(Property property, Node node, java.lang.Object object)
Remove redundant global tag for a type safe (generic) collection if it is the same as defined by the JavaBean property- Parameters:
property- - JavaBean propertynode- - representation of the propertyobject- - instance represented by the node
-
getProperties
protected java.util.Set<Property> getProperties(java.lang.Class<? extends java.lang.Object> type)
Get JavaBean properties to be serialised. The order is respected. This method may be overridden to provide custom property selection or order.- Parameters:
type- - JavaBean to inspect the properties- Returns:
- properties to serialise
-
addClassTag
public Tag addClassTag(java.lang.Class<? extends java.lang.Object> clazz, Tag tag)
Define a tag for theClassto serialize.- Parameters:
clazz-Classwhich tag is changedtag- new tag to be used for every instance of the specifiedClass- Returns:
- the previous tag associated with the
Class
-
getTimeZone
public java.util.TimeZone getTimeZone()
-
setTimeZone
public void setTimeZone(java.util.TimeZone timeZone)
-
-