public final class ClipboardFormat extends Object
Modifier and Type | Field and Description |
---|---|
static Namespace |
CLIPBOARD_NAMESPACE
Namespace of the wrapper element used to to wrap multiple XML nodes
when these nodes are copied to the clipboard.
|
static Name |
ENVELOPE_NAME
Name of the wrapper element used to wrap multiple XML nodes when
these nodes are copied to the clipboard.
|
static Name[] |
INCLUSION_PROPERTIES
An array containing the names of all the properties added to a node
having an inclusion property:
Constants.INCLUSION_PROPERTY ,
Constants.SOURCE_URL_PROPERTY ,
Constants.READ_ONLY_PROPERTY . |
static Name |
TEXT_PLACEHOLDER_NAME
Name of the element used to represent an empty text node.
|
Modifier and Type | Method and Description |
---|---|
static Node[] |
checkForFormat(Node[] nodes,
int nodeCount)
Checks specified node array prior to using
format(com.xmlmind.xml.doc.Node[], int, com.xmlmind.xml.name.PrefixEntry[], boolean) . |
static Node[] |
docToNodes(Document doc)
Convert specified document containing XML data in clipboard format
to a sequence of Nodes.
|
static String |
format(Node[] nodes,
int nodeCount,
PrefixEntry[] prefixes,
boolean preserveInclusions)
Converts specified nodes to a string which may be copied to the
clipboard.
|
static Node[] |
parse(File file)
Equivalent to
parse(FileUtil.fileToURL(file)) . |
static Node[] |
parse(InputSource source)
Parses the contents of specified source and returns parsed nodes.
|
static Node[] |
parse(String string)
Parses specified string and returns parsed nodes.
|
static Node[] |
parse(URL url)
Parses the contents of specified file and returns parsed nodes.
|
public static final Namespace CLIPBOARD_NAMESPACE
public static final Name ENVELOPE_NAME
public static final Name TEXT_PLACEHOLDER_NAME
This element is useful when a included element is to be formatted.
When such an element is then pasted in a document (after reparsing
it using parse(String)
, we cannot normalize
ignoreable whitespace as we do it for non-included elements
(because an included element is marked read-only).
public static final Name[] INCLUSION_PROPERTIES
Constants.INCLUSION_PROPERTY
,
Constants.SOURCE_URL_PROPERTY
,
Constants.READ_ONLY_PROPERTY
.public static Node[] parse(String string)
string
- the string to be parsed.
This string is expected to start with "<?xml ".
Moreover, this string is expected to contain XML data in clipboard format.
null
if specified string cannot be
parsed as XML.public static Node[] parse(File file) throws IOException
parse(FileUtil.fileToURL(file))
.IOException
public static Node[] parse(URL url) throws IOException
url
- URL of the file to be parsed.
This file is expected to contain XML data in clipboard format.
null
if the contents of specified
file cannot be parsed as XML.IOException
- if an I/O error occurs during this operationpublic static Node[] parse(InputSource source)
source
- the XML source.
This source is expected to contain XML data in clipboard format.
null
if the contents of
specified source cannot be parsed as XML.public static Node[] docToNodes(Document doc)
ENVELOPE_NAME
as its name, this method returns
the child nodes of the root element in an array.
In both cases, nested ENVELOPE_NAME
elements
are automatically removed and replaced by their child nodes.
Note that each element contained in the returned array may be given
a Constants.DECLARED_PREFIXES_PROPERTY
property.
public static String format(Node[] nodes, int nodeCount, PrefixEntry[] prefixes, boolean preserveInclusions)
nodes
- the nodes to be formattednodeCount
- the number of nodes available in nodesprefixes
- specifies which prefixes to use for the
namespaces of elements contained in nodes. May be
null
, in which case automatically generated prefixes
ns, ns2, ns3, etc, are used.preserveInclusions
- specifies whether inclusions should be
preservedcheckForFormat(com.xmlmind.xml.doc.Node[], int)
public static Node[] checkForFormat(Node[] nodes, int nodeCount)
format(com.xmlmind.xml.doc.Node[], int, com.xmlmind.xml.name.PrefixEntry[], boolean)
.nodes
- node array to be checkednodeCount
- number of nodes in nodesThe latter case occurs when nodes does not specify a node range (for example, because specified nodes are not siblings or simply because they are not yet attached to the document tree) or when specified node range does not contain one or more inclusions as a whole.