%@ jet package="org.geotools.maven.xmlcodegen.templates" imports="java.util.* java.io.* org.opengis.feature.type.Schema org.geotools.maven.xmlcodegen.* org.geotools.feature.* org.opengis.feature.type.TypeName org.apache.xml.serialize.* org.eclipse.xsd.*" class="SchemaClassTemplate" %> <% Object[] arguments = (Object[]) argument; Schema schema = (Schema) arguments[0]; String prefix = (String) arguments[1]; prefix = prefix.toUpperCase(); SchemaGenerator sg = (SchemaGenerator) arguments[2]; %> import org.geotools.feature.AttributeType; import org.geotools.feature.AttributeTypeFactory; import org.geotools.feature.Name; import org.geotools.feature.type.SchemaImpl; <% HashMap ns2import = new HashMap(); for (Iterator itr = sg.getImports().iterator(); itr.hasNext();) { Schema imported = (Schema)itr.next(); String fullClassName = imported.getClass().getName(); String className = fullClassName.substring(fullClassName.lastIndexOf(".")+1); ns2import.put(imported.namespace().getURI(), className); %> import <%=fullClassName%>; <% } %> public class <%=prefix%>Schema extends SchemaImpl { <% for (Iterator itr = schema.values().iterator(); itr.hasNext();) { AttributeType type = (AttributeType) itr.next(); String name = type.getName(); String binding = type.getType().getName() + ".class"; %> /** *
*
*
<%
XSDTypeDefinition xsdType = sg.getXSDType(type);
OutputFormat output = new OutputFormat();
output.setOmitXMLDeclaration(true);
output.setIndenting(true);
StringWriter writer = new StringWriter();
XMLSerializer serializer = new XMLSerializer(writer,output);
try {
serializer.serialize(xsdType.getElement());
}
catch (IOException e) {
e.printStackTrace();
return null;
}
String[] lines = writer.getBuffer().toString().split("\n");
for (int i = 0; i < lines.length; i++) {
%>
* <%=lines[i].replaceAll("<","<").replaceAll(">",">")%>
<%
}
%>
*
*
*
*
*
* @generated
*/
public static final AttributeType <%=name.toUpperCase()%>_TYPE =
AttributeTypeFactory.newAttributeType( "<%=name%>", <%=binding%> );
<%
}
%>
public <%=prefix%>Schema() {
super("<%=schema.toURI()%>");
<%
for (Iterator itr = schema.values().iterator(); itr.hasNext();) {
AttributeType type = (AttributeType) itr.next();
%>
put(new Name( "<%=schema.namespace().getURI()%>", "<%=type.getName()%>" ),<%=type.getName().toUpperCase()%>_TYPE);
<%
}
%>
}
}