Methods Summary |
---|
public java.util.List | getCascadeTypes(org.w3c.dom.Node node)INTERNAL:
ArrayList<String> cTypes = new ArrayList<String>();
NodeList cascadeTypes = getNodes(node, XMLConstants.CASCADE, XMLConstants.ALL_CHILDREN);
for (int i = 0; i < cascadeTypes.getLength(); i++) {
cTypes.add(cascadeTypes.item(i).getLocalName());
}
return cTypes;
|
public java.lang.Class | getClassForName(java.lang.String className)INTERNAL:
return MetadataHelper.getClassForName(getFullyQualifiedClassName(className), m_loader);
|
public java.lang.Class | getClassForNode(org.w3c.dom.Node node)INTERNAL:
Return the Class for a given node. This method assumes that the node
requires a class attribute, i.e. entity or mapped-superclass.
return MetadataHelper.getClassForName(getClassNameForNode(node), m_loader);
|
public java.lang.ClassLoader | getClassLoader()INTERNAL:
Get the loader.
return m_loader;
|
public java.lang.String | getClassNameForNode(org.w3c.dom.Node node)INTERNAL:
Return the fully qualified class name for a given node. This method
assumes that the node requires a class attribute, i.e. entity or
mapped-superclass.
return getFullyQualifiedClassName(getNodeValue(node, XMLConstants.ATT_CLASS));
|
public org.w3c.dom.Document | getDocument()INTERNAL:
Return the instance document associated with this helper.
return m_document;
|
public java.lang.String | getDocumentName()INTERNAL:
Return the instance document name associated with this helper.
return m_documentName;
|
public java.lang.String | getFetchTypeDefaultEAGER(org.w3c.dom.Node node)INTERNAL:
return getNodeValue(node, XMLConstants.ATT_FETCH, MetadataConstants.EAGER);
|
public java.lang.String | getFetchTypeDefaultLAZY(org.w3c.dom.Node node)INTERNAL:
return getNodeValue(node, XMLConstants.ATT_FETCH, MetadataConstants.LAZY);
|
public java.lang.String | getFullyQualifiedClassName(java.lang.String className)INTERNAL:
This convenience method will attempt to fully qualify a class name if
required. This assumes that the className value is non-null, and a
"qualified" class name contains at least one '.'
return getFullyQualifiedClassName(className, m_defaultPackage);
|
public static java.lang.String | getFullyQualifiedClassName(java.lang.String className, java.lang.String packageName)INTERNAL:
This convenience method will attempt to fully qualify a class name if
required. This assumes that the className value is non-null, and a
"qualified" class name contains at least one '.'
// if there is no global package defined or the class name is qualified, return className
if (packageName.equals("") || className.indexOf(".") != -1) {
return className;
}
// prepend the package to the class name
// format of global package is "foo.bar."
if (packageName.endsWith(".")) {
return (packageName + className);
}
// format of global package is "foo.bar"
return (packageName + "." + className);
|
public java.lang.String | getLoggingContextForDefaultMappingReferenceClass(org.w3c.dom.Node mappingNode)INTERNAL:
This convenience method determines the type of relationship mapping the
node represents, and returns the appropriate logging context.
if (mappingNode.getLocalName().equals(XMLConstants.ONE_TO_ONE)) {
return MetadataLogger.ONE_TO_ONE_MAPPING_REFERENCE_CLASS;
}
if (mappingNode.getLocalName().equals(XMLConstants.ONE_TO_MANY)) {
return MetadataLogger.ONE_TO_MANY_MAPPING_REFERENCE_CLASS;
}
if (mappingNode.getLocalName().equals(XMLConstants.MANY_TO_ONE)) {
return MetadataLogger.MANY_TO_ONE_MAPPING_REFERENCE_CLASS;
}
// assume many-to-many
return MetadataLogger.MANY_TO_MANY_MAPPING_REFERENCE_CLASS;
|
public java.lang.String | getMappedBy(org.w3c.dom.Node node)INTERNAL:
return getNodeValue(node, XMLConstants.ATT_MAPPED_BY, "");
|
public org.w3c.dom.Node | getNode(org.w3c.dom.Node node, java.lang.String xPath)INTERNAL:
Get a node off the given node.
return getNode(node, new String[] {xPath});
|
public org.w3c.dom.Node | getNode(org.w3c.dom.Node node, java.lang.String[] xPath)INTERNAL:
Get a node off the given node.
return m_xPathEngine.selectSingleNode(node, xPath);
|
public org.w3c.dom.Node | getNode(java.lang.String[] xPath)INTERNAL:
Get a node off the document node.
return getNode(m_document, xPath);
|
public java.lang.String | getNodeTextValue(org.w3c.dom.Node node, java.lang.String xPath)INTERNAL:
return getNodeValue(node, new String[] {xPath, XMLConstants.TEXT});
|
public java.lang.String | getNodeTextValue(java.lang.String xPath1, java.lang.String xPath2)INTERNAL:
return getNodeValue(m_document, new String[] {xPath1, xPath2, XMLConstants.TEXT});
|
public java.lang.String | getNodeTextValue(java.lang.String xPath1, java.lang.String xPath2, java.lang.String defaultValue)INTERNAL:
return getNodeValue(m_document, new String[] {xPath1, xPath2, XMLConstants.TEXT}, defaultValue);
|
public java.lang.String | getNodeValue(org.w3c.dom.Node node, java.lang.String xPath)INTERNAL:
return getNodeValue(node, new String[] {xPath});
|
public boolean | getNodeValue(org.w3c.dom.Node node, java.lang.String xPath, boolean defaultValue)INTERNAL:
return getNodeValue(node, new String[] {xPath}, defaultValue);
|
public java.lang.Class | getNodeValue(org.w3c.dom.Node node, java.lang.String xPath, java.lang.Class defaultValue)INTERNAL:
return getNodeValue(node, new String[] {xPath}, defaultValue);
|
public int | getNodeValue(org.w3c.dom.Node node, java.lang.String xPath, int defaultValue)INTERNAL:
return getNodeValue(node, new String[] {xPath}, defaultValue);
|
public java.lang.String | getNodeValue(org.w3c.dom.Node node, java.lang.String xPath, java.lang.String defaultValue)INTERNAL:
return getNodeValue(node, new String[] {xPath}, defaultValue);
|
public boolean | getNodeValue(org.w3c.dom.Node node, java.lang.String[] xPath, boolean defaultValue)INTERNAL:
return getValue(getNode(node, xPath), defaultValue);
|
public java.lang.Class | getNodeValue(org.w3c.dom.Node node, java.lang.String[] xPath, java.lang.Class defaultValue)INTERNAL:
return getValue(getNode(node, xPath), defaultValue);
|
public int | getNodeValue(org.w3c.dom.Node node, java.lang.String[] xPath, int defaultValue)INTERNAL:
return getValue(getNode(node, xPath), defaultValue);
|
public java.lang.String | getNodeValue(org.w3c.dom.Node node, java.lang.String[] xPath, java.lang.String defaultValue)INTERNAL:
return getValue(getNode(node, xPath), defaultValue);
|
public java.lang.String | getNodeValue(org.w3c.dom.Node node, java.lang.String[] xPath)INTERNAL:
return getNodeValue(node, xPath, "");
|
public java.lang.String | getNodeValue(java.lang.String[] xPath)INTERNAL:
return getNodeValue(xPath, "");
|
public int | getNodeValue(java.lang.String[] xPath, int defaultValue)INTERNAL:
return getValue(getNode(xPath), defaultValue);
|
public java.lang.String | getNodeValue(java.lang.String[] xPath, java.lang.String defaultValue)INTERNAL:
return getValue(getNode(xPath), defaultValue);
|
public org.w3c.dom.NodeList | getNodes(java.lang.String xPath1, java.lang.String xPath2)INTERNAL:
Get the nodes off the given node.
return getNodes(m_document, new String[] {xPath1, xPath2});
|
public org.w3c.dom.NodeList | getNodes(java.lang.String[] xPath)INTERNAL:
Get the nodes off the given node.
return getNodes(m_document, xPath);
|
public org.w3c.dom.NodeList | getNodes(org.w3c.dom.Node node, java.lang.String xPath)INTERNAL:
return getNodes(node, new String[] {xPath});
|
public org.w3c.dom.NodeList | getNodes(org.w3c.dom.Node node, java.lang.String xPath1, java.lang.String xPath2)INTERNAL:
return getNodes(node, new String[] {xPath1, xPath2});
|
public org.w3c.dom.NodeList | getNodes(org.w3c.dom.Node node, java.lang.String[] xPath)INTERNAL:
return m_xPathEngine.selectNodes(node, xPath);
|
public java.lang.String | getPackage()INTERNAL:
return m_defaultPackage;
|
public java.lang.Class | getTargetEntity(org.w3c.dom.Node node)INTERNAL:
return getNodeValue(node, XMLConstants.ATT_TARGET_ENTITY, void.class);
|
public org.w3c.dom.NodeList | getTextColumnNodes(org.w3c.dom.Node node)INTERNAL:
return getNodes(node, new String[] {XMLConstants.COLUMN_NAME, XMLConstants.TEXT});
|
private boolean | getValue(org.w3c.dom.Node node, boolean defaultValue)INTERNAL:
if (node == null) {
return defaultValue;
} else {
return Boolean.parseBoolean(node.getNodeValue());
}
|
private java.lang.Class | getValue(org.w3c.dom.Node node, java.lang.Class defaultValue)INTERNAL:
if (node == null) {
return defaultValue;
} else {
return getClassForName(node.getNodeValue());
}
|
private int | getValue(org.w3c.dom.Node node, int defaultValue)INTERNAL:
if (node == null) {
return defaultValue;
} else {
return Integer.parseInt(node.getNodeValue());
}
|
private java.lang.String | getValue(org.w3c.dom.Node node, java.lang.String defaultValue)INTERNAL:
if (node == null) {
return defaultValue;
} else {
String value = node.getNodeValue();
if (value == null) {
return defaultValue;
} else {
return value;
}
}
|
public boolean | hasNode(org.w3c.dom.Node node, java.lang.String xPath)INTERNAL:
return getNode(node, xPath) != null;
|
public boolean | isOptional(org.w3c.dom.Node node)INTERNAL:
return getNodeValue(node, XMLConstants.ATT_OPTIONAL, true);
|
public org.w3c.dom.Node | locateEmbeddableNode(java.lang.Class cls)INTERNAL:
Locate a node in the DOM tree for a given class.
return locateNode(cls, XMLConstants.EMBEDDABLE);
|
public org.w3c.dom.Node | locateEntityNode(java.lang.Class cls)INTERNAL:
Locate a node in the DOM tree for a given class.
return locateNode(cls, XMLConstants.ENTITY);
|
public org.w3c.dom.Node | locateMappedSuperclassNode(java.lang.Class cls)INTERNAL:
Locate a node in the DOM tree for a given class.
return locateNode(cls, XMLConstants.MAPPED_SUPERCLASS);
|
public org.w3c.dom.Node | locateNode(java.lang.Class cls)INTERNAL:
Locate a node in the DOM tree for the given class. Will look for
an entity, embeddable, or mapped-superclass node with @class matching
the class name.
Node result = null;
result = locateEntityNode(cls);
if (result == null) {
result = locateMappedSuperclassNode(cls);
}
if (result == null) {
result = locateEmbeddableNode(cls);
}
return result;
|
private org.w3c.dom.Node | locateNode(java.lang.Class cls, java.lang.String searchString)INTERNAL:
Locate a node in the DOM tree for a given class.
The search string should be used as follows:
- For an entity: XMLConstants.ENTITY
- For an embeddable: XMLConstants.EMBEDDABLE
- For a mapped superclass: XMLConstants.MAPPED_SUPERCLASS
Or call locateNode which will check them all. For efficiency, it looks
for an entity first.
NodeList nodes = getNodes(m_document, XMLConstants.ENTITY_MAPPINGS, searchString);
if (nodes != null) {
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
// process @class (required)
if (getClassNameForNode(node).equals(cls.getName())) {
return node;
}
}
}
return null;
|
public org.w3c.dom.Node | locateNodeForAttribute(org.w3c.dom.Node node, java.lang.String attributeName)INTERNAL:
Locate a node in the DOM tree for a given attribute name.
NodeList attributeNodes = getNodes(node, XMLConstants.ATTRIBUTES, XMLConstants.ALL_CHILDREN);
if (attributeNodes != null) {
Node attributeNode;
for (int i = 0; i < attributeNodes.getLength(); i++) {
attributeNode = attributeNodes.item(i);
// process @name (required)
if (getNodeValue(attributeNode, XMLConstants.ATT_NAME).equals(attributeName)) {
return attributeNode;
}
}
}
return null;
|
public java.lang.Class | locateRootEntity(java.lang.Class entityClass)INTERNAL:
Return the root entity in an entity class hierarchy
Class superclass = entityClass.getSuperclass();
if (superclass != null) {
Node entityNode = locateEntityNode(superclass);
if (entityNode != null) {
return locateRootEntity(superclass);
}
}
return entityClass;
|
public boolean | nodeHasJoinColumns(org.w3c.dom.Node node)INTERNAL:
Indicates if a given node has a primary-key-join-column sub-element.
if (node == null) {
return false;
}
NodeList nodes = getNodes(node, XMLConstants.JOIN_COLUMN);
return (nodes != null && nodes.getLength() > 0);
|
public boolean | nodeHasPrimaryKeyJoinColumns(org.w3c.dom.Node node)INTERNAL:
Indicates if a given node has a primary-key-join-column sub-element.
if (node == null) {
return false;
}
NodeList nodes = getNodes(node, XMLConstants.PK_JOIN_COLUMN);
return (nodes != null && nodes.getLength() > 0);
|
public static org.w3c.dom.Document | parseDocument(java.io.InputStream xmlDocumentInputStream, java.lang.String documentName, java.lang.ClassLoader loader)INTERNAL:
Build a DOM from an instance document using the provided URL.
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setAttribute(XMLConstants.SCHEMA_LANGUAGE, XMLConstants.XML_SCHEMA);
dbf.setValidating(true);
// attempt to load the schema from the classpath
URL schemaURL = loader.getResource(XMLConstants.ORM_SCHEMA_NAME);
if (schemaURL != null) {
dbf.setAttribute(XMLConstants.JAXP_SCHEMA_SOURCE, schemaURL.toString());
}
// create a document builder
DocumentBuilder db;
try {
db = dbf.newDocumentBuilder();
} catch (ParserConfigurationException pex) {
throw XMLParseException.exceptionCreatingDocumentBuilder(documentName, pex);
}
// set the parse exception handler
XMLExceptionHandler xmlExceptionHandler = new XMLExceptionHandler();
db.setErrorHandler(xmlExceptionHandler);
// parse the document
Document doc = null;
try {
doc = db.parse(xmlDocumentInputStream);
} catch (IOException ioex) {
throw XMLParseException.exceptionReadingXMLDocument(documentName, ioex);
} catch (SAXException saxex) {
// XMLExceptionHandler will handle parse exceptions
}
XMLException xmlEx = xmlExceptionHandler.getXMLException();
if (xmlEx != null) {
throw ValidationException.invalidEntityMappingsDocument(documentName, xmlEx);
}
return doc;
|
public void | setLoader(java.lang.ClassLoader loader)INTERNAL:
Update the loader after it changes.
m_loader = loader;
|