Class ArrayAccessor
java.lang.Object
org.jolokia.service.serializer.json.ArrayAccessor
- All Implemented Interfaces:
ObjectAccessor
ObjectAccessor for arrays of any type (primitive or object arrays).- Since:
- Apr 19, 2009
- Author:
- roland
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether this accessor can be used to set a value inside (directly or nested) a value ofgiven class.extractObject(ObjectToJsonConverter pConverter, Object pArray, Deque<String> pPathParts, boolean pJsonify) Extract an array or indexed element of an array.Class<?>getType()Gets a class of supported objects.Set a value in an array under given indexMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jolokia.service.serializer.json.ObjectAccessor
extractString, supportsStringConversion
-
Constructor Details
-
ArrayAccessor
public ArrayAccessor()
-
-
Method Details
-
getType
Description copied from interface:ObjectAccessorGets a class of supported objects.- Specified by:
getTypein interfaceObjectAccessor- Returns:
- supported type of the objects handled by this accessor
-
extractObject
public Object extractObject(ObjectToJsonConverter pConverter, Object pArray, Deque<String> pPathParts, boolean pJsonify) throws AttributeNotFoundException Extract an array or indexed element of an array. WhenpJsonify, return aJSONArrayfor entire array or JSON representation of the value under some index.- Specified by:
extractObjectin interfaceObjectAccessor- Parameters:
pConverter- the global converter to convert inner values and get serialization optionspArray- the value to convert (must be an array)pPathParts- if not empty, top value may be an index into the array and remaining parts are passed recursivelypJsonify- whether to convert the array intoJSONArrayor its element to a relevant JSON representation- Returns:
- the extracted object or entire array when the
pPathPartsstack is empty - Throws:
AttributeNotFoundException- if the index is not specified as non-negative integerIndexOutOfBoundsException- if the index is not within the array
-
canSetValue
public boolean canSetValue()Description copied from interface:ObjectAccessorWhether this accessor can be used to set a value inside (directly or nested) a value ofgiven class.- Specified by:
canSetValuein interfaceObjectAccessor- Returns:
trueif this extractor can be used to set inner values.
-
setObjectValue
public Object setObjectValue(Converter<String> pConverter, Object pArray, String pIndex, Object pValue) throws IllegalAccessException, InvocationTargetException Set a value in an array under given index- Specified by:
setObjectValuein interfaceObjectAccessor- Parameters:
pConverter- the global converter to convert the value being set intoClass.getComponentType()pArray- an array to set the value intopIndex- index (as string) where to set the value within the arraypValue- the new value to set, subject to conversion- Returns:
- the old value at this index
- Throws:
IllegalAccessExceptionInvocationTargetException
-