public class XMLSchemaParser extends XMLMetaDataParser implements SchemaParser
Schema
objects. The parser
will place all parsed schemas into the current SchemaGroup
, set
via the setSchemaGroup(org.apache.openjpa.jdbc.schema.SchemaGroup)
method. This allows parsing of
multiple files into a single schema group.
The parser deserializes from the following XML format: <!ELEMENT schemas (schema)+>
<!ELEMENT schema (table|sequence)+>
<!ATTLIST schema name CDATA #IMPLIED>
<!ELEMENT table (column|index|pk|fk|unique)+>
<!ATTLIST table name CDATA #REQUIRED>
<!ELEMENT column EMPTY>
<!ATTLIST column name CDATA #REQUIRED>
<!ATTLIST column type (array|bigint|binary|bit|blob|char|clob
|date|decimal|distinct|double|float|integer|java_object
|longvarbinary|longvarchar|null|numeric|other|real|ref|smallint|struct
|time|timstamp|tinyint|varbinary|varchar) #REQUIRED>
<!ATTLIST column type-name CDATA #IMPLIED>
<!ATTLIST column size CDATA #IMPLIED>
<!ATTLIST column decimal-digits CDATA #IMPLIED>
<!ATTLIST column not-null (true|false) "false">
<!ATTLIST column default CDATA #IMPLIED>
<!ATTLIST column auto-assign (true|false) "false">
<!ELEMENT index (on)*>
<!ATTLIST index name CDATA #REQUIRED>
<!ATTLIST index column CDATA #IMPLIED>
<!ATTLIST index unique (true|false) "false">
<!ELEMENT on EMPTY>
<!ATTLIST on column CDATA #REQUIRED>
<!ELEMENT pk (on)*>
<!ATTLIST pk name CDATA #IMPLIED>
<!ATTLIST pk column CDATA #IMPLIED>
<!ELEMENT fk (join)*>
<!ATTLIST fk name CDATA #IMPLIED>
<!ATTLIST fk deferred (true|false) "false">
<!ATTLIST fk column CDATA #IMPLIED>
<!ATTLIST fk to-table CDATA #REQUIRED>
<!ATTLIST fk delete-action (cascade|default|restrict|none|null)
"none">
<!ATTLIST fk update-action (cascade|default|restrict|none|null)
"none">
<!ELEMENT unique (on)*>
<!ATTLIST unique name CDATA #IMPLIED>
<!ATTLIST unique column CDATA #IMPLIED>
<!ATTLIST unique deferred (true|false) "false">
<!ELEMENT join EMPTY>
<!ATTLIST join column CDATA #IMPLIED>
<!ATTLIST join value CDATA #IMPLIED>
<!ATTLIST join to-column CDATA #REQUIRED>
<!ELEMENT sequence EMPTY>
<!ATTLIST sequence name CDATA #REQUIRED>
<!ATTLIST sequence initial-value CDATA #IMPLIED>
<!ATTLIST sequence increment CDATA #IMPLIED>
<!ATTLIST sequence allocate CDATA #IMPLIED>
Schema parsers are not threadsafe.Modifier and Type | Class and Description |
---|---|
static class |
XMLSchemaParser.UniqueInfo
Used to hold unique constraint info before it is resolved.
|
_extendedNamespace, _openjpaNamespace
Constructor and Description |
---|
XMLSchemaParser(JDBCConfiguration conf)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
endElement(String name)
Override this method marking the end of some element.
|
protected void |
finish()
Parse the schema relating to the given class.
|
boolean |
getDelayConstraintResolve()
Delay resolution of foreign key constraints until
SchemaParser.resolveConstraints() is called. |
protected Reader |
getDocType()
Override this method to return any
DOCTYPE declaration
that should be dynamically included in xml documents that will be
validated. |
SchemaGroup |
getSchemaGroup()
Return the current schema group.
|
protected void |
reset()
Override this method to clear any state and ready the parser for
a new document.
|
void |
resolveConstraints()
If this parser is in delayed resolve mode, resolve all constraints.
|
void |
setDelayConstraintResolve(boolean delay)
Delay resolution of foreign key constraints until
SchemaParser.resolveConstraints() is called. |
void |
setSchemaGroup(SchemaGroup group)
Set the current schema group; this clears all state from the last group.
|
protected boolean |
startElement(String name,
Attributes attrs)
Override this method marking the start of some element.
|
addComments, addResult, characters, clear, clearDeferredMetaData, comment, currentClassLoader, currentComments, currentDepth, currentLocation, currentText, endCDATA, endDTD, endElement, endEntity, error, fatalError, getClassLoader, getException, getException, getException, getLexicalHandler, getLocation, getLog, getOverrideContextClassloader, getParseComments, getParseText, getResults, getSchemaSource, getSourceFile, getSourceIsSystemId, getSourceName, getSuffix, ignoreContent, isCaching, isParsing, isValidating, parse, parse, parse, parse, parse, parse, parsed, parseNewResource, setCaching, setClassLoader, setDocumentLocator, setLexicalHandler, setLocation, setLog, setOverrideContextClassloader, setParseComments, setParseText, setParsing, setSourceIsSystemId, setSuffix, setValidating, startCDATA, startDTD, startElement, startEntity
endDocument, endPrefixMapping, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clear, getResults, parse, parse, parse, parse, parse, parse, setClassLoader
public XMLSchemaParser(JDBCConfiguration conf)
public boolean getDelayConstraintResolve()
SchemaParser
SchemaParser.resolveConstraints()
is called. This allows you to parse
multiple resources where a foreign key in one resource might refer
to a table in another.getDelayConstraintResolve
in interface SchemaParser
public void setDelayConstraintResolve(boolean delay)
SchemaParser
SchemaParser.resolveConstraints()
is called. This allows you to parse
multiple resources where a foreign key in one resource might refer
to a table in another.setDelayConstraintResolve
in interface SchemaParser
public void resolveConstraints()
SchemaParser
resolveConstraints
in interface SchemaParser
public SchemaGroup getSchemaGroup()
SchemaParser
getSchemaGroup
in interface SchemaParser
public void setSchemaGroup(SchemaGroup group)
SchemaParser
setSchemaGroup
in interface SchemaParser
protected void finish()
finish
in class XMLMetaDataParser
protected void reset()
XMLMetaDataParser
super.reset()
to clear superclass state.reset
in class XMLMetaDataParser
protected Reader getDocType() throws IOException
XMLMetaDataParser
DOCTYPE
declaration
that should be dynamically included in xml documents that will be
validated. Returns null by default.getDocType
in class XMLMetaDataParser
IOException
protected boolean startElement(String name, Attributes attrs) throws SAXException
XMLMetaDataParser
startElement
in class XMLMetaDataParser
SAXException
protected void endElement(String name)
XMLMetaDataParser
endElement
in class XMLMetaDataParser
Copyright © 2006–2019 Apache Software Foundation. All rights reserved.