@Test public void testIsValidValue() { String isValidResult; isValidResult = textBox.isValidValue("a", true); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("a", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("_", true); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("_", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("aBc", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("CdE", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("-", true); assertEquals(ERROR_REMOVED + ": -", isValidResult); isValidResult = textBox.isValidValue("a-b", true); assertEquals(ERROR_REMOVED + ": -", isValidResult); isValidResult = textBox.isValidValue("a#$%1", false); assertEquals(ERROR_TYPED + ": #$%", isValidResult); isValidResult = textBox.isValidValue("Cd.E", false); assertEquals(null, isValidResult); isValidResult = textBox.isValidValue("<a#$%1>", false); assertEquals(ERROR_TYPED + ": <#$%>", isValidResult); }
@Override public String isValidValue(final String value, final boolean isOnFocusLost) { if (regExp != null) { boolean isValid = this.regExp.test(value); if (!isValid) { String invalidChars = getInvalidCharsInName(regExp, value); return (isOnFocusLost ? invalidCharactersInNameErrorMessage : invalidCharacterTypedMessage) + ": " + invalidChars; } } return null; }
CustomDataTypeTextBox extends AbstractValidatingTextBox { @Override public String isValidValue(final String value, final boolean isOnFocusLost) { if (regExp != null) { boolean isValid = this.regExp.test(value); if (!isValid) { String invalidChars = getInvalidCharsInName(regExp, value); return (isOnFocusLost ? invalidCharactersInNameErrorMessage : invalidCharacterTypedMessage) + ": " + invalidChars; } } return null; } }
CustomDataTypeTextBox extends AbstractValidatingTextBox { @Override public String isValidValue(final String value, final boolean isOnFocusLost) { if (regExp != null) { boolean isValid = this.regExp.test(value); if (!isValid) { String invalidChars = getInvalidCharsInName(regExp, value); return (isOnFocusLost ? invalidCharactersInNameErrorMessage : invalidCharacterTypedMessage) + ": " + invalidChars; } } return null; } CustomDataTypeTextBox(); }
CustomDataTypeTextBox extends AbstractValidatingTextBox { @Override public String isValidValue(final String value, final boolean isOnFocusLost) { if (regExp != null) { boolean isValid = this.regExp.test(value); if (!isValid) { String invalidChars = getInvalidCharsInName(regExp, value); return (isOnFocusLost ? invalidCharactersInNameErrorMessage : invalidCharacterTypedMessage) + ": " + invalidChars; } } return null; } CustomDataTypeTextBox(); void setRegExp(final String pattern,
                          final String invalidCharactersInNameErrorMessage,
                          final String invalidCharacterTypedMessage); @Override String isValidValue(final String value,
                               final boolean isOnFocusLost); }
CustomDataTypeTextBox extends AbstractValidatingTextBox { @Override public String isValidValue(final String value, final boolean isOnFocusLost) { if (regExp != null) { boolean isValid = this.regExp.test(value); if (!isValid) { String invalidChars = getInvalidCharsInName(regExp, value); return (isOnFocusLost ? invalidCharactersInNameErrorMessage : invalidCharacterTypedMessage) + ": " + invalidChars; } } return null; } CustomDataTypeTextBox(); void setRegExp(final String pattern,
                          final String invalidCharactersInNameErrorMessage,
                          final String invalidCharacterTypedMessage); @Override String isValidValue(final String value,
                               final boolean isOnFocusLost);  }