info.informatica.doc
Class DocumentFragment

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

public abstract class DocumentFragment
extends Object
implements Comparable<DocumentFragment>

DocumentFragment.

Version:
1.02
Author:
amengual at informatica dot info

Nested Class Summary
static class DocumentFragment.FragmentComp
           
static class DocumentFragment.NotFragmentComp
           
 
Constructor Summary
DocumentFragment(DocumentFragment df)
          Copy constructor.
DocumentFragment(FragmentPosition pos)
           
 
Method Summary
 FragmentPosition adjustWidth()
          Updates the width of this DocumentFragment by computing its length.
 int compareTo(DocumentFragment o)
           
 FragmentPosition getCurrentPosition()
          Gets the current fragment position.
 FragmentPosition getPosition()
          Gets the fragment position.
abstract  int length()
          Gets the length of this fragment.
 void setPosition(FragmentPosition pos)
          Sets the fragment position.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DocumentFragment

public DocumentFragment(FragmentPosition pos)

DocumentFragment

public DocumentFragment(DocumentFragment df)
Copy constructor.

Method Detail

getPosition

public FragmentPosition getPosition()
Gets the fragment position.

It is the position set when the fragment was created, or when it was adjusted with adjustWidth the last time.

If you need the Position computed for the current fragment size, use getCurrentPosition.

In the case of a Tag, the position is always the position of the starting tag, and not the whole block "start + data + close".

Returns:
the element position.
See Also:
getCurrentPosition()

getCurrentPosition

public FragmentPosition getCurrentPosition()
Gets the current fragment position.

Calling this method does not modify its original Position, i.e. this method does not call adjustWidth.

In the case of a Tag, the position is always the position of the starting tag, and not the whole block "start + data + close".

Returns:
the current element position.

setPosition

public void setPosition(FragmentPosition pos)
Sets the fragment position.

Parameters:
pos - the new fragment position.

adjustWidth

public FragmentPosition adjustWidth()
Updates the width of this DocumentFragment by computing its length.

Most fragment manipulations will change the length of this DocumentFragment, but to save time its FragmentPosition is not updated each time.

This method is provided to adjust the FragmentPosition of this fragment whenever needed.

Returns:
the updated position of this fragment.

compareTo

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

length

public abstract int length()
Gets the length of this fragment.

Returns:
the length of this fragment at the present moment.