From: <je...@sv...> - 2006-07-29 01:13:57
|
Author: jeichar Date: 2006-07-28 18:13:12 -0700 (Fri, 28 Jul 2006) New Revision: 20748 Added: geotools/trunk/gt/module/main/src/org/geotools/xml/handlers/XMLTypeHel= per.java Log: forgot class Added: geotools/trunk/gt/module/main/src/org/geotools/xml/handlers/XMLTyp= eHelper.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- geotools/trunk/gt/module/main/src/org/geotools/xml/handlers/XMLTypeHe= lper.java 2006-07-29 01:12:15 UTC (rev 20747) +++ geotools/trunk/gt/module/main/src/org/geotools/xml/handlers/XMLTypeHe= lper.java 2006-07-29 01:13:12 UTC (rev 20748) @@ -0,0 +1,46 @@ +/** + *=20 + */ +package org.geotools.xml.handlers; + +import java.net.URI; + +import org.geotools.xml.schema.ComplexType; +import org.geotools.xml.schema.Element; +import org.geotools.xml.schema.ElementGrouping; +import org.geotools.xml.schema.Type; + +/** + * Utility class with methods to help implement Element and Type Handler= s=20 + * @author Jesse + */ +public class XMLTypeHelper { + + public static Element findChildElement(Type type, String localName, URI= namespaceURI) { + if( type instanceof ComplexType ){ + ComplexType complexType=3D(ComplexType) type; + ElementGrouping child =3D complexType.getChild(); + if( child!=3Dnull){ + Element found=3Dchild.findChildElement(localName, namespaceURI); + if( found!=3Dnull ) + return found; + } + Element[] children =3D complexType.getChildElements(); + if( children=3D=3Dnull || children.length=3D=3D0) + return null; + for (int i =3D 0; i < children.length; i++) { + Element element =3D children[i]; + if( localName.equals(element.getName()) && namespaceURI.equals(eleme= nt.getNamespace()) ) + return element; + } + if( complexType.getParent()!=3Dnull ){ + Type parent =3D complexType.getParent(); + return findChildElement((ComplexType) parent, localName, namespaceUR= I); + } + }else{ + return type.findChildElement(localName); + } + return null; + } + +} |