Class SimplifierExtractor<T>

java.lang.Object
org.jolokia.service.serializer.json.simplifier.SimplifierExtractor<T>
All Implemented Interfaces:
Extractor
Direct Known Subclasses:
BigIntegerSimplifier, ClassSimplifier, DomElementSimplifier, FileSimplifier, ObjectNameSimplifier, UrlSimplifier

public abstract class SimplifierExtractor<T> extends Object implements Extractor
Base class for all simplifiers. A simplifier is a special Extractor which condense full blown Java beans (like File) to a more compact representation. Simplifier extractors cannot be written to and are only used for downstream serialization. Simplifier are registered by listing the classes in a META-INF/simplifiers plain text file and then picked up by the converter. The default simplifiers coming prepackaged are taken from META-INF/simplifiers-default
Since:
Jul 27, 2009
Author:
roland
  • Constructor Details

    • SimplifierExtractor

      protected SimplifierExtractor(Class<T> pType)
      Super constructor taking the value type as argument
      Parameters:
      pType - type for which this extractor is responsible
  • 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 object from pValue. In the simplest case, this is the value itself. For more complex data types, it is converted into a JSON structure if possible (and if 'jsonify' is true). pExtraArgs is not null, this returns only a substructure, specified by the path represented by this stack
      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
      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.
    • canSetValue

      public boolean canSetValue()
      No setting for simplifying extractors
      Specified by:
      canSetValue in interface Extractor
      Returns:
      always false
    • setObjectValue

      public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException
      Throws always IllegalArgumentException since a simplifier cannot be written to
      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
    • addExtractors

      protected final void addExtractors(Object[][] pAttrExtractors)
      Add given extractors to the map. Should be called by a subclass from within init()
      Parameters:
      pAttrExtractors - extractors
    • addExtractor

      protected final void addExtractor(String pName, SimplifierExtractor.AttributeExtractor<T> pExtractor)
      Add a single extractor
      Parameters:
      pName - name of the extractor
      pExtractor - the extractor itself