org.zaval.lw.mask
Class MaskedText

java.lang.Object
  |
  +--org.zaval.lw.mask.MaskedText
All Implemented Interfaces:
TextModel

public class MaskedText
extends java.lang.Object
implements TextModel

This class implements text model interface for masked text.


Constructor Summary
MaskedText(java.lang.String mask)
          Constructs the class with the specified mask.
MaskedText(java.lang.String mask, MaskValidator v)
          Constructs the class with the specified mask and the given mask validator.
 
Method Summary
 void addTextListener(TextListener l)
          Adds the specified text listener to receive text events.
 int findHandledTag(int offset, int d)
          Looks for the next handled (by the validator) character index in the text starting from the given offset.
 int getExtraChar(int i)
          Gets special extra char that is used to store extra information by the specified index.
 java.lang.String getLine(int i)
          Returns the line at the specified line number.
 java.lang.String getMask()
          Gets the mask.
 int getSize()
          Returns the line number of the text.
 java.lang.String getText()
          Returns the original text data that have been set with setText method.
 int getTextLength()
          Returns the text length (number of the text characters).
 MaskValidator getValidator()
          Gets the mask validator.
 boolean isHandledOffset(int offset)
           
 void remove(int offset, int count)
          Removes a text at the specified offset with the size.
 void removeTextListener(TextListener l)
          Removes the specified text listener.
 void setExtraChar(int i, int ch)
          Sets special extra char that is used to store extra information by the specified index.
 void setMask(java.lang.String m)
          Sets the specified mask.
 void setText(java.lang.String t)
          Sets the specified text data.
 void setValidator(MaskValidator v)
          Sets the specified mask validator.
 void write(char ch, int offset)
          Inserts the specified character at the given offset.
 void write(java.lang.String s, int offset)
          Inserts the specified text at the given offset.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MaskedText

public MaskedText(java.lang.String mask)
Constructs the class with the specified mask.
Parameters:
mask - the specified mask.

MaskedText

public MaskedText(java.lang.String mask,
                  MaskValidator v)
Constructs the class with the specified mask and the given mask validator.
Parameters:
mask - the specified mask.
v - the specified mask validator.
Method Detail

getMask

public java.lang.String getMask()
Gets the mask.
Returns:
a mask.

setMask

public void setMask(java.lang.String m)
Sets the specified mask.
Parameters:
m - the specified mask.

getLine

public java.lang.String getLine(int i)
Description copied from interface: TextModel
Returns the line at the specified line number.
Specified by:
getLine in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
line - the specified line number.
Returns:
a line at the specified line number.

getValidator

public MaskValidator getValidator()
Gets the mask validator.
Returns:
a mask validator.

setValidator

public void setValidator(MaskValidator v)
Sets the specified mask validator.
Parameters:
v - the specified mask validator.

getText

public java.lang.String getText()
Description copied from interface: TextModel
Returns the original text data that have been set with setText method.
Specified by:
getText in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Returns:
an original text data.

setText

public void setText(java.lang.String t)
Description copied from interface: TextModel
Sets the specified text data. As rule the method should perform parsing process. The process decides how the text data have to be divided into lines.
Specified by:
setText in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
text - the specified text data.

getSize

public int getSize()
Description copied from interface: TextModel
Returns the line number of the text.
Specified by:
getSize in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Returns:
a line number.

getTextLength

public int getTextLength()
Description copied from interface: TextModel
Returns the text length (number of the text characters).
Specified by:
getTextLength in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Returns:
a text length.

write

public void write(char ch,
                  int offset)
Description copied from interface: TextModel
Inserts the specified character at the given offset. The offset has to be less than the text length. Actually the method performs re-parsing of the text.
Specified by:
write in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
ch - the character to be inserted.
offset - the offset where the character will be inserted.

write

public void write(java.lang.String s,
                  int offset)
Description copied from interface: TextModel
Inserts the specified text at the given offset. The offset has to be less than the text length. Actually the method performs re-parsing of the text.
Specified by:
write in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
s - the text to be inserted.
offset - the offset where the text will be inserted.

remove

public void remove(int offset,
                   int count)
Description copied from interface: TextModel
Removes a text at the specified offset with the size. The offset and the offset plus the size have to be less than the text length.
Specified by:
remove in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
offset - the offset where the text will be removed.
size - the size of the part that is going to be removed.

addTextListener

public void addTextListener(TextListener l)
Description copied from interface: TextModel
Adds the specified text listener to receive text events.
Specified by:
addTextListener in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
l - the text listener.
See Also:
TextListener, TextEvent

removeTextListener

public void removeTextListener(TextListener l)
Description copied from interface: TextModel
Removes the specified text listener.
Specified by:
removeTextListener in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
l - the text listener.
See Also:
TextListener, TextEvent

getExtraChar

public int getExtraChar(int i)
Description copied from interface: TextModel
Gets special extra char that is used to store extra information by the specified index. The method is depricated to be used, because it will be probably re-designed in the future.
Specified by:
getExtraChar in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
i - the specified extra char index.
Returns:
an extra char value.

setExtraChar

public void setExtraChar(int i,
                         int ch)
Description copied from interface: TextModel
Sets special extra char that is used to store extra information by the specified index. The method is depricated to be used, because it will probably be re-designed in the future.
Specified by:
setExtraChar in interface TextModel
Following copied from interface: org.zaval.data.TextModel
Parameters:
i - the specified extra char index.
val - the specified extra char value.

findHandledTag

public int findHandledTag(int offset,
                          int d)
Looks for the next handled (by the validator) character index in the text starting from the given offset. The method gets the direction argument that defines look-up direction (forward or backwards).
Parameters:
offset - the starting offset.
d - the look-up direction.
Returns:
a next handled character index.

isHandledOffset

public boolean isHandledOffset(int offset)


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org