public class VOElementFactory extends Object
Element
or from some non-DOM source such
as a file, input stream, or SAX stream.
In the latter case a DOM is built using the
transformToDOM(javax.xml.transform.Source,boolean)
method with no validation. There are several optimisations performed
by this method which distinguish it from a DOM that you'd get
if you constructed it directly; the most important ones are that
the data-bearing parts (children of STREAM or TABLEDATA elements)
of the XML document are not included in the built DOM, and that
any reference to the VOTable DTD is resolved locally rather than
making a potential network connection. You almost certainly don't
need to worry about this; however if for some reason you want to
work on a 'normal' DOM, or if you want validation, you can construct
the DOM yourself and invoke one of the non-transforming
makeVOElement
methods on the result.
The various makeVOElement
methods may return an object of class
VOElement
or of one of its subclasses, according to the
name of the element in question; specific subclasses are provided only
where some extra functionality is available, for instance the
TableElement.getData()
method of the TableElement
class.
One upshot of this is that a tree of VOElements need not conform to
the VOTable DTD, elements of any name may be in it. Wherever an
element has a name which matches an element with specific significance
in a VOTable document however, such as "TABLE", it is handled
accordingly.
Modifier and Type | Field and Description |
---|---|
static boolean |
STRICT_DEFAULT
Determines whether the default strictness state is true or false
when the
STRICT_PROPERTY property has not been set. |
static String |
STRICT_PROPERTY
Property which determines the default strictness state.
|
Constructor and Description |
---|
VOElementFactory()
Constructs a new VOElementFactory with the default storage policy.
|
VOElementFactory(StoragePolicy policy)
Constructs a new VOElementFactory with a given storage policy.
|
Modifier and Type | Method and Description |
---|---|
StoragePolicy |
getStoragePolicy()
Returns the storage policy currently in effect.
|
boolean |
isStrict()
Indicates whether a strict reading of the VOTable standard is
in effect.
|
static boolean |
isStrictByDefault()
Indicates whether strict interpretation of the VOTable standard is
on by default (if it has not been set explicitly).
|
VOElement |
makeVOElement(DataSource datsrc)
Builds a custom DOM read from a DataSource and returns a new VOElement
based on its top-level element.
|
VOElement |
makeVOElement(Document doc,
String systemId)
Returns a new VOElement based on a DOM Document node.
|
VOElement |
makeVOElement(DOMSource dsrc)
Returns a VOElement based on a DOM source.
|
VOElement |
makeVOElement(Element el,
String systemId)
Returns a VOElement based on a given DOM element.
|
VOElement |
makeVOElement(File file)
Builds a custom DOM read from a file and returns a new VOElement
based on its top-level element.
|
VOElement |
makeVOElement(InputStream strm,
String systemId)
Builds a custom DOM from an input stream and returns a new VOElement
based on its top-level element.
|
VOElement |
makeVOElement(Source xsrc)
Returns a VOElement based on an XML Source.
|
VOElement |
makeVOElement(String uri)
Builds a custom DOM read from a URI and returns a new VOElement
based on its top-level element.
|
VOElement |
makeVOElement(URL url)
Builds a custom DOM read from a URL and returns a new VOElement
based on its top-level element.
|
void |
setStoragePolicy(StoragePolicy policy)
Sets the storage policy.
|
void |
setStrict(boolean strict)
Determines whether a strict reading of the VOTable standard will be
enforced.
|
DOMSource |
transformToDOM(Source xsrc,
boolean validate)
Gets a custom DOMSource from a generic XML Source.
|
public static final String STRICT_PROPERTY
STRICT_DEFAULT
. The return value of the
isStrict()
method will be set like this unless strictness
is set explicitly.setStrict(boolean)
,
Constant Field Valuespublic static boolean STRICT_DEFAULT
STRICT_PROPERTY
property has not been set.
True by default.public VOElementFactory(StoragePolicy policy)
policy
- storage policypublic VOElementFactory()
StoragePolicy.getDefaultPolicy()
public StoragePolicy getStoragePolicy()
public void setStoragePolicy(StoragePolicy policy)
policy
- new storage policypublic VOElement makeVOElement(Element el, String systemId)
el
is already a VOElement, it is just returned.el
- DOM element on which the new object will be basedsystemId
- the location of the documentpublic VOElement makeVOElement(Document doc, String systemId)
doc
- DOM document nodesystemId
- the location of the documentdoc
public VOElement makeVOElement(DOMSource dsrc)
dsrc
- DOM source representing an Element or Document nodedsrc
public VOElement makeVOElement(Source xsrc) throws SAXException, IOException
xsrc
- the XML source representing the elementxsrc
SAXException
- if xsrc
is not a DOM source
and there is a parse error transforming it to a DOMIOException
- if xsrc
is not a DOM source
and there is an I/O error transforming to a DOMpublic VOElement makeVOElement(InputStream strm, String systemId) throws SAXException, IOException
strm
- stream containing XML datasystemId
- the location of the documentSAXException
IOException
public VOElement makeVOElement(String uri) throws SAXException, IOException
uri
- location of the documentSAXException
IOException
public VOElement makeVOElement(URL url) throws SAXException, IOException
url
- location of the documentSAXException
IOException
public VOElement makeVOElement(File file) throws SAXException, IOException
file
- file containing XML documentSAXException
IOException
public VOElement makeVOElement(DataSource datsrc) throws SAXException, IOException
datsrc
- data source containing XMLSAXException
IOException
public DOMSource transformToDOM(Source xsrc, boolean validate) throws SAXException, IOException
VOElement
or one of its specialist subclasses.
The clever bit is that during the parse (if xsrc
is not already a DOMSource) it intercepts SAX events
which indicate the start and end of any DATA events it finds so
that they are not incorporated as part of the DOM.
Such elements it parses
directly on the basis of what it knows about items that crop up
in VOTables. This keeps the resulting DOM to a reasonable size.
xsrc
- input XML sourcevalidate
- whether to use a validating parser if the
transformation needs to be done (that is, if xsrc
is not already a DOMSource)xsrc
The DOMSource's node will be either a VOElement or a VODocumentSAXException
IOException
public void setStrict(boolean strict)
FIELD
or PARAM
element with
a datatype
attribute of "char
" or
"unicodeChar
" but no arraysize
attribute will be assumed to represent a character array
(arraysize="*"
)
rather than a single-character value.strict
- true iff you want a strict reading of the VOTable
standardisStrict()
,
STRICT_PROPERTY
public boolean isStrict()
isStrictByDefault()
.setStrict(boolean)
public static boolean isStrictByDefault()
STRICT_PROPERTY
, or of STRICT_DEFAULT
if that is not set.setStrict(boolean)
Copyright © 2025 Central Laboratory of the Research Councils. All Rights Reserved.