Class ArrayExtractor

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

public class ArrayExtractor extends Object implements Extractor
Extractor for extracting arrays of any kind.
Since:
Apr 19, 2009
Author:
roland
  • Constructor Details

    • ArrayExtractor

      public ArrayExtractor()
  • 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
      Extract an array and, if to be jsonified, put it into an JSONArray. An index can be used (on top of the extra args stack) in order to specify a single value within the array.
      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 (must be an aary)
      pPathParts - extra arguments stack, which is popped to get an index for extracting a single element of the array
      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
      IndexOutOfBoundsException - if an index is used which points outside the given list
    • setObjectValue

      public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pIndex, Object pValue) throws IllegalAccessException, InvocationTargetException
      Set a value in an array
      Specified by:
      setObjectValue in interface Extractor
      Parameters:
      pConverter - the global converter in order to be able do dispatch for serializing inner data types
      pInner - object on which to set the value (which must be a List)
      pIndex - index (as string) where to set the value within the array
      pValue - the new value to set
      Returns:
      the old value at this index
      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.