示例#1
0
文件: DataType.java 项目: inexas/oak
 public OverflowException(Number n, Class<?> expectedClass) {
   super(
       "Overflow exception, "
           + n.toString()
           + " cannot be converted to: "
           + expectedClass.getSimpleName());
 }
示例#2
0
 /**
  * Get the enum value associated with an index.
  *
  * @param clazz The type of enum to retrieve.
  * @param index The index must be between 0 and length() - 1.
  * @return The enum value at the index location
  * @throws JSONException if the key is not found or if the value cannot be converted to an enum.
  */
 public <E extends Enum<E>> E getEnum(Class<E> clazz, int index) throws JSONException {
   E val = optEnum(clazz, index);
   if (val == null) {
     // JSONException should really take a throwable argument.
     // If it did, I would re-implement this with the Enum.valueOf
     // method and place any thrown exception in the JSONException
     throw new JSONException(
         "JSONObject["
             + JSONObject.quote(Integer.toString(index))
             + "] is not an enum of type "
             + JSONObject.quote(clazz.getSimpleName())
             + ".");
   }
   return val;
 }
示例#3
0
文件: DataType.java 项目: inexas/oak
 TypeMismatchException(Class<? extends Object> got, Class<?> expected) {
   super("Cannot convert " + got.getSimpleName() + " to  " + expected.getSimpleName());
 }