Example #1
0
 private void readDatatypeArray(int type, Document document, String key) {
   ValueList tempList = valueList.getNextList();
   if (tempList == null) {
     document.put(key, null);
     return;
   }
   int len = tempList.length();
   Object[] array = null;
   if (type == ElementType.TYPE_STRING_ARRAY) {
     array = new String[len];
     for (int i = 0; i < len; i++) {
       array[i] = tempList.getNextString();
     }
   } else if (type == ElementType.TYPE_INTEGER_ARRAY) {
     array = new Integer[len];
     for (int i = 0; i < len; i++) {
       array[i] = tempList.getNextInt();
     }
   } else if (type == ElementType.TYPE_LONG_ARRAY) {
     array = new Long[len];
     for (int i = 0; i < len; i++) {
       array[i] = tempList.getNextLong();
     }
   } else if (type == ElementType.TYPE_DOUBLE_ARRAY) {
     array = new Double[len];
     for (int i = 0; i < len; i++) {
       array[i] = tempList.getNextDouble();
     }
   }
   document.put(key, array);
 }
Example #2
0
 private void readDoubleWrapperArray(Document document, String key) {
   ValueList tempList = valueList.getNextList();
   if (tempList == null) {
     document.put(key, null);
     return;
   }
   int len = tempList.length();
   Double[] array = new Double[len];
   for (int i = 0; i < len; i++) {
     array[i] = tempList.getNextDouble();
   }
   document.put(key, array);
 }
Example #3
0
 private void read(Document document, ValueList valueList, DocumentType documentType) {
   Set<String> keySet = documentType.types.keySet();
   for (String key : keySet) {
     ElementType eType = documentType.types.get(key);
     int type = eType.type;
     if (type == ElementType.TYPE_STRING) {
       document.put(key, valueList.getNextString());
     } else if (type == ElementType.TYPE_INTEGER) {
       document.put(key, valueList.getNextInt());
     } else if (type == ElementType.TYPE_DOUBLE) {
       document.put(key, valueList.getNextDouble());
     } else if (type == ElementType.TYPE_LONG) {
       document.put(key, valueList.getNextLong());
     } else if (type == ElementType.TYPE_INTEGER_WRAPPER) {
       document.put(key, valueList.getNextInt());
     } else if (type == ElementType.TYPE_DOUBLE_WRAPPER) {
       document.put(key, valueList.getNextDouble());
     } else if (type == ElementType.TYPE_LONG_WRAPPER) {
       document.put(key, valueList.getNextLong());
     } else if (type == ElementType.TYPE_EMBEDDED) {
       ValueList tempList = valueList.getNextList();
       Document nestedDoc = new Document();
       read(nestedDoc, tempList, eType.nestedType);
       document.put(key, nestedDoc);
     } else if (type == ElementType.TYPE_EMBEDDED_ARRAY) {
       // } TODO else if (type == DocumentType.TYPE_REFERENCE_ARRAY) {
       ValueList tempList = valueList.getNextList();
       if (tempList == null) {
         document.put(key, null);
         continue;
       }
       int listLen = tempList.length();
       Document[] references = new Document[listLen];
       for (int j = 0; j < listLen; j++) {
         references[j] = new Document();
         ValueList tList = tempList.getNextList();
         read(references[j], tList, eType.nestedType);
       }
       document.put(key, references);
     } else if (type == ElementType.TYPE_REFERENCE) {
       String address = valueList.getNextString();
       if (address.equals("")) {
         document.put(key, null);
         continue;
       }
       Document reference = readReference(address, eType.reference, eType.nestedType);
       document.put(key, reference);
     } else if (type == ElementType.TYPE_STRING_ARRAY) {
       readStringArray(document, key);
     } else if (type == ElementType.TYPE_INTEGER_ARRAY) {
       readIntArray(document, key);
     } else if (type == ElementType.TYPE_INTEGER_WRAPPER_ARRAY) {
       readIntegerWrapperArray(document, key);
     } else if (type == ElementType.TYPE_LONG_ARRAY) {
       readLongArray(document, key);
     } else if (type == ElementType.TYPE_LONG_WRAPPER_ARRAY) {
       readLongWrapperArray(document, key);
     } else if (type == ElementType.TYPE_DOUBLE_ARRAY) {
       readDoubleArray(document, key);
     } else if (type == ElementType.TYPE_DOUBLE_WRAPPER_ARRAY) {
       readDoubleWrapperArray(document, key);
     } else if (type == ElementType.TYPE_BYTE_ARRAY) {
       document.put(key, valueList.getNextBytes());
     } else {
       document.put(key, valueList.getNextObject());
     }
   }
 }