1 17 package org.apache.ws.jaxme.xs.impl; 18 19 import java.util.ArrayList ; 20 import java.util.List ; 21 22 import org.apache.ws.jaxme.xs.XSAnnotation; 23 import org.apache.ws.jaxme.xs.XSAppinfo; 24 import org.apache.ws.jaxme.xs.parser.impl.LocSAXException; 25 import org.xml.sax.SAXException ; 26 27 30 public class XSUtil { 31 34 public static List getAppinfos(XSAnnotation[] annotations, Class pClass) { 35 List result = new ArrayList (); 36 for (int i = 0; i < annotations.length; i++) { 37 XSAppinfo[] appinfos = annotations[i].getAppinfos(); 38 for (int j = 0; j < appinfos.length; j++) { 39 Object [] childs = appinfos[j].getChilds(); 40 for (int k = 0; k < childs.length; k++) { 41 if (pClass.isAssignableFrom(childs[k].getClass())) { 42 result.add(childs[k]); 43 } 44 } 45 } 46 } 47 return result; 48 } 49 50 54 public static Object getSingleAppinfo(XSAnnotation[] annotations, Class pClass) throws SAXException { 55 Object result = null; 56 if (annotations != null) { 57 for (int i = 0; i < annotations.length; i++) { 58 XSAppinfo[] appinfos = annotations[i].getAppinfos(); 59 for (int j = 0; j < appinfos.length; j++) { 60 Object [] childs = appinfos[j].getChilds(); 61 for (int k = 0; k < childs.length; k++) { 62 if (pClass.isAssignableFrom(childs[k].getClass())) { 63 if (result == null) { 64 result = childs[k]; 65 } else { 66 throw new LocSAXException("Multiple instances of " + pClass.getName() + 67 " in xs:annotation/xs:appinfo are forbidden.", 68 appinfos[j].getLocator()); 69 } 70 } 71 } 72 } 73 } 74 } 75 return result; 76 } 77 } 78 | Popular Tags |