Package components.xmltree
Class XMLTree2
java.lang.Object
components.xmltree.XMLTreeSecondary
components.xmltree.XMLTree2
- All Implemented Interfaces:
XMLTree
XMLTree represented as a Tree, with implementations of all
methods.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns anIterable<String>of the attribute names of the root ofthis.final StringattributeValue(String name) Returns the value associated with the attribute of the root tag ofthiscalledname.final XMLTreechild(int k) Returns thek-th subtree of the root ofthis.final voiddisplay()Displaysthisin a new window with a default title.final voidDisplaysthisin a new window with the giventitle.final booleanhasAttribute(String name) Returns whether the root tag ofthishas an attribute calledname.final booleanisTag()Returns whether the label of the root ofthisis a tag.final Stringlabel()Returns the label of the root ofthis.final intReturns the number of subtrees of the root ofthis.Methods inherited from class components.xmltree.XMLTreeSecondary
equals, hashCode, toString
-
Constructor Details
-
XMLTree2
Constructs anXMLTreefrom 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]
-
XMLTree2
Constructs anXMLTreefrom 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:XMLTreeReturns the label of the root ofthis.- Returns:
- the label of the root of
this
-
isTag
Description copied from interface:XMLTreeReturns whether the label of the root ofthisis a tag.- Returns:
- true iff the label of the root of
thisis a tag
-
hasAttribute
Description copied from interface:XMLTreeReturns whether the root tag ofthishas an attribute calledname.- Parameters:
name- the name of the possible attribute- Returns:
- true iff the root tag of
thishas an attribute calledname
-
attributeValue
Description copied from interface:XMLTreeReturns the value associated with the attribute of the root tag ofthiscalledname.- Parameters:
name- the name of the attribute- Returns:
- the value associated to attribute
nameof the root tag ofthis
-
numberOfChildren
Description copied from interface:XMLTreeReturns the number of subtrees of the root ofthis.- Returns:
- the number of subtrees of the root of
this
-
child
Description copied from interface:XMLTreeReturns 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:XMLTreeReturns 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:XMLTreeDisplaysthisin a new window with a default title. -
display
Description copied from interface:XMLTreeDisplaysthisin a new window with the giventitle.- Parameters:
title- the window title
-