예제 #1
0
 // array: the array of unknown class to write as XML
 private void writeArray(Object array)
     throws NoSuchMethodException, InvocationTargetException, InstantiationException,
         IllegalAccessException, SecurityException {
   final int length = Array.getLength(array);
   this.driver.startElement(DTD.ELEMENT_ARRAY);
   this.driver.setAttribute(DTD.ATTRIBUTE_LENGTH, Integer.toString(length));
   final ValueType pvt = ValueType.ofPrimitive(array.getClass().getComponentType());
   if (pvt != null) { // primitives array:
     for (int i = 0; i < length; i++) {
       pvt.getWriteArrayItem(this.driver, array, i, false);
     }
   } else { // objects array:
     final Object[] objArray = (Object[]) array;
     for (int i = 0; i < length; i++) {
       this.write0(objArray[i]);
     }
   }
   this.driver.endElement();
 }