static void setElements(RawObject collection, Object[] elements) {
   RawObject value = null;
   while (value == null && collection != null) {
     Map<String, Object> values = collection.getValues();
     if (values != null) {
       value = (RawObject) values.get("elements");
       if (value != null) {
         values.put("elements", new RawObject(value.getType(), elements));
       } else {
         collection = collection.getSuper();
       }
     }
   }
   if (value == null) {
     throw new IllegalStateException();
   }
 }
 static Object[] getElements(RawObject collection) {
   Object value = null;
   while (value == null && collection != null) {
     Map<String, Object> values = collection.getValues();
     if (values != null) {
       value = values.get("elements");
       if (value == null) {
         collection = collection.getSuper();
       }
     }
   }
   if (value == null || !(value instanceof RawObject)) {
     throw new IllegalStateException(
         "Collection proxy for a secondary key field must " + "contain a field named 'elements'");
   }
   RawObject rawObj = (RawObject) value;
   Format format = (Format) rawObj.getType();
   if (!format.isArray() || format.getComponentType().getId() != Format.ID_OBJECT) {
     throw new IllegalStateException("Collection proxy 'elements' field must by an Object array");
   }
   return rawObj.getElements();
 }
예제 #3
0
 public int getKey(RawObject o) {
   Object val = o.getValues().get("key");
   return ((Integer) val).intValue();
 }