Class CollectionExtractor

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

public class CollectionExtractor extends Object implements Extractor
Extractor used for arbitrary collections. They are simply converted into JSON arrays, although the order is arbitrary. Setting to a collection is not allowed. This extractor must be called after all more specialized extractors (like the MapExtractor or ArrayExtractor).
Since:
18.10.11
Author:
roland
  • Constructor Details

    • CollectionExtractor

      public CollectionExtractor()
  • 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
      Converts a collection to an JSON array. No path access is supported here
      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
      pPathParts - extra arguments which contain e.g. a path. The path is ignored here.
      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 - if the inner path does not exist.
    • setObjectValue

      public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException
      Setting of an object value is not supported for the collection converter
      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
      pAttribute - attribute of the object to set
      pValue - the new value to set
      Returns:
      the old value
      Throws:
      IllegalAccessException - if the attribute to set to is not accessible
      InvocationTargetException - reflection error
    • 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.