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.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 |
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, setDefaultRecognizer
public 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 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.NodeInfo
public 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)
Recognizer
Node
.
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 Recognizer
url
- 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
Recognizer
Node
instance of the specified
type with the specified URL
. If the type is
null
, then the returned Node is also
null
.create
in class Recognizer
url
- 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.IllegalAccessException
java.lang.InstantiationException
public java.net.URL validate(java.net.URL newURL, java.net.URL oldURL) throws RecognizerException
Recognizer
null
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 Recognizer
newURL
- 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.