Class SimpleElementFacade
- All Implemented Interfaces:
IElementFacade
An instance of this class may be used to apply a namespace prefix to the name of a JSON-XML element and to the names of attributes of a JSON-XML element.
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleElementFacade
(String documentElementName) Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element.SimpleElementFacade
(String namespaceUri, String namespacePrefix, String documentElementName) Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element.SimpleElementFacade
(String namespaceUri, String namespacePrefix, Document document) Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element.SimpleElementFacade
(Document document) Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element. -
Method Summary
Modifier and TypeMethodDescriptionstatic Document
createDocument
(String namespaceUri, String documentElementName) Creates and returns a new instance of a XML document whose document element has the specified namespace URI and the specified qualified name.createElement
(String name) Creates and returns a new instance of a JSON-XML element whose name is the specified name or is derived from it in some way (for example, by applying a namespace prefix to it).getAttribute
(Element element, String name) Returns the value of a named attribute of the specified element.Returns the XML document that is associated with the elements and attributes that are created by the methods of this facade.void
setAttribute
(Element element, String name, String value) Sets the value of a named attribute of the specified element.
-
Constructor Details
-
SimpleElementFacade
Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element. No namespace URI is associated with the JSON-XML elements and attributes.The JSON-XML elements and attributes are associated with an XML document that is created by this constructor. The document element of the document has no namespace URI and the specified qualified name.
- Parameters:
documentElementName
- the qualified name of the document element of the XML document that is created.- Throws:
BaseException
- if an error occurs when creating the XML document.
-
SimpleElementFacade
public SimpleElementFacade(String namespaceUri, String namespacePrefix, String documentElementName) throws BaseException Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element. The specified namespace URI is associated with the JSON-XML elements and attributes, and the specified namespace prefix is applied to the names of the JSON-XML elements and attributes.The JSON-XML elements and attributes are associated with an XML document that is created by this constructor. The document element of the document has the specified namespace URI and the specified qualified name.
- Parameters:
namespaceUri
- the namespace URI that will be associated with JSON-XML elements and attributes. It will also be set on the document element of the XML document that is created.namespacePrefix
- the namespace prefix that will be applied to the names of JSON-XML elements and attributes. If the prefix isnull
or empty or it contains only whitespace characters, no prefix will be applied.documentElementName
- the qualified name of the document element of the XML document that is created.- Throws:
BaseException
- if an error occurs when creating the XML document.IllegalArgumentException
- if-
documentElementName
isnull
, or -
namespaceUri
isnull
andnamespacePrefix
is notnull
andnamespacePrefix
is not empty andnamespacePrefix
does not contain only whitespace, or -
namespaceUri
is notnull
and any of the following istrue
:-
namespacePrefix
isnull
, -
namespacePrefix
is empty, -
namespacePrefix
contains only whitespace characters.
-
-
-
SimpleElementFacade
Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element. No namespace URI is associated with the JSON-XML elements and attributes.The JSON-XML elements and attributes are associated with the specified XML document.
- Parameters:
document
- the XML document with which JSON-XML elements and attributes will be associated.
-
SimpleElementFacade
Creates a new instance of a facade that provides methods for creating a JSON-XML element and accessing the attributes of a JSON-XML element. The specified namespace URI is associated with the JSON-XML elements and attributes, and the specified namespace prefix is applied to the names of the JSON-XML elements and attributes.The JSON-XML elements and attributes are associated with the specified XML document.
- Parameters:
namespaceUri
- the namespace URI that will be associated with JSON-XML elements and attributes.namespacePrefix
- the namespace prefix that will be applied to the names of JSON-XML elements and attributes. If the prefix isnull
or empty or it contains only whitespace characters, no prefix will be applied.document
- the XML document with which JSON-XML elements and attributes will be associated.- Throws:
IllegalArgumentException
- if-
document
isnull
, or -
namespaceUri
isnull
andnamespacePrefix
is notnull
andnamespacePrefix
is not empty andnamespacePrefix
does not contain only whitespace, or -
namespaceUri
is notnull
and any of the following istrue
:-
namespacePrefix
isnull
, -
namespacePrefix
is empty, -
namespacePrefix
contains only whitespace characters.
-
-
-
-
Method Details
-
createDocument
public static Document createDocument(String namespaceUri, String documentElementName) throws BaseException Creates and returns a new instance of a XML document whose document element has the specified namespace URI and the specified qualified name.- Parameters:
namespaceUri
- the namespace URI of the document element of the XML document, which may benull
.documentElementName
- the qualified name of the document element of the XML document, which may benull
.- Returns:
- a new instance of a XML document. The namespace URI of the document element is
namespaceUri
and the qualified name of the document element isdocumentElementName
. - Throws:
BaseException
- if an error occurs when creating the XML document.
-
createElement
Creates and returns a new instance of a JSON-XML element whose name is the specified name or is derived from it in some way (for example, by applying a namespace prefix to it).- Specified by:
createElement
in interfaceIElementFacade
- Parameters:
name
- the name from which the name of the new JSON-XML element will be derived.- Returns:
- a new instance of a JSON-XML element whose name is derived from
name
.
-
getAttribute
Returns the value of a named attribute of the specified element. The name of the attribute is the specified name or is derived from it in some way (for example, by applying a namespace prefix to it).- Specified by:
getAttribute
in interfaceIElementFacade
- Parameters:
element
- the JSON-XML element whose specified attribute is of interest.name
- the name from which the name of the target attribute will be derived.- Returns:
- the value of the attribute of
element
whose name is derived fromname
.
-
setAttribute
Sets the value of a named attribute of the specified element. The name of the attribute is the specified name or is derived from it in some way (for example, by applying a namespace prefix to it).- Specified by:
setAttribute
in interfaceIElementFacade
- Parameters:
element
- the JSON-XML element whose specified attribute is of interest.name
- the name from which the name of the target attribute will be derived.value
- the value to which the target attribute will be set.
-
getDocument
Returns the XML document that is associated with the elements and attributes that are created by the methods of this facade.- Returns:
- the XML document that is associated with the elements and attributes that are created by the methods of this facade.
-