Class ListAccessor
java.lang.Object
org.jolokia.service.serializer.json.ListAccessor
- All Implemented Interfaces:
ObjectAccessor
- 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 pList, Deque<String> pPathParts, boolean pJsonify) Extract a list or indexed element of a list.Class<?>getType()Gets a class of supported objects.Set a value in a list 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
-
ListAccessor
public ListAccessor()
-
-
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 pList, Deque<String> pPathParts, boolean pJsonify) throws AttributeNotFoundException Extract a list or indexed element of a list. WhenpJsonify, return aJSONArrayfor entire list 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 optionspList- the value to convert (must be aList)pPathParts- if not empty, top value may be an index into the list and remaining parts are passed recursivelypJsonify- whether to convert the list into aJSONArrayor its element to a relevant JSON representation- Returns:
- the extracted object or entire list when the
pPathPartsstack is empty - Throws:
AttributeNotFoundException- if the index is not specified as non-negative integerIndexOutOfBoundsException- if an index is used which points outside the given list
-
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 pList, String pIndex, Object pValue) throws IllegalAccessException, InvocationTargetException Set a value in a list under given index- Specified by:
setObjectValuein interfaceObjectAccessor- Parameters:
pConverter- the global converter to convert the value being set into a class of the list elementpList- aListto set the value intopIndex- index (as string) where to set the value within the listpValue- the new value to set, subject to conversion- Returns:
- the old value at this index
- Throws:
IllegalAccessExceptionInvocationTargetException
-