public final class XMLRecognizer extends Recognizer
XMLRecognizer is the default Recognizer
implementation used in the IDE. It contains support for recognizing
an XML document through a variety of mechanisms.| Modifier and Type | Class and Description |
|---|---|
static class |
XMLRecognizer.Attribute
Represents one attribute name/value pair used in the Attributes class.
|
static class |
XMLRecognizer.Attributes
When Node types are recognized based on root element name and
namespace, they can additionally be recognized based on root
element attribute name/value pairs, either an and'ed list of
attribute name/value pairs (all name/value pairs have to be
present for the Node to be recognized), or an or'ed list (at
least one of the name/value pairs has to be present for the
Node to be recognized).
|
static class |
XMLRecognizer.Doctype
Two Doctype instances are considered equal if their public IDs
match, regardless of what the system IDs are.
|
static class |
XMLRecognizer.NoNamespaceRule |
static class |
XMLRecognizer.NSElem |
Recognizer.DeclarativeDocumentInfo| Modifier and Type | Method and Description |
|---|---|
Node |
create(java.net.URL url,
java.lang.Class nodeType)
This method creates a
Node instance of the specified
type with the specified URL. |
static NodeInfo |
findNodeInfo(java.lang.Class dataClass)
This method finds a
NodeInfo instance that is associated
with a particular data Class. |
static XMLRecognizer |
getInstance() |
static void |
mapDoctypeToClass(java.lang.String publicId,
java.lang.String systemId,
java.lang.Class cls)
Maps the specified public ID and system ID (from the XML doctype)
to the specified data class.
|
static void |
mapNamespaceElemAttributesToClass(java.lang.String namespaceURI,
java.lang.String localElemName,
XMLRecognizer.Attributes attributes,
java.lang.Class cls)
Maps the specified root namespace element (a combination of the XML
namespace URI with local element name) and Attributes to the
specified data class.
|
static void |
mapNamespaceElemToClass(java.lang.String namespaceURI,
java.lang.String localElemName,
java.lang.Class cls)
Maps the specified namespace element (a combination of the XML
namespace URI with local element name) to the specified data
class.
|
static void |
mapRootElementToClass(java.lang.String rootElem,
java.lang.Class cls)
Maps the specified file
extension to the specified
data class. |
static void |
mapSchemaInstanceToClass(java.lang.String schemaLocationURI,
java.lang.String rootElemLocalName,
java.lang.Class nodeType)
Maps the specified schema location URI and root element's local name
to the specified data class.
|
MetaClass |
recognizeAsMeta(java.net.URL url)
This method allows gets the MetaClass of a recognized
Node. |
static void |
registerNodeInfo(NodeInfo info)
Uses the specified
NodeInfo to register recognizer
behavior. |
static void |
treatExtensionAsXML(java.lang.String extension)
Registers the specified
extension as one that
corresponds to an XML file. |
static void |
treatExtensionAsXML(java.lang.String extension,
NodeInfoLoader loader)
Registers the specified
extension as one that
corresponds to an XML file. |
java.net.URL |
validate(java.net.URL newURL,
java.net.URL oldURL)
Validate the specified new name.
|
canConvert, findRecognizer, getClassForExtension, getContentTypeForExtension, getDeclarativeExtensionToClassMap, getDeclarativeExtensionToContentTypeMap, getDefaultNodeType, getDefaultNodeTypeAsMeta, getDefaultRecognizer, getDocumentInfo, getDocumentInfo, getDocumentInfoForDeclarativeEntries, getExtensionToClassMap, getExtensionToContentTypeMap, getExtensionToMetaClassMap, getLogger, isXmlExtension, mapExtensionToClass, mapExtensionToContentType, mapExtensionToMetaClass, mapExtensionToXML, recognize, recognizeURL, recognizeURL, recognizeURLAsMeta, recognizeURLAsMeta, registerConversion, registerDocumentInfo, registerLowPriorityRecognizer, registerRecognizer, registerRecognizer, sanitizeExtension, setDefaultRecognizerpublic static XMLRecognizer getInstance()
public static void treatExtensionAsXML(java.lang.String extension)
extension as one that
corresponds to an XML file. The XMLRecognizer only attempts
to find a data class for an XML file if the URL for the file
has an extension that is treated as XML.
The extension passed in is allowed to contain
or omit the leading "."; if it is omitted, it will be added
automatically.
public static void treatExtensionAsXML(java.lang.String extension,
NodeInfoLoader loader)
extension as one that
corresponds to an XML file. The NodeInfoLoader will be
used to trigger the lazy loading of NodeInfo objects if
an URL with the specified extension is
recognized by XMLRecognizer.
The loader can be null, which means
that there is no NodeInfoLoader that needs to be invoked
for the specified extension.
public static void mapNamespaceElemToClass(java.lang.String namespaceURI,
java.lang.String localElemName,
java.lang.Class cls)
public static void mapNamespaceElemAttributesToClass(java.lang.String namespaceURI,
java.lang.String localElemName,
XMLRecognizer.Attributes attributes,
java.lang.Class cls)
namespaceURI - The namespace of the root elementlocalElemName - The name of the root elementattributes - The attributes to match in the root elementcls - The Node type to recognizepublic static void mapSchemaInstanceToClass(java.lang.String schemaLocationURI,
java.lang.String rootElemLocalName,
java.lang.Class nodeType)
public static void mapDoctypeToClass(java.lang.String publicId,
java.lang.String systemId,
java.lang.Class cls)
public static void mapRootElementToClass(java.lang.String rootElem,
java.lang.Class cls)
extension to the specified
data class.
The specified extension is allowed to contain or
omit the leading "."; if omitted, it will be added automatically.
public static void registerNodeInfo(NodeInfo info)
NodeInfo to register recognizer
behavior.NodeInfopublic static NodeInfo findNodeInfo(java.lang.Class dataClass)
NodeInfo instance that is associated
with a particular data Class.dataClass - The data Class.NodeInfo associated with the data class or
null if no NodeInfo is found.public MetaClass recognizeAsMeta(java.net.URL url)
RecognizerNode.
This is useful for cases in which the classloader of a metaclass is not the
same as the real classloader of the node class. It may also be useful,
for cases when we need to get the MetaClass of a recognized node without
initializing the node extensions.recognizeAsMeta in class Recognizerurl - unique URL identifying the document.Node type as a MetaClass object.public Node create(java.net.URL url, java.lang.Class nodeType) throws java.lang.IllegalAccessException, java.lang.InstantiationException
RecognizerNode instance of the specified
type with the specified URL. If the type is
null, then the returned Node is also
null.create in class Recognizerurl - unique URL identifying the document.nodeType - the type of the Node. The specified
Class object must represent a type of Node, or else
a ClassCastException will occur.Node.java.lang.IllegalAccessExceptionjava.lang.InstantiationExceptionpublic java.net.URL validate(java.net.URL newURL,
java.net.URL oldURL)
throws RecognizerException
Recognizernull if the
name does not validate. This method may modify the URL to
make it valid, such as adding a file extension. The old
URL is used as the validation base. For example, if the
new URL does not have the correct file extension, the old
URL extension may be added to the new URL during
the validation process.validate in class RecognizernewURL - the new URL to validate.oldURL - the old URL used as the validation base.URL or null if the
name does not validate.RecognizerException - if validation fails. The reason
why validation failed is in the exception's message. The message
should be suitably formatted so that it can be displayed to the
user.