Class SimpleAccessor

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

public class SimpleAccessor extends Object implements ObjectAccessor
  • Constructor Details

    • SimpleAccessor

      public SimpleAccessor()
  • 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 pValue, Deque<String> pPathParts, boolean pJsonify) throws AttributeNotFoundException
      Description copied from interface: ObjectAccessor

      Extract an object from given pValue of the supported type.

      In the simplest case without jsonification and without a property path, we extract the value itself.

      pPathParts may be used as a Deque (a stack) of keys into the object being accessed, where the first item (Deque.pop()) is the 1st level inner object and the remainder of the stack is passed recursively when accessing composite objects. First key may be null, which means that the remaining path parts are applied to each item of the object (like elements of the array).

      pJsonify flag indicates that the returned value should be converted into a JSON representation.

      Specified by:
      extractObject in interface ObjectAccessor
      Parameters:
      pConverter - the top-level converter that knows about other accessors used for drilling into inner objects.
      pValue - the objects being accessed
      pPathParts - a path into inner object(s) to access internal structure of the object. Each accessor should Deque.pop() its attribute and pass the remaining stack recursively.
      pJsonify - whether to convert the extracted object into a JSON representation
      Returns:
      the extracted object in JSON or original format
      Throws:
      AttributeNotFoundException - if the inner path does not exist.
    • 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 pObject, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException, IllegalArgumentException
      Description copied from interface: ObjectAccessor
      If this accessor can be used to set inner values, this method sets the value inside the passed outer object.
      Specified by:
      setObjectValue in interface ObjectAccessor
      Parameters:
      pConverter - Converter used to convert the value being set to a class of the accessed attribute
      pObject - object on which to set the value
      pAttribute - attribute of the object to set. (For arrays or lists it should be an index.)
      pValue - the new value to set after conversion
      Returns:
      the old value of the changed attribute
      Throws:
      IllegalAccessException - if the attribute to set to is not accessible
      InvocationTargetException - reflection error
      IllegalArgumentException - if the attribute can't be converted to desired kind (like array index number)