public abstract class PersistorToHierarchialString extends PersistorToString
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
JSON_ARRAY_BRACKET_LEFT
"[" the start bracket to wrap json array items
|
protected static java.lang.String |
JSON_ARRAY_BRACKET_RIGHT
"]" the end bracket to wrap the json array items
|
protected static java.lang.String |
JSON_ARRAY_COMMA_SEP
"," separator to separate the json array items
|
ignoredFieldsForUnpickle, stringFormat, stringFormatReader
Constructor and Description |
---|
PersistorToHierarchialString() |
PersistorToHierarchialString(java.io.Reader stringFormatReader) |
PersistorToHierarchialString(java.lang.String stringFormat) |
Modifier and Type | Method and Description |
---|---|
protected abstract java.lang.String |
getChildBegin(java.lang.String key,
java.lang.String value,
java.lang.String classname)
This is called inside
parse(Persistable, boolean) to write "key"
and "value" of a child. |
protected java.lang.String |
getChildEnd(boolean lastChild)
This is called inside
parse(Persistable, boolean) to write the
end of a child, here a newline "\n" is written. |
protected abstract java.lang.String |
getContainerBegin(java.lang.String className,
boolean needLeadingName)
This is called inside
parse(Persistable, boolean) to write the begin
of a container such as:
<tagNam> for XML format
"tagName" : {\n for JSON format
|
protected abstract java.lang.String |
getContainerEnd(java.lang.String className)
This is called inside
parse(Persistable, boolean) to write the end
of a container such as:
</tagNam> for XML file
} for JSON file. |
protected java.lang.String |
getTagName(java.lang.String className) |
protected java.lang.String |
parse(Persistable persistable,
boolean needLeadingNameForContainer)
Convert a Persistable Object to a hierarchical string.
|
protected java.lang.String |
parseArrayField(java.lang.Object arrayFieldObject) |
protected java.lang.String |
parseFieldValue(java.lang.Object value)
Parse the parameter value and convert it to a string which will be persisted to (File or Variable or ...)
The following are the ways to parse value: The String value will be PersistorToString.escape(String) and double-quoted if needed. |
beforeUnpickle, doUnpickle, escape, getPersistenceName, getStringFormat, getStringFormatReader, getType, isIgnoredField, persist, setStringFormat, setStringFormatReader, stringNeedQuoted, unpersist, unpickle, write, writeHeader, writeTailer
validate
protected static final java.lang.String JSON_ARRAY_BRACKET_LEFT
protected static final java.lang.String JSON_ARRAY_BRACKET_RIGHT
protected static final java.lang.String JSON_ARRAY_COMMA_SEP
public PersistorToHierarchialString()
public PersistorToHierarchialString(java.lang.String stringFormat)
public PersistorToHierarchialString(java.io.Reader stringFormatReader)
protected final java.lang.String parse(Persistable persistable, boolean needLeadingNameForContainer) throws SAFSException
parse
in class PersistorToString
persistable
- needLeadingNameForContainer
- SAFSException
protected java.lang.String getTagName(java.lang.String className)
protected abstract java.lang.String getContainerBegin(java.lang.String className, boolean needLeadingName)
parse(Persistable, boolean)
to write the begin
of a container such as:
className
- String, the class name of a container. This is a full class-name, which may needs to
treated to get the simple class name as the tag-name.needLeadingName
- boolean, if the leading tag name is needed. For example sometimes we don't need the "tagName" for JSON format.java.io.IOException
protected abstract java.lang.String getChildBegin(java.lang.String key, java.lang.String value, java.lang.String classname)
parse(Persistable, boolean)
to write "key"
and "value" of a child.key
- String, the key namevalue
- String, the valueclassname
- String, the class name of this value. It is not useful with JSON format, but it is useful for XML format.java.io.IOException
protected java.lang.String getChildEnd(boolean lastChild)
parse(Persistable, boolean)
to write the
end of a child, here a newline "\n" is written.lastChild
- boolean, if this is the last child within the container.
it is useful for some file format, such as JSON, if this
is false (not the last child), a comma ,
needs to be added at the end as "key" : "value" ,java.io.IOException
protected abstract java.lang.String getContainerEnd(java.lang.String className)
parse(Persistable, boolean)
to write the end
of a container such as:
className
- String, the tag name, it is normally a container. This is a full class-name, which may needs to
treated to get the simple class name as the tag-name.java.io.IOException
protected java.lang.String parseFieldValue(java.lang.Object value)
PersistorToString.escape(String)
and double-quoted if needed.
value
- Object, the Persistable object field's valueSAFSException
protected java.lang.String parseArrayField(java.lang.Object arrayFieldObject)
arrayFieldObject
- Object, it is the object represent an array field of a classCopyright © SAS Institute. All Rights Reserved.