litesoft
@ 964
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / common / shared / validators / Only7BitAlphaNumericUnderScoreValueValidator.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
package com.temp.common.shared.validators; import org.litesoft.externalization.shared.*; import com.temp.common.shared.*; import com.temp.common.shared.utils.*; public class Only7BitAlphaNumericUnderScoreValueValidator implements ValueValidator { public static final String TEMPLATE_ID_CODE = "Only7BitAlphaNumericUnderScore"; public static final String TEMPLATE_NAME_WHY = "why"; public static final String SUBTEMPLATE_WHY_NOT_STRING = "NotString"; public static final String SUBTEMPLATE_WHY_EMPTY_STRING = "EmptyString"; public static final ValueValidator INSTANCE = new Only7BitAlphaNumericUnderScoreValueValidator(); private Only7BitAlphaNumericUnderScoreValueValidator() { } @Override public E13nData checkValue( Object value ) { if ( !(value instanceof String) ) { return E13nData.builder( TEMPLATE_ID_CODE ) .addSubstitutionNamedExternalizableCode( TEMPLATE_NAME_WHY, SUBTEMPLATE_WHY_NOT_STRING ) .build(); } String userData = value.toString().trim(); if ( userData.length() == 0 ) { return E13nData.builder( TEMPLATE_ID_CODE ) .addSubstitutionNamedExternalizableCode( TEMPLATE_NAME_WHY, SUBTEMPLATE_WHY_EMPTY_STRING ) .build(); } for ( int i = 0; i < userData.length(); i++ ) { char c = userData.charAt( i ); if ( !CharacterUtils.isAlphaNumericUnderScore7BitAscii( c ) ) { } } return null; // OK! } } |
Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/common/shared/validators/Only7BitAlphaNumericUnderScoreValueValidator.java
Revision | Author | Commited | Message |
---|---|---|---|
964 | GeorgeS | Fri 01 Aug, 2014 03:18:23 +0000 | ! |