sk.uniba.euromath.editor.textEditor
Class TextPieceInfoImpl

java.lang.Object
  extended by sk.uniba.euromath.editor.textEditor.TextPieceInfoImpl
All Implemented Interfaces:
ITextPieceInfo

public class TextPieceInfoImpl
extends Object
implements ITextPieceInfo

Info about text piece from textual node identified by nodeID.

Author:
Tomáš Studva 24.1.2006

Constructor Summary
TextPieceInfoImpl(String nodeID, int offset, int originalOffset, String text)
          Constructor.
 
Method Summary
static String buildID(String nodeID, int offset, int length)
          Static method to build text piece id from nodeID, offset and length.
 int contains(String nodeID, int offset, int length)
          Deprecated. ak sa ti to hodi pouzit informuj STUDVU
 String getID()
          Returns id for text piece in this TextPieceInfo.
 int getLastIndex()
          Index of last character of this text piece in whole displayed text
 int getLength()
          Length of the text piece.
static int getLength(String id)
          Parses length of text piece from text piece's id.
 String getNodeID()
          Identification of node holding the text (text node, cdata node, attribute).
static String getNodeID(String id)
          Parses node id with multiplicity from id.
 int getOffset()
          Index of the first character of this text piece in whole displayed text of textual node.
static int getOffset(String id)
          Parses offset of text piece from text piece id.
 int getOriginalOffset()
          Index of the first character of this text piece in whole original text of textual node.
static String getParsedNodeId(String nodeId)
          Parses node id without multiplicity - anything include and after ":" is omitted.
 String getText()
          Returns text of this text piece.
static boolean isTextPieceId(String id)
          True if parameter id is text piece/selection id, it means of form int.
static void tidyUpIds(List<String> ids)
          Any text piece ids which are neighbour are joined together.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TextPieceInfoImpl

public TextPieceInfoImpl(String nodeID,
                         int offset,
                         int originalOffset,
                         String text)
Constructor.

Parameters:
nodeID - id of text node of text piece
offset - of first character in displayed text of text node
originalOffset - offset of first character in original text of text node
text - text from textual node with id nodeID and starting at position offset
Method Detail

getID

public String getID()
Returns id for text piece in this TextPieceInfo. Text piece id is unique identifier for substring of text of textual node from xml document. Id is build by adding offset and length to id of textual node containig this text. The id has format: id of node

Specified by:
getID in interface ITextPieceInfo
Returns:
text piece id : id of node

getNodeID

public String getNodeID()
Description copied from interface: ITextPieceInfo
Identification of node holding the text (text node, cdata node, attribute).

Specified by:
getNodeID in interface ITextPieceInfo
Returns:
id of node containing this text

getOffset

public int getOffset()
Description copied from interface: ITextPieceInfo
Index of the first character of this text piece in whole displayed text of textual node.

Specified by:
getOffset in interface ITextPieceInfo
Returns:
globaloffset of first character

getLastIndex

public int getLastIndex()
Description copied from interface: ITextPieceInfo
Index of last character of this text piece in whole displayed text

Specified by:
getLastIndex in interface ITextPieceInfo
Returns:
global offset of last character

getLength

public int getLength()
Description copied from interface: ITextPieceInfo
Length of the text piece.

Specified by:
getLength in interface ITextPieceInfo
Returns:
length

getText

public String getText()
Description copied from interface: ITextPieceInfo
Returns text of this text piece.

Specified by:
getText in interface ITextPieceInfo
Returns:
text value.

getNodeID

public static String getNodeID(String id)
Parses node id with multiplicity from id.

Parameters:
id - some id
Returns:
id of node

getParsedNodeId

public static final String getParsedNodeId(String nodeId)
Parses node id without multiplicity - anything include and after ":" is omitted.

Parameters:
nodeId - id of node
Returns:
id without multiplicity

getOffset

public static int getOffset(String id)
Parses offset of text piece from text piece id. If id is not text piece id, IllegalArgumentException is thrown.

Parameters:
id - id of text piece
Returns:
offset of text piece

getLength

public static int getLength(String id)
Parses length of text piece from text piece's id. If id is not text piece id, IllegalArgumentException is thrown.

Parameters:
id - id of text piece
Returns:
length of text piece

contains

@Deprecated
public int contains(String nodeID,
                               int offset,
                               int length)
Deprecated. ak sa ti to hodi pouzit informuj STUDVU

Specified by:
contains in interface ITextPieceInfo
Parameters:
nodeID - id of text node
offset - offset in text piece
Returns:
index of character from start of this text piece

isTextPieceId

public static boolean isTextPieceId(String id)
True if parameter id is text piece/selection id, it means of form int.

Parameters:
id - to examine
Returns:
true if id is textpiece/selection id

buildID

public static final String buildID(String nodeID,
                                   int offset,
                                   int length)
Static method to build text piece id from nodeID, offset and length.

Parameters:
nodeID - id of node of text piece
offset - of first character in text of text node
length - of text to identify
Returns:
nodeID

tidyUpIds

public static void tidyUpIds(List<String> ids)
Any text piece ids which are neighbour are joined together. Neighbour text piece ids are satisfiing these conditions: have same node id and offset + length - 1 == offset of second (where first ends, second starts).

Parameters:
ids - text piece ids to tidy up

getOriginalOffset

public int getOriginalOffset()
Description copied from interface: ITextPieceInfo
Index of the first character of this text piece in whole original text of textual node.

Specified by:
getOriginalOffset in interface ITextPieceInfo
Returns:
globaloffset of first character


Copyright © 2003-2006 null. All Rights Reserved.