Class MapExtractor

java.lang.Object
org.jolokia.service.serializer.json.MapExtractor
All Implemented Interfaces:
Extractor

public class MapExtractor extends Object implements Extractor
Extractor for Maps (which turns Map into JSONObject)
Since:
Apr 19, 2009
Author:
roland
  • Constructor Details

    • MapExtractor

      public MapExtractor()
  • Method Details

    • getType

      public Class<?> getType()
      Type for which this extractor can objects of this type
      Specified by:
      getType in interface Extractor
      Returns:
      type which can be handled
    • extractObject

      public Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Deque<String> pPathParts, boolean jsonify) throws AttributeNotFoundException
      Convert a Map to JSON (if jsonify is true). 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:
      extractObject in interface Extractor
      Parameters:
      pConverter - the global converter in order to be able do dispatch for serializing inner data types
      pValue - the value to convert which must be a Map
      pPathParts - extra argument stack which on top must be a key into the map
      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
    • 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:
      setObjectValue in interface Extractor
      Parameters:
      pConverter - the global converter in order to be able do dispatch for serializing inner data types
      pMap - map on which to set the value
      pKey - key in the map where to put the value
      pValue - the new value to set
      Returns:
      the old value or null if a new map entry was created/
      Throws:
      IllegalAccessException
      InvocationTargetException
    • canSetValue

      public boolean canSetValue()
      Whether this extractor is able to set a value.
      Specified by:
      canSetValue in interface Extractor
      Returns:
      true if this extractor can set a value, false otherwise.