Constructor and Description |
---|
TabularDataExtractor() |
Modifier and Type | Method and Description |
---|---|
boolean |
canSetValue()
Whether this extractor is able to set a value.
|
Object |
extractObject(ObjectToJsonConverter pConverter,
Object pValue,
Stack<String> pPathParts,
boolean pJsonify)
Extract a
TabularData . |
Class |
getType()
Type for which this extractor can objects of this type
|
Object |
setObjectValue(StringToObjectConverter pConverter,
Object pInner,
String pAttribute,
Object pValue)
Throws always
IllegalArgumentException since tabular data is immutable |
public Class getType()
public Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Stack<String> pPathParts, boolean pJsonify) throws AttributeNotFoundException
Extract a TabularData
. The JSON representation of a tabular data is different,
depending on whether it represents a map for an MXBean
or is a regular data.
I.e. for an tabular data which have a row type with two column "key" and "value", then a map is returned (with the "key" values as map keys and "value" values as map values).
Otherwise a map of (one or more) maps is returned, where the map keys are taken
from TabularType
of the presented data. E.g. if there is a single valued key
"key"
, then the returned JSON looks like
{ "mykey1" : { "key" : "mkey1", "item" : "value1", .... } "mykey2" : { "key" : "mkey2", "item" : "value2", .... } .... }For multi valued keys of simple open types (i.e.
TabularType.getIndexNames()
is a list with more than one element), the
returned JSON structure looks like (index names here are "key" and "innerkey")
{ "mykey1" : { "myinner1" : { "key" : "mkey1", "innerkey" : "myinner1", "item" : "value1", .... } "myinner2" : { "key" : "mkey1", "innerkey" : "myinner2", "item" : "value1", .... } .... } "mykey2" : { "second1" : { "key" : "mkey2", "innerkey" : "second1", "item" : "value1", .... } "second2" : { "key" : "mkey2", "innerkey" : "second2", "item" : "value1", .... } .... } .... }If keys are used, which themselves are complex objects (like composite data), this hierarchical map structure can not be used. In this case an object with two keys is returned: "indexNames" holds the name of the key index and "values" is an array of all rows which are represented as JSON objects:
{ "indexNames" : [ "key", "innerkey" ], "values" : [ { "key" : "mykey1", "innerkey" : { "name" : "a", "number" : 4711 }, "item" : "value1", .... }, { "key" : "mykey2", "innerkey" : { "name" : "b", "number" : 815 }, "item" : "value2", .... }, ... ] }
Accessing TabularData
with a path is only supported for simple type keys, i.e. each index name must point
to a string representation of a simple open type. As many path elements must be provided as index names for
the tabular type exists (i.e. pExtraArgs.size() >= pValue.getTabularType().getIndexNames().size()
)
For TabularData representing maps, a path access with the single "key" value will
return the content of the "value" value. For all other TabularData, the complete row to which the path points
is returned.
extractObject
in interface Extractor
pConverter
- the global converter in order to be able do dispatch for
serializing inner data typespValue
- the value to convertpPathParts
- extra arguments which contain e.g. a pathpJsonify
- whether to convert to a JSON object/list or whether the plain object
should be returned. The later is required for writing an inner valueAttributeNotFoundException
public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException
IllegalArgumentException
since tabular data is immutablesetObjectValue
in interface Extractor
pConverter
- the global converter in order to be able do dispatch for
serializing inner data typespInner
- object on which to set the valuepAttribute
- attribute of the object to setpValue
- the new value to setIllegalAccessException
- if the attribute to set to is not accessibleInvocationTargetException
- reflection errorpublic boolean canSetValue()
canSetValue
in interface Extractor
Copyright © 2017. All rights reserved.