de.matthiasmann.twl.model
Class DefaultEditFieldModel

java.lang.Object
  extended by de.matthiasmann.twl.model.DefaultEditFieldModel
All Implemented Interfaces:
EditFieldModel, ObservableCharSequence, java.lang.CharSequence

public class DefaultEditFieldModel
extends java.lang.Object
implements EditFieldModel

An EditFieldModel based on a StringBuilder


Nested Class Summary
 
Nested classes/interfaces inherited from interface de.matthiasmann.twl.model.ObservableCharSequence
ObservableCharSequence.Callback
 
Constructor Summary
DefaultEditFieldModel()
           
 
Method Summary
 void addCallback(ObservableCharSequence.Callback callback)
           
 char charAt(int index)
           
 int length()
           
 void removeCallback(ObservableCharSequence.Callback callback)
           
 boolean replace(int start, int count, char replacement)
          Replace count characters starting at start with the specified replacement character.
 int replace(int start, int count, java.lang.String replacement)
          Replace count characters starting at start with the specified replacement text.
 java.lang.CharSequence subSequence(int start, int end)
           
 java.lang.String substring(int start, int end)
          Returns a String containing the specified range from this sequence.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultEditFieldModel

public DefaultEditFieldModel()
Method Detail

length

public int length()
Specified by:
length in interface java.lang.CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface java.lang.CharSequence

subSequence

public java.lang.CharSequence subSequence(int start,
                                          int end)
Specified by:
subSequence in interface java.lang.CharSequence

toString

public java.lang.String toString()
Specified by:
toString in interface java.lang.CharSequence
Overrides:
toString in class java.lang.Object

addCallback

public void addCallback(ObservableCharSequence.Callback callback)
Specified by:
addCallback in interface ObservableCharSequence

removeCallback

public void removeCallback(ObservableCharSequence.Callback callback)
Specified by:
removeCallback in interface ObservableCharSequence

replace

public int replace(int start,
                   int count,
                   java.lang.String replacement)
Description copied from interface: EditFieldModel
Replace count characters starting at start with the specified replacement text.

Specified by:
replace in interface EditFieldModel
Parameters:
start - the start index
count - the number of characters to replace, can be 0.
replacement - the replacement text, can be empty.
Returns:
the number of characters which have been inserted, or -1 if no replacement has been performed.

replace

public boolean replace(int start,
                       int count,
                       char replacement)
Description copied from interface: EditFieldModel
Replace count characters starting at start with the specified replacement character.

Specified by:
replace in interface EditFieldModel
Parameters:
start - the start index
count - the number of characters to replace, can be 0.
replacement - the replacement character
Returns:
true if the sequence was changed, false otherwise.

substring

public java.lang.String substring(int start,
                                  int end)
Description copied from interface: EditFieldModel
Returns a String containing the specified range from this sequence.

Specified by:
substring in interface EditFieldModel
Parameters:
start - the start index
end - the end index
Returns:
the String object
See Also:
CharSequence.subSequence(int, int)