示例#1
0
 private Object extractWithPath(
     ObjectToJsonConverter pConverter,
     List pList,
     Stack<String> pStack,
     boolean jsonify,
     String pPathPart)
     throws AttributeNotFoundException {
   try {
     int idx = Integer.parseInt(pPathPart);
     return pConverter.extractObject(pList.get(idx), pStack, jsonify);
   } catch (NumberFormatException exp) {
     ValueFaultHandler faultHandler = pConverter.getValueFaultHandler();
     return faultHandler.handleException(
         new AttributeNotFoundException(
             "Index '" + pPathPart + "' is not numeric for accessing list"));
   } catch (IndexOutOfBoundsException exp) {
     ValueFaultHandler faultHandler = pConverter.getValueFaultHandler();
     return faultHandler.handleException(
         new AttributeNotFoundException(
             "Index '" + pPathPart + "' is out-of-bound for a list of size " + pList.size()));
   }
 }
示例#2
0
 /**
  * Handle an exception happened during value extraction
  *
  * @param pFault the fault raised
  * @return a replacement value if this should be used instead or the exception is rethrown if the
  *     handler doesn't handle it
  */
 public <T extends Throwable> Object handleValueFault(T pFault) throws T {
   return valueFaultHandler.handleException(pFault);
 }