de.fu_berlin.ties.xml
Class OpenTags

java.lang.Object
  extended by de.fu_berlin.ties.xml.TagContainer
      extended by de.fu_berlin.ties.xml.OpenTags

public class OpenTags
extends TagContainer

A container used to manage the currently open start tags during XML adjustment. Adds stack-like push and pop functionality to the superclass and allows checking specifically for tentative tag.

Version:
$Revision: 1.3 $, $Date: 2004/08/23 17:11:06 $, $Author: siefkes $
Author:
Christian Siefkes

Field Summary
protected static Object DUMMY
          A dummy object stored as map value where no value is required.
 
Constructor Summary
OpenTags()
          Creates a new instance.
 
Method Summary
 boolean containsNonTentative(String tagname)
          Checks whether this instance contains at least one appearance of the specified tag that is not TagVariety.TENTATIVE.
 TagConstituent findTentativeTag(String tagname)
          Finds a tentative appearance of a tag, if any exists.
 boolean isRoot(TagConstituent tag)
          Checks whether a tag is the root tag (the first tag inserted into this container).
 TagConstituent peek()
          Returns the last tag appearance that was pushed into this container.
protected  TagConstituent peekFirst()
          Returns the first tag appearance that was initially pushed into this container.
 TagConstituent pop()
          Removes and returns the last tag appearance that was pushed into this container.
 boolean popAndRegularize()
          Removes and returns the last tag appearance that was pushed into this container.
 void push(TagConstituent tag, boolean appendAtEnd)
          Inserts an appearance of a tag into the container.
 boolean remove(TagConstituent tag)
          Removes a single appearance of a tag from the container.
 
Methods inherited from class de.fu_berlin.ties.xml.TagContainer
contains, findFirst, findInSeries, forceRemove, getTagMap, isEmpty, push, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DUMMY

protected static final Object DUMMY
A dummy object stored as map value where no value is required.

Constructor Detail

OpenTags

public OpenTags()
Creates a new instance.

Method Detail

containsNonTentative

public boolean containsNonTentative(String tagname)
Checks whether this instance contains at least one appearance of the specified tag that is not TagVariety.TENTATIVE.

Parameters:
tagname - the name of the tag to check
Returns:
true iff the container contains one or more non-tenatative (at insertion time) appearances of the specified tag

findTentativeTag

public TagConstituent findTentativeTag(String tagname)
Finds a tentative appearance of a tag, if any exists. If several tentative appearances exist, the last of them is returned.

Parameters:
tagname - the name of the tag to check
Returns:
the found apearance of the tag, or null if no matching appearance was found

isRoot

public boolean isRoot(TagConstituent tag)
Checks whether a tag is the root tag (the first tag inserted into this container).

Parameters:
tag - the tag to check
Returns:
true if the tag is the root tag

peekFirst

protected TagConstituent peekFirst()
Returns the first tag appearance that was initially pushed into this container.

Returns:
the first undeleted tag pushed into this container, or null if the container is empty

peek

public TagConstituent peek()
Returns the last tag appearance that was pushed into this container.

Returns:
the last undeleted tag pushed into this container, or null if the container is empty

pop

public TagConstituent pop()
                   throws NullPointerException
Removes and returns the last tag appearance that was pushed into this container.

Returns:
the removed tag
Throws:
NullPointerException - if the container is empty (i.e. a call to peek() would return null)

popAndRegularize

public boolean popAndRegularize()
                         throws NullPointerException
Removes and returns the last tag appearance that was pushed into this container. The variety of the removed tag is set to TagVariety.REGULAR (independently of its previous value).

Returns:
true if the tag was irregular and thus had to be regularized; false if it was a regular tag
Throws:
NullPointerException - if the container is empty (i.e. a call to peek() would return null)

push

public void push(TagConstituent tag,
                 boolean appendAtEnd)
          throws IllegalArgumentException,
                 UnsupportedOperationException
Inserts an appearance of a tag into the container. The name of the tag is used as key; the whole constituent is appended to the list of appearances stored for this tag name. This implementation doesn't support inserting at the begin of af the list because it would hinder the stack operations. Instances of this class accept only start tags.

Overrides:
push in class TagContainer
Parameters:
tag - the tag to insert
appendAtEnd - must always be true
Throws:
IllegalArgumentException - if the specified tag is not a start tag
UnsupportedOperationException - if appendAtEnd is false (prepending is not supported)

remove

public boolean remove(TagConstituent tag)
Removes a single appearance of a tag from the container.

Overrides:
remove in class TagContainer
Parameters:
tag - the tag to remove
Returns:
true if the specified TagConstituent was removed successfully; false otherwise (the specified constituent wasn't found in the container)


Copyright © 2003-2004 Christian Siefkes. All Rights Reserved.