Interface Extractor

All Known Implementing Classes:
ArrayExtractor, BeanExtractor, BigIntegerSimplifier, CalendarExtractor, ClassSimplifier, CollectionExtractor, CompositeDataExtractor, DateExtractor, DomElementSimplifier, EnumExtractor, FileSimplifier, ListExtractor, MapExtractor, ObjectNameSimplifier, SimplifierExtractor, TabularDataExtractor, TemporalExtractor, UrlSimplifier

public interface Extractor
Interface for extractor serializing an object to a JSON representation. Each extractor is responsible for a single type.
Since:
Jul 2, 2010
Author:
roland
  • Method Details

    • getType

      Class<?> getType()
      Type for which this extractor can objects of this type
      Returns:
      type which can be handled
    • extractObject

      Object extractObject(ObjectToJsonConverter pConverter, Object pValue, Deque<String> pExtraArgs, 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
      Parameters:
      pConverter - the global converter in order to be able do dispatch for serializing inner data types
      pValue - the value to convert
      pExtraArgs - 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.
    • setObjectValue

      If this extractor is able to set a value (see canSetValue()), this method sets the value even on an inner object
      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
      IllegalArgumentException - if the attribute can't be converted to desired value
    • canSetValue

      boolean canSetValue()
      Whether this extractor is able to set a value.
      Returns:
      true if this extractor can set a value, false otherwise.