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 Summary
Modifier and TypeMethodDescriptionbooleanWhether this extractor is able to set a value.extractObject(ObjectToJsonConverter pConverter, Object pValue, Deque<String> pExtraArgs, boolean jsonify) Extract an object from pValue.Class<?>getType()Type for which this extractor can objects of this typesetObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) If this extractor is able to set a value (seecanSetValue()), this method sets the value even on an inner object
-
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 typespValue- the value to convertpExtraArgs- extra arguments which contain e.g. a pathjsonify- 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
Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException, IllegalArgumentException If this extractor is able to set a value (seecanSetValue()), 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 typespInner- object on which to set the valuepAttribute- attribute of the object to setpValue- the new value to set- Returns:
- the old value
- Throws:
IllegalAccessException- if the attribute to set to is not accessibleInvocationTargetException- reflection errorIllegalArgumentException- 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.
-