Package components.xmltree
Class XMLTree1
java.lang.Object
components.xmltree.XMLTreeSecondary
components.xmltree.XMLTree1
- All Implemented Interfaces:
XMLTree
XMLTree
represented as a recursive data structure, done
"bare-handed", with implementations of all methods.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturns anIterable<String>
of the attribute names of the root ofthis
.final String
attributeValue
(String name) Returns the value associated with the attribute of the root tag ofthis
calledname
.final XMLTree
child
(int k) Returns thek
-th subtree of the root ofthis
.final void
display()
Displaysthis
in a new window with a default title.final void
Displaysthis
in a new window with the giventitle
.final boolean
hasAttribute
(String name) Returns whether the root tag ofthis
has an attribute calledname
.final boolean
isTag()
Returns whether the label of the root ofthis
is a tag.final String
label()
Returns the label of the root ofthis
.final int
Returns the number of subtrees of the root ofthis
.Methods inherited from class components.xmltree.XMLTreeSecondary
equals, hashCode, toString
-
Constructor Details
-
XMLTree1
Constructs anXMLTree
from inputsource
(could be a file or a URL). Leading and trailing whitespace is trimmed from text nodes.- Parameters:
source
- XML input- Requires:
source is the name of a file or a URL
- Ensures:
this = [the XMLTree corresponding to the given input source, with whitespace trimmed]
-
XMLTree1
Constructs anXMLTree
from inputsource
(could be a file or a URL).- Parameters:
source
- XML inputtrimWhitespace
- flag to indicate whether leading and trailing whitespace should be trimmed from text nodes- Requires:
source is the name of a file or a URL
- Ensures:
this = [the XMLTree corresponding to the given input source, with whitespace trimmed only if trimWhitespace]
-
-
Method Details
-
label
Description copied from interface:XMLTree
Returns the label of the root ofthis
.- Returns:
- the label of the root of
this
-
isTag
Description copied from interface:XMLTree
Returns whether the label of the root ofthis
is a tag.- Returns:
- true iff the label of the root of
this
is a tag
-
hasAttribute
Description copied from interface:XMLTree
Returns whether the root tag ofthis
has an attribute calledname
.- Parameters:
name
- the name of the possible attribute- Returns:
- true iff the root tag of
this
has an attribute calledname
-
attributeValue
Description copied from interface:XMLTree
Returns the value associated with the attribute of the root tag ofthis
calledname
.- Parameters:
name
- the name of the attribute- Returns:
- the value associated to attribute
name
of the root tag ofthis
-
numberOfChildren
Description copied from interface:XMLTree
Returns the number of subtrees of the root ofthis
.- Returns:
- the number of subtrees of the root of
this
-
child
Description copied from interface:XMLTree
Returns thek
-th subtree of the root ofthis
.- Parameters:
k
- the subtree to return- Returns:
- the
k
-th subtree of the root ofthis
-
attributeNames
Description copied from interface:XMLTree
Returns anIterable<String>
of the attribute names of the root ofthis
.- Returns:
- an
Iterable<String>
of the attribute names of the root ofthis
-
display
Description copied from interface:XMLTree
Displaysthis
in a new window with a default title. -
display
Description copied from interface:XMLTree
Displaysthis
in a new window with the giventitle
.- Parameters:
title
- the window title
-