Class MapAccessor
java.lang.Object
org.jolokia.service.serializer.json.MapAccessor
- All Implemented Interfaces:
ObjectAccessor
ObjectAccessor for maps.- Since:
- Apr 19, 2009
- Author:
- roland
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this accessor can be used to set a value inside (directly or nested) a value ofgiven class.extractObject(ObjectToJsonConverter pConverter, Object pMap, Deque<String> pPathParts, boolean pJsonify) Convert a Map toJSONObject(ifpJsonifyistrue).Class<?>getType()Gets a class of supported objects.Set the value within a map, where the attribute is taken as key into the map.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jolokia.service.serializer.json.ObjectAccessor
extractString, supportsStringConversion
-
Constructor Details
-
MapAccessor
public MapAccessor()
-
-
Method Details
-
getType
Description copied from interface:ObjectAccessorGets a class of supported objects.- Specified by:
getTypein interfaceObjectAccessor- Returns:
- supported type of the objects handled by this accessor
-
extractObject
public Object extractObject(ObjectToJsonConverter pConverter, Object pMap, Deque<String> pPathParts, boolean pJsonify) throws AttributeNotFoundException Convert a Map toJSONObject(ifpJsonifyistrue). If a path is used, the first element of the path is interpreted as a key into the map and the extracted object is converted value under that key. If the first element isnull, new map is returned, possibly with values extracted from existing values using the remainder of the path stack.- Specified by:
extractObjectin interfaceObjectAccessor- Parameters:
pConverter- the global converter to convert inner values and get serialization optionspMap- the value to convert (must be aMap)pPathParts- if not empty, top value may be an index into the list and remaining parts are passed recursivelypJsonify- whether to convert the map into aJSONObjector its element to a relevant JSON representation- Returns:
- the extracted object or entire map when the
pPathPartsstack is empty - Throws:
AttributeNotFoundException
-
canSetValue
public boolean canSetValue()Description copied from interface:ObjectAccessorWhether this accessor can be used to set a value inside (directly or nested) a value ofgiven class.- Specified by:
canSetValuein interfaceObjectAccessor- Returns:
trueif this extractor can be used to set inner values.
-
setObjectValue
public Object setObjectValue(Converter<String> 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 interfaceObjectAccessor- Parameters:
pConverter- the global converter to convert the value being set into a class of the map valuepMap- aMapto set the value intopKey- key in the map where to put the value, which is tricky, as the map keys may not be stringspValue- the new value to set, subject to conversion- Returns:
- the old value or
nullif a new map entry was created - Throws:
IllegalAccessExceptionInvocationTargetException
-