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
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceHelper interface for extracting and simplifying values -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSimplifierExtractor(Class<T> pType) Super constructor taking the value type as argument -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidaddExtractor(String pName, SimplifierExtractor.AttributeExtractor<T> pExtractor) Add a single extractorprotected final voidaddExtractors(Object[][] pAttrExtractors) Add given extractors to the map.booleanNo setting for simplifying extractorsextractObject(ObjectToJsonConverter pConverter, Object pValue, Deque<String> pPathParts, 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) Throws alwaysIllegalArgumentExceptionsince a simplifier cannot be written to
-
Constructor Details
-
SimplifierExtractor
Super constructor taking the value type as argument- Parameters:
pType- type for which this extractor is responsible
-
-
Method Details
-
getType
Type for which this extractor can objects of this type -
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:
extractObjectin interfaceExtractor- Parameters:
pConverter- the global converter in order to be able do dispatch for serializing inner data typespValue- the value to convertpPathParts- 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.
-
canSetValue
public boolean canSetValue()No setting for simplifying extractors- Specified by:
canSetValuein interfaceExtractor- Returns:
- always
false
-
setObjectValue
public Object setObjectValue(StringToObjectConverter pConverter, Object pInner, String pAttribute, Object pValue) throws IllegalAccessException, InvocationTargetException Throws alwaysIllegalArgumentExceptionsince a simplifier cannot be written to- Specified by:
setObjectValuein interfaceExtractor- 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 error
-
addExtractors
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 extractorpExtractor- the extractor itself
-