info.informatica.doc
Class FragmentPosition

java.lang.Object
  extended by info.informatica.doc.FragmentPosition
All Implemented Interfaces:
Comparable<FragmentPosition>

public class FragmentPosition
extends Object
implements Comparable<FragmentPosition>

Position of an fragment in a document.

Version:
1.03
Author:
amengual at informatica dot info

Nested Class Summary
static class FragmentPosition.FragmentPositionComp
           
static class FragmentPosition.NotFragmentPositionComp
           
 
Field Summary
 int ini
          index of Element start position.
 
Constructor Summary
FragmentPosition()
          Constructor.
FragmentPosition(FragmentPosition pos)
          Copy constructor.
FragmentPosition(int ini, int size)
          Constructor.
 
Method Summary
 int compareTo(FragmentPosition o)
           
static FragmentPosition enclosed(FragmentPosition start_tag, FragmentPosition close_tag)
          Computes the Position of the element enclosed by two Positions.
 boolean equals(Object obj)
           
 int getEnd()
           
 int getStart()
           
 int hashCode()
           
static FragmentPosition merge(FragmentPosition start_tag, FragmentPosition close_tag)
          Computes the Position of the element resulting from the merge of other two.
 void set(FragmentPosition pos)
          Similar to copy constructor.
 void setEnd(int post_end)
           
 void shift(int offset)
          Shifts the position by offset.
 int size()
          Gets the size of the current fragment.
 String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ini

public int ini
index of Element start position.

Constructor Detail

FragmentPosition

public FragmentPosition()
Constructor.

Builds a fragment position starting at index zero, and of size zero.


FragmentPosition

public FragmentPosition(int ini,
                        int size)
Constructor.

Parameters:
ini - the start index of the fragment.
size - the size of the fragment.

FragmentPosition

public FragmentPosition(FragmentPosition pos)
Copy constructor.

Parameters:
pos - the FragmentPosition object to be copied.
Method Detail

getStart

public final int getStart()

getEnd

public final int getEnd()

setEnd

public void setEnd(int post_end)

size

public final int size()
Gets the size of the current fragment.

Returns:
the fragment size.

set

public void set(FragmentPosition pos)
Similar to copy constructor.

Parameters:
pos - the FragmentPosition object to be copied.

shift

public void shift(int offset)
Shifts the position by offset.

Parameters:
offset - the offset to shift the position forward.

enclosed

public static FragmentPosition enclosed(FragmentPosition start_tag,
                                        FragmentPosition close_tag)
                                 throws DocumentException
Computes the Position of the element enclosed by two Positions.

Parameters:
start_tag - the Position of the opening tag.
close_tag - the Position of the closing tag.
Returns:
the FragmentPosition of the element enclosed by the two given positions, or null if no element is enclosed.
Throws:
HTMLDocumentException - if the enclosing positions are inconsistent (e.g. enclosing tags overlap or are inverted).
DocumentException

merge

public static FragmentPosition merge(FragmentPosition start_tag,
                                     FragmentPosition close_tag)
                              throws DocumentException
Computes the Position of the element resulting from the merge of other two.

Parameters:
start_tag - the Position of the opening tag.
close_tag - the Position of the closing tag.
Returns:
the FragmentPosition of the element resulting from merging the two given positions.
Throws:
HTMLDocumentException - if the given positions are inconsistent (e.g. enclosing tags overlap or are inverted).
DocumentException

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

compareTo

public int compareTo(FragmentPosition o)
Specified by:
compareTo in interface Comparable<FragmentPosition>