org.geotools.maven.xmlcodegen
Class SchemaGenerator

java.lang.Object
  extended by org.geotools.maven.xmlcodegen.AbstractGenerator
      extended by org.geotools.maven.xmlcodegen.SchemaGenerator

public class SchemaGenerator
extends AbstractGenerator

Parses an XML schema to procuce an instance of Schema.

Author:
Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org

Constructor Summary
SchemaGenerator(org.eclipse.xsd.XSDSchema schema)
           
 
Method Summary
 void addImport(org.opengis.feature.type.Schema imported)
          Adds an imported schema to be used for type lookups.
 void addTypeMapping(java.lang.String namespace, java.lang.String name, org.opengis.feature.type.AttributeType gtType)
          Provide an explicit mapping from an XSD type
 void generate()
          Generates the Geotools schema from the XML schema.
 org.opengis.feature.type.Schema getImport(java.lang.String namespace)
          Returns an imported schema for a particular namespace.
 java.util.Collection getImports()
           
 org.eclipse.xsd.XSDSchema getSchema()
           
 java.util.Map<org.opengis.feature.type.Name,java.lang.String> getTypeBindings()
           
 org.eclipse.xsd.XSDTypeDefinition getXSDType(org.opengis.feature.type.AttributeType type)
           
static void main(java.lang.String[] args)
           
 void setComplexTypes(boolean complexTypes)
           
 void setFollowComplexTypes(boolean followComplexTypes)
          Indicates to generator wether to follow the type definitons of complex types.
 void setIncludes(java.lang.String[] includes)
          Sets the type names for which to include in the generated schema.
 void setMaxRecursionDepth(int maxDepth)
          Sets the max depth the generator will recurse into the schema.
 void setPrintRecursionPaths(boolean printRecursionPaths)
          Sets the flag controlling whether paths are printed out as the generator recurses through the schema.
 void setSimpleTypes(boolean simpleTypes)
           
 void setTypeBindings(TypeBinding[] typeBindings)
          Add the explicit bindings of XSD types to fully-qualified class names.
 java.util.List sort()
          Returns a list of the types in the generated schema sorted as follows:
 
Methods inherited from class org.geotools.maven.xmlcodegen.AbstractGenerator
copy, execute, findSchemaFile, getPackageBase, included, outputLocation, setIncluded, setOverwriting, setPackageBase, setResourceLocation, setSchemaLookupDirectories, setSchemaSourceDirectory, setSourceLocation, setTestLocation, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SchemaGenerator

public SchemaGenerator(org.eclipse.xsd.XSDSchema schema)
Method Detail

getSchema

public org.eclipse.xsd.XSDSchema getSchema()
Returns:
The parsed xml schema.

setComplexTypes

public void setComplexTypes(boolean complexTypes)
Parameters:
complexTypes - Flag indicating wether or not to process complex types in the supplied schema.

setSimpleTypes

public void setSimpleTypes(boolean simpleTypes)
Parameters:
simpleTypes - Flag indicating wether or not to process complex types in the supplied schema.

setFollowComplexTypes

public void setFollowComplexTypes(boolean followComplexTypes)
Indicates to generator wether to follow the type definitons of complex types.

Warning, setting this flag to true will result in all generated complex types being empty.


setIncludes

public void setIncludes(java.lang.String[] includes)
Sets the type names for which to include in the generated schema.


setPrintRecursionPaths

public void setPrintRecursionPaths(boolean printRecursionPaths)
Sets the flag controlling whether paths are printed out as the generator recurses through the schema.


setMaxRecursionDepth

public void setMaxRecursionDepth(int maxDepth)
Sets the max depth the generator will recurse into the schema.


addTypeMapping

public void addTypeMapping(java.lang.String namespace,
                           java.lang.String name,
                           org.opengis.feature.type.AttributeType gtType)
Provide an explicit mapping from an XSD type

Parameters:
namespace -
name -

setTypeBindings

public void setTypeBindings(TypeBinding[] typeBindings)
Add the explicit bindings of XSD types to fully-qualified class names. If a type has a binding, it will be treated as non-complex and bound to the named class.

Parameters:
typeBindings -

getTypeBindings

public java.util.Map<org.opengis.feature.type.Name,java.lang.String> getTypeBindings()
Returns:
the map of XSD type names to fully-qualified class names.

addImport

public void addImport(org.opengis.feature.type.Schema imported)
Adds an imported schema to be used for type lookups.


getImport

public org.opengis.feature.type.Schema getImport(java.lang.String namespace)
Returns an imported schema for a particular namespace.

Returns:
The imported schema, or null if non exists.

getImports

public java.util.Collection getImports()
Returns:
The collection of schemas imported by the schema being generated.

getXSDType

public org.eclipse.xsd.XSDTypeDefinition getXSDType(org.opengis.feature.type.AttributeType type)
Parameters:
type - Geotools attribute type.
Returns:
the XSD type associated with type.

generate

public void generate()
              throws java.lang.Exception
Generates the Geotools schema from the XML schema.

Throws:
java.lang.Exception

sort

public java.util.List sort()
Returns a list of the types in the generated schema sorted as follows:


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 1996-2010 Geotools. All Rights Reserved.