sk.uniba.euromath.editor.textEditor
Class TextPieceContainer

java.lang.Object
  extended by sk.uniba.euromath.editor.textEditor.TextPieceContainer
All Implemented Interfaces:
ITextPieceContainer

public class TextPieceContainer
extends Object
implements ITextPieceContainer

Base implementation of ITextpieceContainer. To resolve indexex, are used tree types of text: original, logical and rendered. Logical replaces transformed text, because transformed text is not available. Logical text is simply created from rendered, adding line breaks at end of lines and interpreting them as white space.

Author:
Tomáš Studva 29.9.2005

Constructor Summary
TextPieceContainer(ITextPieceKeeper firstPieceKeeper, String nodeId)
          Constructor.
 
Method Summary
 ITextPieceInfo add(ITextPieceKeeper pieceKeeper)
          Adds ITextPieceKeeper to container.
 List<ITextPieceKeeper> getAll()
          Returns all stored ITextPieceKeeper.
 ITextPieceInfo getInfo(ITextPieceKeeper forPiece)
          Returns ITextPieceInfo for ITextPieceKeeper.
 ITextPieceKeeper getKeeper(int index)
          Returns ITextPieceKeeper stored with index index.
 ITextPieceKeeper getKeeperByRenderedOffset(int offset)
          Returns keeper holding rendered text where index falls.
 List<ITextPieceKeeper> getKeepers(int startIndex, int endIndex)
          Returns ITextPieceKeepers stored with index in closed interval startIndex, endIndex.
 List<ITextPieceKeeper> getKeepers(ITextPieceKeeper startKeeper, ITextPieceKeeper endKeeper)
          Returns ITextPieceKeepers stored after startKeeper including and before endKeeper including.
 ITextPieceKeeper getNext(ITextPieceKeeper keeper)
          Returns next stored ITextPieceKeeper in order they are stored.
 ITextPieceKeeper getPrevious(ITextPieceKeeper keeper)
          Returns previous stored ITextPieceKeeper in order they are stored.
 String getWholeRenderedText()
          Returns rendered text of all stored keepers, exactly the same as is rendered.
 boolean hasNext(ITextPieceKeeper keeper)
          Returns if keeper is last or not.
 boolean hasPrevious(ITextPieceKeeper keeper)
          Returns if keeper is first or not.
 int indexOf(ITextPieceKeeper piece)
          Returns index of ITextPieceKeeper piece in this container as is stored.
 int resolveOriginalIndex(int indexInOriginalText, XMLAccess xmlAccess)
          Resolves index in DOM node's text of original document(not XSLT-transformed) to index in node's rendered text.
 int resolveRenderedIndex(int indexInRenderedText, XMLAccess xmlAccess)
          Resolves index in container rendered text to DOM node's text of original document(not XSLT-transformed).
 int size()
          Returns number of all stored pieces.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextPieceContainer

public TextPieceContainer(ITextPieceKeeper firstPieceKeeper,
                          String nodeId)
Constructor.

Parameters:
firstPieceKeeper - first TextPieceKeeper in this container
nodeId - id of node corresponding to this TextPieceContainer
originalNodeText - original DOM node's text
Method Detail

add

public ITextPieceInfo add(ITextPieceKeeper pieceKeeper)
Description copied from interface: ITextPieceContainer
Adds ITextPieceKeeper to container. Returns for that keeper ITextPieceInfo. Keepers are ordered and indexed as follows text in node they keeps. Only in noticed order can be added to container.

Specified by:
add in interface ITextPieceContainer
Parameters:
pieceKeeper - keeper to add
Returns:
ITextPieceInfo for pieceKeeper

getKeeper

public ITextPieceKeeper getKeeper(int index)
Description copied from interface: ITextPieceContainer
Returns ITextPieceKeeper stored with index index.

Specified by:
getKeeper in interface ITextPieceContainer
Parameters:
index - of wanted keeper
Returns:
ITextPieceKeeper with index index

size

public int size()
Description copied from interface: ITextPieceContainer
Returns number of all stored pieces.

Specified by:
size in interface ITextPieceContainer
Returns:
number of all stored pieces

getInfo

public ITextPieceInfo getInfo(ITextPieceKeeper forPiece)
Description copied from interface: ITextPieceContainer
Returns ITextPieceInfo for ITextPieceKeeper. This info is the same as ITextPieceKeeper has set.

Specified by:
getInfo in interface ITextPieceContainer
Parameters:
forPiece - ITextPieceKeeper stored in this container
Returns:
ITextPieceInfo about ITextPieceKeeper forPiece

getPrevious

public ITextPieceKeeper getPrevious(ITextPieceKeeper keeper)
Description copied from interface: ITextPieceContainer
Returns previous stored ITextPieceKeeper in order they are stored.

Specified by:
getPrevious in interface ITextPieceContainer
Parameters:
keeper - asked for predeccessor
Returns:
predeccessor or IllegalArgumentException if piece is the first part

getNext

public ITextPieceKeeper getNext(ITextPieceKeeper keeper)
Description copied from interface: ITextPieceContainer
Returns next stored ITextPieceKeeper in order they are stored.

Specified by:
getNext in interface ITextPieceContainer
Parameters:
keeper - asked for successor
Returns:
successor or IllegalArgumentException if piece is the last part

indexOf

public int indexOf(ITextPieceKeeper piece)
Description copied from interface: ITextPieceContainer
Returns index of ITextPieceKeeper piece in this container as is stored.

Specified by:
indexOf in interface ITextPieceContainer
Parameters:
piece - asked for index
Returns:
returns index of piece

getAll

public List<ITextPieceKeeper> getAll()
Description copied from interface: ITextPieceContainer
Returns all stored ITextPieceKeeper. If is correctly filled by ITextPieceKeepers, than returns all ITexPieceKeepers for node.

Specified by:
getAll in interface ITextPieceContainer
Returns:
all stored ITextPieceKeeper

getKeeperByRenderedOffset

public ITextPieceKeeper getKeeperByRenderedOffset(int offset)
Description copied from interface: ITextPieceContainer
Returns keeper holding rendered text where index falls.

Specified by:
getKeeperByRenderedOffset in interface ITextPieceContainer
Parameters:
offset - index in whole rendered text or one behind
Returns:
ITextPieceKeeper keeper holding rendered text where index falls

getKeepers

public List<ITextPieceKeeper> getKeepers(int startIndex,
                                         int endIndex)
Description copied from interface: ITextPieceContainer
Returns ITextPieceKeepers stored with index in closed interval startIndex, endIndex.

Specified by:
getKeepers in interface ITextPieceContainer
Parameters:
startIndex - of first wanted keeper
endIndex - of last wanted keeper
Returns:
List of ITextPieceKeeper within interval

getKeepers

public List<ITextPieceKeeper> getKeepers(ITextPieceKeeper startKeeper,
                                         ITextPieceKeeper endKeeper)
Description copied from interface: ITextPieceContainer
Returns ITextPieceKeepers stored after startKeeper including and before endKeeper including.

Specified by:
getKeepers in interface ITextPieceContainer
Parameters:
startKeeper - first wanted keeper
endKeeper - last wanted keeper
Returns:
List of ITextPieceKeeper within interval

getWholeRenderedText

public String getWholeRenderedText()
Description copied from interface: ITextPieceContainer
Returns rendered text of all stored keepers, exactly the same as is rendered.

Specified by:
getWholeRenderedText in interface ITextPieceContainer
Returns:
whole rendered text of node associated with this container

resolveOriginalIndex

public int resolveOriginalIndex(int indexInOriginalText,
                                XMLAccess xmlAccess)
Description copied from interface: ITextPieceContainer
Resolves index in DOM node's text of original document(not XSLT-transformed) to index in node's rendered text.

Specified by:
resolveOriginalIndex in interface ITextPieceContainer
Parameters:
indexInOriginalText - index in DOM node's original text or one behind
Returns:
index in rendered text of container (node) or one behind

resolveRenderedIndex

public int resolveRenderedIndex(int indexInRenderedText,
                                XMLAccess xmlAccess)
Description copied from interface: ITextPieceContainer
Resolves index in container rendered text to DOM node's text of original document(not XSLT-transformed).

Specified by:
resolveRenderedIndex in interface ITextPieceContainer
Parameters:
indexInRenderedText - index in rendered text of container (node) (0 to text.length-1)or index one behind the text(for example when index is character gap index, can be text lenght)
Returns:
index in DOM node's original text or one behind the text

hasNext

public boolean hasNext(ITextPieceKeeper keeper)
Description copied from interface: ITextPieceContainer
Returns if keeper is last or not.

Specified by:
hasNext in interface ITextPieceContainer
Parameters:
keeper - asked for successor
Returns:
true if keeper is not last in container

hasPrevious

public boolean hasPrevious(ITextPieceKeeper keeper)
Description copied from interface: ITextPieceContainer
Returns if keeper is first or not.

Specified by:
hasPrevious in interface ITextPieceContainer
Parameters:
keeper - asked for predeccessor
Returns:
true if keeper is not first in container

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2003-2006 null. All Rights Reserved.