sk.uniba.euromath.document.schema
Class InsertPoint

java.lang.Object
  extended by sk.uniba.euromath.document.schema.InsertPoint
All Implemented Interfaces:
Comparable

public final class InsertPoint
extends Object
implements Comparable

Defines place for inserting element into nodelist. Insertion place is specified by insertPlace and pos parameters. If insertPlace denotes Element, then new element must be inserted before this Element. In this case, the pos argument is ignored and should be set to zero. If insertPlace denotes CharacterData, then pos specifies index of character, after which new element must be inserted. Immutable, thread-safe.

Author:
Martin Vysny

Field Summary
static InsertPoint FIRST
          Insertpoint, that defines first insertion point.
 int insertPlace
          Index of node in parent parameter.
 int pos
          If insertPlace is CharacterData, then this parameter defines index of character in this CharacterData, after which to insert new element.
 
Constructor Summary
InsertPoint(int insertPlace, int pos)
          Creates instance of InsertPoint.
 
Method Summary
 int compareTo(Object obj)
           
 boolean equals(Object obj)
           
static InsertPoint getLast(Element e)
          Returns an insertpoint pointing after the last child node of e.
 int hashCode()
           
 boolean isValid(NodeList list, boolean mustPointToNode, boolean mayPointAfterLastChar)
          Checks, whether this insertpoint is valid in given element.
 String toString()
          Converts insertpoint object to a string using syntax: [insertPlace,pos].
static InsertPoint valueOf(String string)
          Parses given string and returns an insert point instance.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

insertPlace

public final int insertPlace
Index of node in parent parameter. Defines place, where we want to insert new element. When 0, try to insert before first node. Must not be negative.


pos

public final int pos
If insertPlace is CharacterData, then this parameter defines index of character in this CharacterData, after which to insert new element. This value must not be negative.


FIRST

public static final InsertPoint FIRST
Insertpoint, that defines first insertion point. Node inserted at this point will be first in sequence of nodes.

Constructor Detail

InsertPoint

public InsertPoint(int insertPlace,
                   int pos)
Creates instance of InsertPoint.

Parameters:
insertPlace - index of node in parent parameter. Defines place, where we want to insert new element. When 0, try to insert before first node. Must not be negative.
pos - if insertPlace is CharacterData, then this parameter defines index of character in this CharacterData, after which to insert new element. This value must not be negative.
Method Detail

getLast

public static InsertPoint getLast(Element e)
Returns an insertpoint pointing after the last child node of e.

Parameters:
e - the element.
Returns:
last insertpoint.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

toString

public String toString()
Converts insertpoint object to a string using syntax: [insertPlace,pos].

Overrides:
toString in class Object

valueOf

public static InsertPoint valueOf(String string)
Parses given string and returns an insert point instance.

Parameters:
string - string in form of [insertPlace,pos]
Returns:
insert point instance represented by the string.

isValid

public boolean isValid(NodeList list,
                       boolean mustPointToNode,
                       boolean mayPointAfterLastChar)
Checks, whether this insertpoint is valid in given element. Valid insertpoint must point inside a text, to a node, or at the end of the nodelist.

Parameters:
list - children of the context element.
mustPointToNode - if insertpoint is valid when it points to the end of the nodelist - if true then it must not point after last node.
mayPointAfterLastChar - if true then the point is valid even if it points after the last char in the character node.
Returns:
true if insert point is valid, false otherwise.


Copyright 2003-2003-2006 null. All Rights Reserved.