Class ArrayAccessor

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

public class ArrayAccessor extends Object implements ObjectAccessor
ObjectAccessor for arrays of any type (primitive or object arrays).
Since:
Apr 19, 2009
Author:
roland
  • Constructor Details

    • ArrayAccessor

      public ArrayAccessor()
  • 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 pArray, Deque<String> pPathParts, boolean pJsonify) throws AttributeNotFoundException
      Extract an array or indexed element of an array. When pJsonify, return a JSONArray for entire array or JSON representation of the value under some index.
      Specified by:
      extractObject in interface ObjectAccessor
      Parameters:
      pConverter - the global converter to convert inner values and get serialization options
      pArray - the value to convert (must be an array)
      pPathParts - if not empty, top value may be an index into the array and remaining parts are passed recursively
      pJsonify - whether to convert the array into JSONArray or its element to a relevant JSON representation
      Returns:
      the extracted object or entire array when the pPathParts stack is empty
      Throws:
      AttributeNotFoundException - if the index is not specified as non-negative integer
      IndexOutOfBoundsException - if the index is not within the array
    • 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 pArray, String pIndex, Object pValue) throws IllegalAccessException, InvocationTargetException
      Set a value in an array under given index
      Specified by:
      setObjectValue in interface ObjectAccessor
      Parameters:
      pConverter - the global converter to convert the value being set into Class.getComponentType()
      pArray - an array to set the value into
      pIndex - index (as string) where to set the value within the array
      pValue - the new value to set, subject to conversion
      Returns:
      the old value at this index
      Throws:
      IllegalAccessException
      InvocationTargetException