LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.view.win.swing.text
Class LyJFormat

java.lang.Object
  extended by leon.view.win.swing.text.LyJFormat

public class LyJFormat
extends java.lang.Object

This class implements a mask format.
The format is : '[' number '-' number ']' ( sep '[' number '-' number ']' )* where variable number is a positive number and sep is String that can be "".

See Also:
LyFormattedField

Nested Class Summary
 class LyJFormat.Interval
          This class implements a representation of an interval with min and max values.
 
Field Summary
static java.lang.String __VERSION
           
 char EMPTY_CHAR
          Define the empty character.
 
Constructor Summary
LyJFormat()
          Constructor.
LyJFormat(java.lang.String format)
          Constructor.
 
Method Summary
 void clear()
          Clears the content.
 java.lang.String getDisplayableString(boolean hasFocus)
          Gets the String to display in the text field.
 int getIndexIntervalFromOffset(int offset)
          Gets the index of the last interval that contains the position of the given offset in the textField.
 int getIndexSeparatorFromOffset(int offset)
          Gets the index of the last separator that contains the position of the given offset in the textFieldt.
 LyJFormat.Interval getInterval(int i)
          Gets the interval at the given index.
 int getIntervalsCount()
          Gets the number of intervals.
 int getIntValue(int offset)
          Gets the value at the given position offset as an int.
 int getMaxIntValue(int offset)
          Gets the maximum value at the given position offset.
 int getMinIntValue(int offset)
          Gets the minimum value at the given position offset.
 java.lang.String getSeparator(int i)
          Gets the separator at the given index.
 boolean isAllEmpty()
          Indicates that all intervals are empty or not.
 boolean isCharDeletionValid(int offset)
          Indicates that the char at the given position offset can be removed.
 boolean isCharInsertionValid(char c, int offset)
          Indicates that the given character can be inserted at the given position. offset.
 void parseString(java.lang.String format)
          Parses the String that defines the format and build the compiled version of the format.
 int replaceChar(int offset, char c)
          Finds the Interval that contains the given position offset and replace the character at that position by the given one.
 void setFormatString(java.lang.String format)
          Sets the given format.
 void setIntValue(int offset, int value)
          Sets the value at the given position offset of the textComponent.
 void setValue(java.lang.String value)
          Sets the value of this format.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
See Also:
Constant Field Values

EMPTY_CHAR

public char EMPTY_CHAR
Define the empty character.

Constructor Detail

LyJFormat

public LyJFormat()
Constructor. Initializes class attributes with null or default values.


LyJFormat

public LyJFormat(java.lang.String format)
          throws LyJBadFormatException
Constructor. Call the constructor without parameters LyJFormat() and parses the given format (parseString(String)).

Parameters:
format - the String that defines the format
Throws:
LyJBadFormatException
Method Detail

setFormatString

public void setFormatString(java.lang.String format)
                     throws LyJBadFormatException
Sets the given format. Only call parseString(String).

Parameters:
format - the String that defines the format
Throws:
LyJBadFormatException
See Also:
parseString(String)

parseString

public void parseString(java.lang.String format)
                 throws LyJBadFormatException
Parses the String that defines the format and build the compiled version of the format.

Parameters:
format - the String to parse
Throws:
LyJBadFormatException

getInterval

public LyJFormat.Interval getInterval(int i)
Gets the interval at the given index.

Parameters:
i - the index of the wanted interval
Returns:
the Interval at position i

getSeparator

public java.lang.String getSeparator(int i)
Gets the separator at the given index.

Parameters:
i - the index of the wanted separator
Returns:
the separator at position i

getIntervalsCount

public int getIntervalsCount()
Gets the number of intervals. The number of separators = getIntervalsCount - 1.

Returns:
the number of Intervals

getIndexIntervalFromOffset

public int getIndexIntervalFromOffset(int offset)
Gets the index of the last interval that contains the position of the given offset in the textField.

Parameters:
offset - the offset
Returns:
the index of the interval that contains the position offset in the textField

getIndexSeparatorFromOffset

public int getIndexSeparatorFromOffset(int offset)
Gets the index of the last separator that contains the position of the given offset in the textFieldt.

Parameters:
offset - the offset
Returns:
the index of the separator that contains the position offset in the textField

isCharDeletionValid

public boolean isCharDeletionValid(int offset)
Indicates that the char at the given position offset can be removed.

Parameters:
offset - the offset
Returns:
true if the char at position offset in the textField can be removed, false otherwise

isCharInsertionValid

public boolean isCharInsertionValid(char c,
                                    int offset)
Indicates that the given character can be inserted at the given position. offset.
Verifies that the value is coherent with the format.

Parameters:
c - the character to insert
offset - the offset
Returns:
true if the char c can be inserted at position offset, false otherwise

replaceChar

public int replaceChar(int offset,
                       char c)
Finds the Interval that contains the given position offset and replace the character at that position by the given one.

Parameters:
offset - the offset
c - the character
Returns:
the index of the next separator or offset + 1

getDisplayableString

public java.lang.String getDisplayableString(boolean hasFocus)
Gets the String to display in the text field. The editing and edited value are not always the same.

Parameters:
hasFocus - is true if the textField has the focus
Returns:
the String to display in the textField

isAllEmpty

public boolean isAllEmpty()
Indicates that all intervals are empty or not.

Returns:
true if all intervals are empty, false otherwise

getIntValue

public int getIntValue(int offset)
Gets the value at the given position offset as an int.

Parameters:
offset - the pos of the caret used to determine which interval is the current interval
Returns:
the value at pos offset in the TextComponent as an int
See Also:
setIntValue(int, int)

setIntValue

public void setIntValue(int offset,
                        int value)
Sets the value at the given position offset of the textComponent.

Parameters:
offset - the pos of the caret used to determine which interval is the current interval
value - the value to set
See Also:
getIntValue(int)

getMinIntValue

public int getMinIntValue(int offset)
Gets the minimum value at the given position offset.

Parameters:
offset - the pos of the caret used to determine which interval is the current interval
Returns:
the minimum value at pos offset

getMaxIntValue

public int getMaxIntValue(int offset)
Gets the maximum value at the given position offset.

Parameters:
offset - the pos of the caret used to determine which interval is the current interval
Returns:
the maximum value at pos offset

setValue

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

Parameters:
value - the new value of the format

clear

public void clear()
Clears the content.


(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com