Class MapAccessor

java.lang.Object
org.jolokia.service.serializer.json.MapAccessor
All Implemented Interfaces:
ObjectAccessor

public class MapAccessor extends Object implements ObjectAccessor
Since:
Apr 19, 2009
Author:
roland
  • Constructor Details

    • MapAccessor

      public MapAccessor()
  • Method Details

    • getType

      public Class<?> getType()
      Description copied from interface: ObjectAccessor
      Gets a class of supported objects.
      Specified by:
      getType in interface ObjectAccessor
      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 to JSONObject (if pJsonify is true). 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 is null, new map is returned, possibly with values extracted from existing values using the remainder of the path stack.
      Specified by:
      extractObject in interface ObjectAccessor
      Parameters:
      pConverter - the global converter to convert inner values and get serialization options
      pMap - the value to convert (must be a Map)
      pPathParts - if not empty, top value may be an index into the list and remaining parts are passed recursively
      pJsonify - whether to convert the map into a JSONObject or its element to a relevant JSON representation
      Returns:
      the extracted object or entire map when the pPathParts stack is empty
      Throws:
      AttributeNotFoundException
    • canSetValue

      public boolean canSetValue()
      Description copied from interface: ObjectAccessor
      Whether this accessor can be used to set a value inside (directly or nested) a value of given class.
      Specified by:
      canSetValue in interface ObjectAccessor
      Returns:
      true if 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:
      setObjectValue in interface ObjectAccessor
      Parameters:
      pConverter - the global converter to convert the value being set into a class of the map value
      pMap - a Map to set the value into
      pKey - key in the map where to put the value, which is tricky, as the map keys may not be strings
      pValue - the new value to set, subject to conversion
      Returns:
      the old value or null if a new map entry was created
      Throws:
      IllegalAccessException
      InvocationTargetException