Class ListAccessor

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

public class ListAccessor extends Object implements ObjectAccessor
ObjectAccessor for lists. Unlike the accessor for collections this one can set list elements.
Since:
Apr 19, 2009
Author:
roland
  • Constructor Details

    • ListAccessor

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