站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

XMLDataObject (NetBeans Loaders API) - NetBeans API Javadoc 5.0.0

 

org.openide.loaders
Class XMLDataObject

java.lang.Object
  extended byorg.openide.loaders.DataObject
      extended byorg.openide.loaders.MultiDataObject
          extended byorg.openide.loaders.XMLDataObject
All Implemented Interfaces:
HelpCtx.Provider, Node.Cookie, Serializable

public class XMLDataObject
extends MultiDataObject

Object that provides main functionality for xml documents. These objects are recognized by the xml extension and text/xml MIME type.

It is declaratively extensible by an Environment. The Environment is assigned to document instances using a provider registered by DOCTYPE's public ID in the system filesystem under xml/lookups/{Transformed-DOCTYPE} where the DOCTYPE transformation is the same as that defined for EntityCatalog registrations.

See Also:
XMLUtil, EntityCatalog, Serialized Form

Nested Class Summary
static class XMLDataObject.Info
          Deprecated. use Lookup Representation of xmlinfo file holding container of Processors.
static interface XMLDataObject.Processor
          Deprecated. use lookup
 
Nested classes inherited from class org.openide.loaders.MultiDataObject
MultiDataObject.Entry
 
Nested classes inherited from class org.openide.loaders.DataObject
DataObject.Container, DataObject.Registry
 
Field Summary
static String MIME
          Mime type of XML documents.
static String PROP_DOCUMENT
          property name of DOM document property
static String PROP_INFO
          Deprecated. info is not supported anymore. Replaced with lookup.
static int STATUS_ERROR
          PROP_DOCUMENT parsed with errors.
static int STATUS_NOT
          PROP_DOCUMENT not parsed yet.
static int STATUS_OK
          PROP_DOCUMENT parsed ok.
static int STATUS_WARNING
          PROP_DOCUMENT parsed with warnings.
static String XMLINFO_DTD_PUBLIC_ID
          Deprecated. replaced with Lookup
static String XMLINFO_DTD_PUBLIC_ID_FORTE
          Deprecated. replaced with Lookup
 
Fields inherited from class org.openide.loaders.DataObject
PROP_COOKIE, PROP_FILES, PROP_HELP, PROP_MODIFIED, PROP_NAME, PROP_PRIMARY_FILE, PROP_TEMPLATE, PROP_VALID
 
Constructor Summary
XMLDataObject(FileObject fo, MultiFileLoader loader)
          Create new XMLDataObject.
 
Method Summary
static boolean addEntityResolver(EntityResolver resolver)
          Deprecated. EntityResolver is a parser user responsibility. Every time set a EntityResolver to an XML parser you use. The OpenIDE now defines a system EntityCatalog.
static Document createDocument()
          Deprecated. Replaced with XMLUtil It directly violates DOM's root element reference read-only status. If you can not move to XMLUtil for compatabilty reasons please replace with following workaround:
 String templ = "";
 InputSource in = new InputSource(new StringReader(templ));
 in.setSystemId("StringReader");  //workaround
 DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
 Document doc = builder.parse(in);
 
protected  EditorCookie createEditorCookie()
          Deprecated. CookieSet factory should be used by subclasses instead.
static InputSource createInputSource(URL url)
          Deprecated. Deprecated as it was a workaround method. Replace with new InputSource(url.toExternalForm()).
protected  Node createNodeDelegate()
          If the Info associated with this data object (if any) provides a subclass of Node, then this object is created to represent the XML data object, otherwise DataNode is created.
static Parser createParser()
          Deprecated. Use XMLUtil instead. It will create a SAX XMLReader that is SAX Parser replacement. You will have to replace DocumentHandler by ContentHandler besause XMLReader accepts just ContentHandler.

Alternatively if not interested in new callbacks defined by SAX 2.0 you can wrap returned XMLReader into XMLReaderAdapter that implements Parser.

static Parser createParser(boolean validate)
          Deprecated. Use Util instead setting ns to false. For more details see createParser
 Node.Cookie getCookie(Class cls)
          Cookies from assigned Environment are not placed into protected CookieSet and can be obtained only by invoking this method.
 Document getDocument()
          Creates w3c's document for the xml file.
 HelpCtx getHelpCtx()
          Get help context for this object.
 XMLDataObject.Info getInfo()
          Deprecated. not used anymore
static XMLDataObject.Info getRegisteredInfo(String publicId)
          Deprecated. Register via lookup
 int getStatus()
           
protected  void handleDelete()
          Delete this object (implemented by subclasses).
static Document parse(URL url)
          Deprecated. Use XMLUtil instead setting null error handler and validation to false.
static Document parse(URL url, boolean validate)
          Deprecated. Use XMLUtil instead setting null handler.
static Document parse(URL url, ErrorHandler eh)
          Deprecated. Use XMLUtil instead setting validation to false.
static Document parse(URL url, ErrorHandler eh, boolean validate)
          Deprecated. Use XMLUtil instead.
static void registerCatalogEntry(String publicId, String uri)
          Deprecated. Do not rely on global (non-modular) resolvers. Use EntityCatalog and XMLUtil instead.
static void registerCatalogEntry(String publicId, String resourceName, ClassLoader loader)
          Deprecated. Do not rely on global (non-modular) resolvers. Use EntityCatalog and XMLUtil instead.
static void registerInfo(String publicId, XMLDataObject.Info info)
          Deprecated. Register an Environment via lookup, see some details.
static EntityResolver removeEntityResolver(EntityResolver resolver)
          Deprecated. EntityResolver is a parser user responsibility.
 void setInfo(XMLDataObject.Info ii)
          Deprecated. does not do anything useful
protected  void updateIconBase(String res)
          Deprecated. it is better to listen on properties
static void write(Document doc, OutputStream out, String enc)
          Deprecated. Moved to XMLUtil.
static void write(Document doc, Writer writer)
          Deprecated. Encoding used by Writer may be in direct conflict with encoding declared in document. Replaced with Util.
 
Methods inherited from class org.openide.loaders.MultiDataObject
addSecondaryEntry, files, findSecondaryEntry, getCookieSet, getMultiFileLoader, getPrimaryEntry, handleCopy, handleCreateFromTemplate, handleMove, handleRename, isCopyAllowed, isDeleteAllowed, isMoveAllowed, isRenameAllowed, registerEntry, removeSecondaryEntry, secondaryEntries, setCookieSet, takePrimaryFileLock
 
Methods inherited from class org.openide.loaders.DataObject
addPropertyChangeListener, addVetoableChangeListener, copy, createFromTemplate, createFromTemplate, createShadow, delete, dispose, find, firePropertyChange, fireVetoableChange, getCookie, getFolder, getLoader, getName, getNodeDelegate, getPrimaryFile, getRegistry, handleCreateShadow, isModified, isShadowAllowed, isTemplate, isValid, markFiles, move, removePropertyChangeListener, removeVetoableChangeListener, rename, setModified, setTemplate, setValid, toString, writeReplace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

XMLINFO_DTD_PUBLIC_ID_FORTE

public static final String XMLINFO_DTD_PUBLIC_ID_FORTE
Deprecated. replaced with Lookup

Public ID of xmlinfo dtd.

See Also:
Constant Field Values

XMLINFO_DTD_PUBLIC_ID

public static final String XMLINFO_DTD_PUBLIC_ID
Deprecated. replaced with Lookup

See Also:
Constant Field Values

MIME

public static final String MIME
Mime type of XML documents.

See Also:
Constant Field Values

STATUS_NOT

public static final int STATUS_NOT
PROP_DOCUMENT not parsed yet. Constant for getStatus method.

See Also:
Constant Field Values

STATUS_OK

public static final int STATUS_OK
PROP_DOCUMENT parsed ok. Constant for getStatus method.

See Also:
Constant Field Values

STATUS_WARNING

public static final int STATUS_WARNING
PROP_DOCUMENT parsed with warnings. Constant for getStatus method.

See Also:
Constant Field Values

STATUS_ERROR

public static final int STATUS_ERROR
PROP_DOCUMENT parsed with errors. Constant for getStatus method.

See Also:
Constant Field Values

PROP_DOCUMENT

public static final String PROP_DOCUMENT
property name of DOM document property

See Also:
Constant Field Values

PROP_INFO

public static final String PROP_INFO
Deprecated. info is not supported anymore. Replaced with lookup.

property name of info property

See Also:
Constant Field Values
Constructor Detail

XMLDataObject

public XMLDataObject(FileObject fo,
                     MultiFileLoader loader)
              throws DataObjectExistsException
Create new XMLDataObject. It is usually called by a loader. A user can get existing XMLDataObject by calling DataObject.find(FileObject f) instead.

Parameters:
fo - the primary file object, never null
loader - loader of this data object, never null
Method Detail

createNodeDelegate

protected Node createNodeDelegate()
If the Info associated with this data object (if any) provides a subclass of Node, then this object is created to represent the XML data object, otherwise DataNode is created.

Overrides:
createNodeDelegate in class MultiDataObject
Returns:
the node representation for this data object
See Also:
DataNode

updateIconBase

protected void updateIconBase(String res)
Deprecated. it is better to listen on properties

Called when the info file is parsed and the icon should change.

Parameters:
res - resource for the icon

handleDelete

protected void handleDelete()
                     throws IOException
Description copied from class: DataObject
Delete this object (implemented by subclasses).

Overrides:
handleDelete in class MultiDataObject
Throws:
IOException

getHelpCtx

public HelpCtx getHelpCtx()
Description copied from class: DataObject
Get help context for this object.

Specified by:
getHelpCtx in interface HelpCtx.Provider
Overrides:
getHelpCtx in class MultiDataObject

getCookie

public Node.Cookie getCookie(Class cls)
Cookies from assigned Environment are not placed into protected CookieSet and can be obtained only by invoking this method.

Cookie order for Info environments are handled consistently with CookieSet i.e. FIFO.

Overrides:
getCookie in class MultiDataObject
Parameters:
cls - the class to look for
Returns:
a cookie (instanceof cls) that has been found in info or super.getCookie(cls).

createEditorCookie

protected EditorCookie createEditorCookie()
Deprecated. CookieSet factory should be used by subclasses instead.

Allows subclasses to provide their own editor cookie.

Returns:
an editor cookie to be used as a result of getCookie(EditorCookie.class)

getDocument

public final Document getDocument()
                           throws IOException,
                                  SAXException
Creates w3c's document for the xml file. Either returns cached reference or parses the file and creates new document.

Returns:
the parsed document
Throws:
SAXException - if there is a parsing error
IOException - if there is an I/O error

getStatus

public final int getStatus()
Returns:
one of STATUS_XXX constants representing PROP_DOCUMENT state.

getInfo

public final XMLDataObject.Info getInfo()
Deprecated. not used anymore

Returns:
null

setInfo

public final void setInfo(XMLDataObject.Info ii)
                   throws IOException
Deprecated. does not do anything useful

Throws:
IOException

parse

public static Document parse(URL url)
                      throws IOException,
                             SAXException
Deprecated. Use XMLUtil instead setting null error handler and validation to false.

Provides access to internal XML parser. This method takes URL. After successful finish the document tree is returned. Used non validating parser.

Parameters:
url - the url to read the file from
Throws:
IOException
SAXException

parse

public static Document parse(URL url,
                             boolean validate)
                      throws IOException,
                             SAXException
Deprecated. Use XMLUtil instead setting null handler.

Provides access to internal XML parser. This method takes URL. After successful finish the document tree is returned. Used non validating parser.

Parameters:
url - the url to read the file from
validate - if true validating parser is used
Throws:
IOException
SAXException

parse

public static Document parse(URL url,
                             ErrorHandler eh)
                      throws IOException,
                             SAXException
Deprecated. Use XMLUtil instead setting validation to false.

Provides access to internal XML parser. This method takes URL. After successful finish the document tree is returned.

Parameters:
url - the url to read the file from
eh - error handler to notify about exception
Throws:
IOException
SAXException

parse

public static Document parse(URL url,
                             ErrorHandler eh,
                             boolean validate)
                      throws IOException,
                             SAXException
Deprecated. Use XMLUtil instead.

Factory a DocumentBuilder and let it create a org.w3c.dom.Document This method takes URL. After successful finish the document tree is returned. A parser producing the Document has set entity resolver to system entity resolver chain.

Parameters:
url - the url to read the file from
eh - error handler to notify about exception
validate - if true validating parser is used
Returns:
org.w3c.dom.Document
Throws:
SAXException - annotated if thrown due to configuration problem
FactoryConfigurationError
IOException

createParser

public static Parser createParser()
Deprecated. Use XMLUtil instead. It will create a SAX XMLReader that is SAX Parser replacement. You will have to replace DocumentHandler by ContentHandler besause XMLReader accepts just ContentHandler.

Alternatively if not interested in new callbacks defined by SAX 2.0 you can wrap returned XMLReader into XMLReaderAdapter that implements Parser.

Creates SAX parse that can be used to parse XML files.

Returns:
sax parser

createParser

public static Parser createParser(boolean validate)
Deprecated. Use Util instead setting ns to false. For more details see createParser

Factory SAX parser that can be used to parse XML files. The factory is created according to javax.xml.parsers.SAXParserFactory property. The parser has set entity resolver to system entity resolver chain.

Parameters:
validate - if true validating parser is returned
Returns:
sax parser or null if no parser can be created
Throws:
FactoryConfigurationError

createDocument

public static Document createDocument()
Deprecated. Replaced with XMLUtil It directly violates DOM's root element reference read-only status. If you can not move to XMLUtil for compatabilty reasons please replace with following workaround:
 String templ = "";
 InputSource in = new InputSource(new StringReader(templ));
 in.setSystemId("StringReader");  //workaround
 DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
 Document doc = builder.parse(in);
 

Creates empty DOM Document using JAXP factoring.

Returns:
Document or null on problems with JAXP factoring

write

public static void write(Document doc,
                         Writer writer)
                  throws IOException
Deprecated. Encoding used by Writer may be in direct conflict with encoding declared in document. Replaced with Util.

Writes DOM Document to writer.

Parameters:
doc - DOM Document to be written
writer - OutoutStreamWriter preffered otherwise encoding will be left for implementation specific autodection
Throws:
IOException

write

public static void write(Document doc,
                         OutputStream out,
                         String enc)
                  throws IOException
Deprecated. Moved to XMLUtil.

Write Document into OutputStream using given encoding. It is a shortcut for writing configurations etc. It guarantee just that data will be written. Structure and indentation may change.

Parameters:
doc - DOM Document to be written
out - data sink
enc - - XML defined encoding name (i.e. IANA defined, one of UTF-8, UNICODE, ASCII).
Throws:
IOException

createInputSource

public static InputSource createInputSource(URL url)
                                     throws IOException
Deprecated. Deprecated as it was a workaround method. Replace with new InputSource(url.toExternalForm()).

Creates SAX InputSource for specified URL

Throws:
IOException

registerCatalogEntry

public static void registerCatalogEntry(String publicId,
                                        String uri)
Deprecated. Do not rely on global (non-modular) resolvers. Use EntityCatalog and XMLUtil instead.

Registers the given public ID as corresponding to a particular URI, typically a local copy. This URI will be used in preference to ones provided as system IDs in XML entity declarations. This mechanism would most typically be used for Document Type Definitions (DTDs), where the public IDs are formally managed and versioned.

Any created parser use global entity resolver and you can register its catalog entry.

Parameters:
publicId - The managed public ID being mapped
uri - The URI of the preferred copy of that entity

registerCatalogEntry

public static void registerCatalogEntry(String publicId,
                                        String resourceName,
                                        ClassLoader loader)
Deprecated. Do not rely on global (non-modular) resolvers. Use EntityCatalog and XMLUtil instead.

Registers a given public ID as corresponding to a particular Java resource in a given class loader, typically distributed with a software package. This resource will be preferred over system IDs included in XML documents. This mechanism should most typically be used for Document Type Definitions (DTDs), where the public IDs are formally managed and versioned.

If a mapping to a URI has been provided, that mapping takes precedence over this one.

Any created parser use global entity resolver and you can register its catalog entry.

Parameters:
publicId - The managed public ID being mapped
resourceName - The name of the Java resource
loader - The class loader holding the resource, or null if it is a system resource.

addEntityResolver

public static final boolean addEntityResolver(EntityResolver resolver)
Deprecated. EntityResolver is a parser user responsibility. Every time set a EntityResolver to an XML parser you use. The OpenIDE now defines a system EntityCatalog.

Add a given entity resolver to IDE resolver chain. The resolver chain is searched by private chaining resolver until some registered resolver succed.

Every created parser use global entity resolver and then chain.

Parameters:
resolver - non null resolver to be added
Returns:
true if successfully added

removeEntityResolver

public static final EntityResolver removeEntityResolver(EntityResolver resolver)
Deprecated. EntityResolver is a parser user responsibility.

Remove a given entity resolver from IDE resolver chain.

Every created parser use global entity resolver and then chain.

Parameters:
resolver - non null resolver to be removed
Returns:
removed resolver instance or null if not present

registerInfo

public static void registerInfo(String publicId,
                                XMLDataObject.Info info)
Deprecated. Register an Environment via lookup, see some details.

Registers new Info to particular XML document content type as recognized by DTD public id. The registration is valid until IDE JVM termination.

Parameters:
publicId - used as key
info - associated value or null to unregister

getRegisteredInfo

public static XMLDataObject.Info getRegisteredInfo(String publicId)
Deprecated. Register via lookup

Obtain registered Info for particular DTD public ID.

Parameters:
publicId - key which value is required
Returns:
Info clone that is used for given publicId or null

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.