Class MapExtractor
java.lang.Object
org.jolokia.service.serializer.json.MapExtractor
- All Implemented Interfaces:
Extractor
Extractor for Maps (which turns
Map into JSONObject)- Since:
- Apr 19, 2009
- 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) Convert a Map to JSON (ifjsonifyistrue).Class<?>getType()Type for which this extractor can objects of this typesetObjectValue(StringToObjectConverter pConverter, Object pMap, String pKey, Object pValue) Set the value within a map, where the attribute is taken as key into the map.
-
Constructor Details
-
MapExtractor
public MapExtractor()
-
-
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 Convert a Map to JSON (ifjsonifyistrue). If a path is used, the path is interpreted as a key into the map. The key in the path is a string and is compared agains all keys in the map against their string representation.- Specified by:
extractObjectin interfaceExtractor- Parameters:
pConverter- the global converter in order to be able do dispatch for serializing inner data typespValue- the value to convert which must be aMappPathParts- extra argument stack which on top must be a key into the mapjsonify- 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
-
setObjectValue
public Object setObjectValue(StringToObjectConverter pConverter, Object pMap, String pKey, Object pValue) throws IllegalAccessException, InvocationTargetException Set the value within a map, where the attribute is taken as key into the map.- Specified by:
setObjectValuein interfaceExtractor- Parameters:
pConverter- the global converter in order to be able do dispatch for serializing inner data typespMap- map on which to set the valuepKey- key in the map where to put the valuepValue- the new value to set- Returns:
- the old value or
nullif a new map entry was created/ - Throws:
IllegalAccessExceptionInvocationTargetException
-
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.
-