00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package org.objectweb.proactive.core.xml.handler;
00032
00033 import org.objectweb.proactive.core.xml.io.Attributes;
00034
00035
00044 public class CollectionUnmarshaller extends AbstractUnmarshallerDecorator {
00045 protected java.util.ArrayList resultList;
00046 protected Class targetClass;
00047
00048
00049
00050
00051 public CollectionUnmarshaller(boolean lenient) {
00052 this(null, lenient);
00053 }
00054
00055 public CollectionUnmarshaller() {
00056 this(null);
00057 }
00058
00059 public CollectionUnmarshaller(Class targetClass, boolean lenient) {
00060 super(lenient);
00061 this.targetClass = targetClass;
00062 }
00063
00064 public CollectionUnmarshaller(Class targetClass) {
00065 super();
00066 this.targetClass = targetClass;
00067 }
00068
00069
00070
00071
00072
00073
00074
00075 public Object getResultObject() throws org.xml.sax.SAXException {
00076 int size = 0;
00077 if (resultList != null) {
00078 size = resultList.size();
00079 }
00080 Object[] resultArray = null;
00081 if (targetClass == null) {
00082 resultArray = new Object[size];
00083 } else {
00084 resultArray = (Object[]) java.lang.reflect.Array.newInstance(targetClass,
00085 size);
00086 }
00087 if (size > 0) {
00088 resultList.toArray(resultArray);
00089 }
00090
00091
00092 resultList = null;
00093
00094 return resultArray;
00095 }
00096
00097 public void startContextElement(String name, Attributes attributes)
00098 throws org.xml.sax.SAXException {
00099 resultList = new java.util.ArrayList();
00100 }
00101
00102
00103
00104
00105 protected void notifyEndActiveHandler(String name,
00106 UnmarshallerHandler activeHandler) throws org.xml.sax.SAXException {
00107 Object o = activeHandler.getResultObject();
00108 if (o != null) {
00109 resultList.add(o);
00110 }
00111 }
00112
00113
00114
00115
00116
00117
00118
00119 }