Interface MinMaxLengthElement
-
public interface MinMaxLengthElementInterface to add minlength and maxlength attributes to elements Simply implement this interface into the element to support the two attributes Beware: If the element implementing this interface overridesElement.buildAttribute(org.symphonyoss.symphony.messageml.MessageMLParser, org.w3c.dom.Node)without calling super, it is needed to manage manually MINLENGTH_ATTR, MAXLENGTH_ATTR attributes- Author:
- mariacristina.dedominicis (23/07/2020)
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>ALL_MIN_MAX_ATTRSstatic StringMAXLENGTH_ATTRstatic StringMINLENGTH_ATTR
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default IntegergetAttributeAsInteger(String attributeName)This method take the value corresponding to the attribute given as input and convert it to an Integer, if possibleStringgetAttributeValue(String attributeName)default IntegergetDefaultValueIfCurrentIsNull(Integer currentValue, Integer defaultValue)In case these is no maxlenght or no minlength this method return the default value assigned to each attributesStringgetElementInitialValue()StringgetElementType()default StringgetLengthErrorMessage(String attributeName)IntegergetMaxValueAllowed()IntegergetMinValueAllowed()booleanhasElementInitialValue()default booleanisLengthOutOfRange(Integer length)Check if the length of the input is in the default ranges of the elementdefault booleanisMinAndMaxLengthCombinationValid(Integer minLength, Integer maxLength)Checks if the [minlength, maxlength] range is validdefault booleanisTextBiggerThanMaxLength(Integer maxLength, String text)default booleanisTextSmallerThanMinLength(Integer minLength, String text)default voidvalidateInitialValueIfFound(Integer minLength, Integer maxLength)This method validates in case there is an initial value in the element, if that input is a valid one, meaning that it respects the range of minlength and maxlength.default voidvalidateMinAndMaxLengths()This method checks if the values assigned to minlength and maxlength attributes are valid.
-
-
-
Field Detail
-
MINLENGTH_ATTR
static final String MINLENGTH_ATTR
- See Also:
- Constant Field Values
-
MAXLENGTH_ATTR
static final String MAXLENGTH_ATTR
- See Also:
- Constant Field Values
-
-
Method Detail
-
validateMinAndMaxLengths
default void validateMinAndMaxLengths() throws InvalidInputExceptionThis method checks if the values assigned to minlength and maxlength attributes are valid. If there is an initial value in the textarea it also checks if the latter is between the range given- Throws:
InvalidInputException- when the attributes value are not valid or the input is not in range
-
validateInitialValueIfFound
default void validateInitialValueIfFound(Integer minLength, Integer maxLength) throws InvalidInputException
This method validates in case there is an initial value in the element, if that input is a valid one, meaning that it respects the range of minlength and maxlength.- Parameters:
minLength- valuemaxLength- value- Throws:
InvalidInputException- if the the initial value is not in range
-
getDefaultValueIfCurrentIsNull
default Integer getDefaultValueIfCurrentIsNull(Integer currentValue, Integer defaultValue)
In case these is no maxlenght or no minlength this method return the default value assigned to each attributes- Parameters:
currentValue- is attribute as a value assigneddefaultValue- default value for that attribute- Returns:
-
isMinAndMaxLengthCombinationValid
default boolean isMinAndMaxLengthCombinationValid(Integer minLength, Integer maxLength)
Checks if the [minlength, maxlength] range is valid- Parameters:
maxLength- valueminLength- value- Returns:
- true is the range is valid
-
isTextBiggerThanMaxLength
default boolean isTextBiggerThanMaxLength(Integer maxLength, String text)
- Parameters:
maxLength- valuetext- given in input- Returns:
- true if the input is not longer that maxlength
-
isTextSmallerThanMinLength
default boolean isTextSmallerThanMinLength(Integer minLength, String text)
- Parameters:
minLength- valuetext- given in input- Returns:
- true if the input is not smaller that maxlength
-
getAttributeAsInteger
default Integer getAttributeAsInteger(String attributeName) throws InvalidInputException
This method take the value corresponding to the attribute given as input and convert it to an Integer, if possible- Parameters:
attributeName- attribute to be converted- Returns:
- Integer version of the attribute
- Throws:
InvalidInputException- if the value of the attribute is not a numeric one
-
isLengthOutOfRange
default boolean isLengthOutOfRange(Integer length)
Check if the length of the input is in the default ranges of the element- Parameters:
length- of the input- Returns:
-
getElementType
String getElementType()
- Returns:
- the type of the element
-
hasElementInitialValue
boolean hasElementInitialValue()
- Returns:
- true if the element has an initial value
-
getElementInitialValue
String getElementInitialValue()
- Returns:
- the initial value found in the element
-
getAttributeValue
String getAttributeValue(String attributeName)
- Parameters:
attributeName- we want to retrieve- Returns:
- the value corresponding to the attributeName given in input
-
getMinValueAllowed
Integer getMinValueAllowed()
- Returns:
- minimum value allowed for the minLength attribute
-
getMaxValueAllowed
Integer getMaxValueAllowed()
- Returns:
- maximum value allowed for the maxLength attribute
-
-