|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.datanode.nodes.XMLDocument
public class XMLDocument
Holds a DataSource which is known to contain an XML document. DataNode implementations can provide constructors which take one of these. The idea is that the node building machinery finds out whether a DataSource represents XML (perhaps by doing a SAX parse) and stashes some basic information about it in this object - name of top-level element, IDs of the DTD, maybe a set of validation errors etc - so that the quick view can display them without any further work. It deliberately doesn't store the DOM, since keeping DOMs for all the nodes we've encountered can take up too much memory - it violates DataNode's rule about allocating large memory resources in a node's constructor before getChildren or maybe configureDetail have been called. DataNode constructors which do operate on an XMLDocument should not construct and cache a DOM themselves, though other DataNode methods may do so.
Field Summary | |
---|---|
static String[] |
ENCODINGS
|
static String[] |
MAGICS
|
Constructor Summary | |
---|---|
XMLDocument(DataSource datsrc)
Constructs a new XMLDocument from a DataSource. |
Method Summary | |
---|---|
DOMSource |
constructDOM(boolean validate)
Convenience method to get a DOM from this document, which either succeeds or throws a NoSuchDataException. |
DataSource |
getDataSource()
|
static String |
getEncoding(byte[] magic)
Returns what appears to be the encoding of the XML stream which starts with a given magic number. |
List |
getMessages()
|
String |
getName()
|
Collection |
getNamespaces()
|
String |
getPublicId()
|
String |
getSystemId()
|
Attributes |
getTopAttributes()
|
String |
getTopLocalName()
|
String |
getTopNamespaceURI()
|
static boolean |
isMagic(byte[] magic)
This tests for the likely start of an XML file. |
DOMSource |
parseToDOM(boolean validate,
ErrorHandler ehandler)
Performs a parse on the data source represented by this object and returns the resulting DOM. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String[] MAGICS
public static final String[] ENCODINGS
Constructor Detail |
---|
public XMLDocument(DataSource datsrc) throws NoSuchDataException
datsrc
- data source
NoSuchDataException
- if datsrc doesn't contain XMLMethod Detail |
---|
public DataSource getDataSource()
public String getTopLocalName()
public String getTopNamespaceURI()
public Attributes getTopAttributes()
public Collection getNamespaces()
public List getMessages()
public String getSystemId()
public String getPublicId()
public String getName()
public DOMSource parseToDOM(boolean validate, ErrorHandler ehandler) throws SAXException, IOException
validate
- whether the parse should be validatingehandler
- handler for parse errors (may be null)
SAXException
IOException
public DOMSource constructDOM(boolean validate) throws NoSuchDataException
NoSuchDataException
public static boolean isMagic(byte[] magic)
magic
- buffer containing the first few bytes of the stream
public static String getEncoding(byte[] magic)
MAGICS
). The result will be one of the
encoding names listed in ENCODINGS
, or null if
it doesn't look like the start of an XML stream in any of these
encodings.
magic
- buffer containing the first few bytes of the stream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |