edu.columbia.cs.ref.model
Class Segment

java.lang.Object
  extended by edu.columbia.cs.ref.model.Segment
All Implemented Interfaces:
java.io.Serializable

public class Segment
extends java.lang.Object
implements java.io.Serializable

Representation of a Section of a document.

Since:
2011-09-27
Version:
0.1
Author:
Pablo Barrio, Goncalo Simoes
See Also:
Serialized Form

Constructor Summary
Segment(java.lang.String value, int offset)
          Constructor of the Segment
 
Method Summary
 boolean contains(int offset, int length)
          Verifies if the section starting in a given offset and with a given length is contained in this segment.
 int getOffset()
          Obtains the value of the starting position of the segment in the document
 java.lang.String getValue()
          Obtains the value of the segment
 java.lang.String getValue(int offset, int length)
          Obtains the substring of the section starting at a given offset and with a given length
 void setOffset(int offset)
          Sets the value of the starting position of the segment in the document
 void setValue(java.lang.String value)
          Sets the value of segment
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Segment

public Segment(java.lang.String value,
               int offset)
Constructor of the Segment

Parameters:
value - the text representation of the segment
offset - the offset that indicates the starting position of the segment in document
Method Detail

setValue

public void setValue(java.lang.String value)
Sets the value of segment

Parameters:
value - value to be set

getValue

public java.lang.String getValue()
Obtains the value of the segment

Returns:
The value of the segment

setOffset

public void setOffset(int offset)
Sets the value of the starting position of the segment in the document

Parameters:
offset - starting position to be set

getOffset

public int getOffset()
Obtains the value of the starting position of the segment in the document

Returns:
The offset of the starting position

toString

public java.lang.String toString()
Returns a string representation of the object.

Overrides:
toString in class java.lang.Object
Returns:
string representation of the object.

contains

public boolean contains(int offset,
                        int length)
Verifies if the section starting in a given offset and with a given length is contained in this segment.

Parameters:
offset - the offset that indicates the starting position of the section in document
length - the length of the section
Returns:
true if the section is contained in this segment and false otherwise

getValue

public java.lang.String getValue(int offset,
                                 int length)
Obtains the substring of the section starting at a given offset and with a given length

Parameters:
offset - start of the substring to be retrieved
length - size of the substring to be retrieved
Returns:
substring retrieved