Class CollectionExtractor
java.lang.Object
org.jolokia.service.serializer.json.CollectionExtractor
- All Implemented Interfaces:
Extractor
Extractor used for arbitrary collections. They are simply converted into JSON arrays, although
the order is arbitrary. Setting to a collection is not allowed.
This extractor must be called after all more specialized extractors (like the
MapExtractor or ArrayExtractor).- Since:
- 18.10.11
- Author:
- roland
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this extractor is able to set a value.extractObject(ObjectToJsonConverter pConverter, Object pValue, Deque<String> pPathParts, boolean jsonify) Converts a collection to an JSON array.Class<?>getType()Type for which this extractor can objects of this typesetObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) Setting of an object value is not supported for the collection converter
-
Constructor Details
-
CollectionExtractor
public CollectionExtractor()
-
-
Method Details
-
getType
Type for which this extractor can objects of this type -
extractObject
public Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Deque<String> pPathParts, boolean jsonify) throws AttributeNotFoundException Converts a collection to an JSON array. No path access is supported here- Specified by:
extractObjectin interfaceExtractor- Parameters:
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 path. The path is ignored here.jsonify- whether to convert to a JSON object/list or whether the plain object should be returned. The later is required for writing an inner value- Returns:
- the extracted object
- Throws:
AttributeNotFoundException- if the inner path does not exist.
-
setObjectValue
public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException Setting of an object value is not supported for the collection converter- Specified by:
setObjectValuein interfaceExtractor- Parameters:
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 set- Returns:
- the old value
- Throws:
IllegalAccessException- if the attribute to set to is not accessibleInvocationTargetException- reflection error
-
canSetValue
public boolean canSetValue()Whether this extractor is able to set a value.- Specified by:
canSetValuein interfaceExtractor- Returns:
- true if this extractor can set a value, false otherwise.
-