target
stringlengths 20
113k
| src_fm
stringlengths 11
86.3k
| src_fm_fc
stringlengths 21
86.4k
| src_fm_fc_co
stringlengths 30
86.4k
| src_fm_fc_ms
stringlengths 42
86.8k
| src_fm_fc_ms_ff
stringlengths 43
86.8k
|
---|---|---|---|---|---|
@Test public void testInsignifiantSpacesStringNCombining() throws LdapException { Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" ); char[] chars = new char[] { ' ', 0x0310, ' ', 0x0311, ' ', 0x0312 }; char[] expected = new char[] { ' ', 0x0310, ' ', ' ', 0x0311, ' ', ' ', 0x0312, ' ' }; assertEquals( new String( expected ), normalizer.normalize( new String( chars ) ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testInsignifiantSpacesStringCharsSpaces() throws LdapException { Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" ); assertEquals( " a ", normalizer.normalize( " a" ) ); assertEquals( " a ", normalizer.normalize( "a " ) ); assertEquals( " a ", normalizer.normalize( " a " ) ); assertEquals( " a a ", normalizer.normalize( "a a" ) ); assertEquals( " a a ", normalizer.normalize( " a a" ) ); assertEquals( " a a ", normalizer.normalize( "a a " ) ); assertEquals( " a a ", normalizer.normalize( "a a" ) ); assertEquals( " a a ", normalizer.normalize( " a a " ) ); assertEquals( " aaa aaa aaa ", normalizer.normalize( " aaa aaa aaa " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeCharsCombiningSpaces() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); char[] chars = new char[] { 'a', 'm', ' ', 'e', 0x0301, 'l', 'i', 'e' }; char[] expected = new char[] { ' ', 'a', 'm', ' ', ' ', '\u00e9', 'l', 'i' , 'e', ' ' }; String expectedStr = new String( expected ); String charsStr = new String( chars ); assertEquals( expectedStr, normalizer.normalize( charsStr ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeString() throws Exception { Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" ); assertEquals( " abcd ", normalizer.normalize( "abcd" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testMapToSpace() throws Exception { Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" ); char[] chars = new char[] { 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0085, 0x00A0, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x2028, 0x2029, 0x202F, 0x205F }; assertEquals( " ", normalizer.normalize( new String( chars ) ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeIgnore() throws Exception { Normalizer normalizer = new DeepTrimNormalizer( "1.1.1" ); char[] chars = new char[58]; int pos = 0; for ( char c = 0x0000; c < 0x0008; c++ ) { chars[pos++] = c; } for ( char c = 0x000E; c < 0x001F; c++ ) { chars[pos++] = c; } for ( char c = 0x007F; c < 0x0084; c++ ) { chars[pos++] = c; } for ( char c = 0x0086; c < 0x009F; c++ ) { chars[pos++] = c; } chars[pos++] = 0x00AD; assertEquals( " ", normalizer.normalize( new String( chars ) ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimNormalizer( String oid ); DeepTrimNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testDeepTrimToLowerNormalizerNull() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertNull( normalizer.normalize( ( String ) null ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testDeepTrimToLowerNormalizerEmpty() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " ", normalizer.normalize( "" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testDeepTrim() { assertEquals( "", Strings.deepTrim( " ", false ) ); assertEquals( "ab", Strings.deepTrim( " ab ", false ) ); assertEquals( "a b", Strings.deepTrim( " a b ", false ) ); assertEquals( "a b", Strings.deepTrim( " a b ", false ) ); assertEquals( "a b", Strings.deepTrim( " a b ", false ) ); assertEquals( "ab", Strings.deepTrim( "ab ", false ) ); assertEquals( "ab", Strings.deepTrim( " ab", false ) ); assertEquals( "ab", Strings.deepTrim( "ab ", false ) ); assertEquals( "ab", Strings.deepTrim( " ab", false ) ); assertEquals( "a b", Strings.deepTrim( "a b", false ) ); assertEquals( "a b", Strings.deepTrim( "a b", false ) ); assertEquals( "a b", Strings.deepTrim( " a b", false ) ); assertEquals( "a b", Strings.deepTrim( "a b ", false ) ); } | public static String deepTrim( String str, boolean toLowerCase ) { if ( ( null == str ) || ( str.length() == 0 ) ) { return ""; } char ch; int length = str.length(); char[] newbuf = new char[length]; boolean wsSeen = false; boolean isStart = true; int pos = 0; for ( int i = 0; i < length; i++ ) { ch = str.charAt( i ); if ( toLowerCase && Character.isUpperCase( ch ) ) { ch = Character.toLowerCase( ch ); } if ( Character.isWhitespace( ch ) ) { if ( !wsSeen ) { wsSeen = true; if ( isStart ) { isStart = false; } else { newbuf[pos++] = ch; } } } else { wsSeen = false; isStart = false; newbuf[pos++] = ch; } } return pos == 0 ? "" : new String( newbuf, 0, wsSeen ? pos - 1 : pos ); } | Strings { public static String deepTrim( String str, boolean toLowerCase ) { if ( ( null == str ) || ( str.length() == 0 ) ) { return ""; } char ch; int length = str.length(); char[] newbuf = new char[length]; boolean wsSeen = false; boolean isStart = true; int pos = 0; for ( int i = 0; i < length; i++ ) { ch = str.charAt( i ); if ( toLowerCase && Character.isUpperCase( ch ) ) { ch = Character.toLowerCase( ch ); } if ( Character.isWhitespace( ch ) ) { if ( !wsSeen ) { wsSeen = true; if ( isStart ) { isStart = false; } else { newbuf[pos++] = ch; } } } else { wsSeen = false; isStart = false; newbuf[pos++] = ch; } } return pos == 0 ? "" : new String( newbuf, 0, wsSeen ? pos - 1 : pos ); } } | Strings { public static String deepTrim( String str, boolean toLowerCase ) { if ( ( null == str ) || ( str.length() == 0 ) ) { return ""; } char ch; int length = str.length(); char[] newbuf = new char[length]; boolean wsSeen = false; boolean isStart = true; int pos = 0; for ( int i = 0; i < length; i++ ) { ch = str.charAt( i ); if ( toLowerCase && Character.isUpperCase( ch ) ) { ch = Character.toLowerCase( ch ); } if ( Character.isWhitespace( ch ) ) { if ( !wsSeen ) { wsSeen = true; if ( isStart ) { isStart = false; } else { newbuf[pos++] = ch; } } } else { wsSeen = false; isStart = false; newbuf[pos++] = ch; } } return pos == 0 ? "" : new String( newbuf, 0, wsSeen ? pos - 1 : pos ); } private Strings(); } | Strings { public static String deepTrim( String str, boolean toLowerCase ) { if ( ( null == str ) || ( str.length() == 0 ) ) { return ""; } char ch; int length = str.length(); char[] newbuf = new char[length]; boolean wsSeen = false; boolean isStart = true; int pos = 0; for ( int i = 0; i < length; i++ ) { ch = str.charAt( i ); if ( toLowerCase && Character.isUpperCase( ch ) ) { ch = Character.toLowerCase( ch ); } if ( Character.isWhitespace( ch ) ) { if ( !wsSeen ) { wsSeen = true; if ( isStart ) { isStart = false; } else { newbuf[pos++] = ch; } } } else { wsSeen = false; isStart = false; newbuf[pos++] = ch; } } return pos == 0 ? "" : new String( newbuf, 0, wsSeen ? pos - 1 : pos ); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static String deepTrim( String str, boolean toLowerCase ) { if ( ( null == str ) || ( str.length() == 0 ) ) { return ""; } char ch; int length = str.length(); char[] newbuf = new char[length]; boolean wsSeen = false; boolean isStart = true; int pos = 0; for ( int i = 0; i < length; i++ ) { ch = str.charAt( i ); if ( toLowerCase && Character.isUpperCase( ch ) ) { ch = Character.toLowerCase( ch ); } if ( Character.isWhitespace( ch ) ) { if ( !wsSeen ) { wsSeen = true; if ( isStart ) { isStart = false; } else { newbuf[pos++] = ch; } } } else { wsSeen = false; isStart = false; newbuf[pos++] = ch; } } return pos == 0 ? "" : new String( newbuf, 0, wsSeen ? pos - 1 : pos ); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void testDeepTrimToLowerNormalizerOneSpace() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " ", normalizer.normalize( " " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testDeepTrimToLowerNormalizerTwoSpaces() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " ", normalizer.normalize( " " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testDeepTrimToLowerNormalizerNSpaces() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " ", normalizer.normalize( " " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testInsignifiantSpacesStringOneChar() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " a ", normalizer.normalize( "a" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testInsignifiantSpacesStringTwoChars() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " aa ", normalizer.normalize( "aa" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testInsignifiantSpacesStringNChars() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " aaaaa ", normalizer.normalize( "aaaaa" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testInsignifiantSpacesStringOneCombining() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); char[] chars = new char[] { 'e', 0x0301 }; char[] expected = new char[] { ' ', '\u00E9', ' ' }; String expectedStr = new String( expected ); String charsStr = new String( chars ); assertEquals( expectedStr, normalizer.normalize( charsStr ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testInsignifiantSpacesStringNCombining() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); char[] chars = new char[] { 'e', 0x0301, ' ', 'a', 0x0300, 'i', 0x0302 }; char[] expected = new char[] { ' ', '\u00E9', ' ', ' ', '\u00E0', '\u00EE', ' ' }; assertEquals( new String( expected ), normalizer.normalize( new String( chars ) ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testInsignifiantSpacesStringCharsSpaces() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " a ", normalizer.normalize( " a" ) ); assertEquals( " a ", normalizer.normalize( "a " ) ); assertEquals( " a ", normalizer.normalize( " a " ) ); assertEquals( " a a ", normalizer.normalize( "a a" ) ); assertEquals( " a a ", normalizer.normalize( " a a" ) ); assertEquals( " a a ", normalizer.normalize( "a a " ) ); assertEquals( " a a ", normalizer.normalize( "a a" ) ); assertEquals( " a a ", normalizer.normalize( " a a " ) ); assertEquals( " aaa aaa aaa ", normalizer.normalize( " aaa aaa aaa " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeCharsCombiningSpaces() throws LdapException { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); char[] chars = new char[] { 'a', 'm', ' ', 'e', 0x0301, 'l', 'i', 'e' }; char[] expected = new char[] { ' ', 'a', 'm', ' ', ' ', '\u00e9', 'l', 'i' , 'e', ' ' }; String expectedStr = new String( expected ); String charsStr = new String( chars ); assertEquals( expectedStr, normalizer.normalize( charsStr ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testTrim() { assertEquals( "", Strings.trim( ( String ) null ) ); assertEquals( "", Strings.trim( "" ) ); assertEquals( "", Strings.trim( " " ) ); assertEquals( "", Strings.trim( " " ) ); assertEquals( "a", Strings.trim( "a " ) ); assertEquals( "a", Strings.trim( " a" ) ); assertEquals( "a", Strings.trim( " a " ) ); } | public static String trim( String str ) { return isEmpty( str ) ? "" : str.trim(); } | Strings { public static String trim( String str ) { return isEmpty( str ) ? "" : str.trim(); } } | Strings { public static String trim( String str ) { return isEmpty( str ) ? "" : str.trim(); } private Strings(); } | Strings { public static String trim( String str ) { return isEmpty( str ) ? "" : str.trim(); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static String trim( String str ) { return isEmpty( str ) ? "" : str.trim(); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void testNormalizeString() throws Exception { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); assertEquals( " abcd ", normalizer.normalize( "abcd" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testMapToSpace() throws Exception { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); char[] chars = new char[] { 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0085, 0x00A0, 0x1680, 0x2000, 0x2001, 0x2002, 0x2003, 0x2004, 0x2005, 0x2006, 0x2007, 0x2008, 0x2009, 0x200A, 0x2028, 0x2029, 0x202F, 0x205F }; assertEquals( " ", normalizer.normalize( new String( chars ) ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeIgnore() throws Exception { Normalizer normalizer = new DeepTrimToLowerNormalizer( "1.1.1" ); char[] chars = new char[58]; int pos = 0; for ( char c = 0x0000; c < 0x0008; c++ ) { chars[pos++] = c; } for ( char c = 0x000E; c < 0x001F; c++ ) { chars[pos++] = c; } for ( char c = 0x007F; c < 0x0084; c++ ) { chars[pos++] = c; } for ( char c = 0x0086; c < 0x009F; c++ ) { chars[pos++] = c; } chars[pos++] = 0x00AD; assertEquals( " ", normalizer.normalize( new String( chars ) ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test @Disabled public void testSpeed() throws Exception { Normalizer normalizer = new DeepTrimToLowerNormalizer(); String t = "xs crvtbynU Jikl7897A90"; normalizer.normalize( t ); long t0 = System.currentTimeMillis(); for ( int i = 0; i < 100000000; i++ ) { normalizer.normalize( t ); } long t1 = System.currentTimeMillis(); System.out.println( t1 - t0 ); Strings.deepTrimToLower( t ); t0 = System.currentTimeMillis(); for ( int i = 0; i < 100000000; i++ ) { Strings.deepTrimToLower( t ); } t1 = System.currentTimeMillis(); System.out.println( t1 - t0 ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | DeepTrimToLowerNormalizer extends Normalizer implements PreparedNormalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } DeepTrimToLowerNormalizer( String oid ); DeepTrimToLowerNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeNullValue() throws Exception { assertNull( normalizer.normalize( null ) ); } | @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeNonNullValue() throws Exception { assertEquals( "TRUE", normalizer.normalize( "true" ) ); assertEquals( "ABC", normalizer.normalize( "aBc" ) ); assertEquals( "FALSE", normalizer.normalize( "falsE" ) ); } | @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testNormalizeValueWithSpaces() throws Exception { assertEquals( "TRUE", normalizer.normalize( " tRuE " ) ); } | @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } | BooleanNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapInvalidDnException { if ( value == null ) { return null; } return Strings.upperCase( value.trim() ); } BooleanNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertionType ); } |
@Test public void testTelephoneNumberNormalizerNull() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( null, normalizer.normalize( ( String ) null ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testTelephoneNumberNormalizerEmpty() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "", normalizer.normalize( "" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testTelephoneNumberNormalizerOneSpace() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "", normalizer.normalize( " " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testTrimLeft() { assertEquals( "", Strings.trimLeft( ( String ) null ) ); assertEquals( "", Strings.trimLeft( "" ) ); assertEquals( "", Strings.trimLeft( " " ) ); assertEquals( "", Strings.trimLeft( " " ) ); assertEquals( "a ", Strings.trimLeft( "a " ) ); assertEquals( "a", Strings.trimLeft( " a" ) ); assertEquals( "a ", Strings.trimLeft( " a " ) ); } | public static String trimLeft( String str ) { if ( isEmpty( str ) ) { return ""; } int start = 0; int end = str.length(); while ( ( start < end ) && ( str.charAt( start ) == ' ' ) ) { start++; } return start == 0 ? str : str.substring( start ); } | Strings { public static String trimLeft( String str ) { if ( isEmpty( str ) ) { return ""; } int start = 0; int end = str.length(); while ( ( start < end ) && ( str.charAt( start ) == ' ' ) ) { start++; } return start == 0 ? str : str.substring( start ); } } | Strings { public static String trimLeft( String str ) { if ( isEmpty( str ) ) { return ""; } int start = 0; int end = str.length(); while ( ( start < end ) && ( str.charAt( start ) == ' ' ) ) { start++; } return start == 0 ? str : str.substring( start ); } private Strings(); } | Strings { public static String trimLeft( String str ) { if ( isEmpty( str ) ) { return ""; } int start = 0; int end = str.length(); while ( ( start < end ) && ( str.charAt( start ) == ' ' ) ) { start++; } return start == 0 ? str : str.substring( start ); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static String trimLeft( String str ) { if ( isEmpty( str ) ) { return ""; } int start = 0; int end = str.length(); while ( ( start < end ) && ( str.charAt( start ) == ' ' ) ) { start++; } return start == 0 ? str : str.substring( start ); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void testNewOidEmpty() { try { Oid.fromBytes( new byte[] {} ); fail( "Should not reach this point ..." ); } catch ( DecoderException de ) { assertTrue( true ); } } | public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } private Oid( String oidString, byte[] oidBytes ); } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } private Oid( String oidString, byte[] oidBytes ); @Override boolean equals( Object other ); static Oid fromBytes( byte[] oidBytes ); static Oid fromString( String oidString ); int getEncodedLength(); @Override int hashCode(); static boolean isOid( String oidString ); byte[] toBytes(); @Override String toString(); void writeBytesTo( ByteBuffer buffer ); void writeBytesTo( OutputStream outputStream ); } | Oid { public static Oid fromBytes( byte[] oidBytes ) throws DecoderException { if ( ( oidBytes == null ) || ( oidBytes.length < 1 ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } StringBuilder builder = new StringBuilder(); long value = 0; int valStart = 0; int valLength = 0; boolean firstArc = true; for ( int i = 0; i < oidBytes.length; i++ ) { value |= oidBytes[i] & 0x7F; if ( oidBytes[i] < 0 ) { value = value << 7; valLength++; } else { valLength++; if ( valLength > 8 ) { int nbBytes = valLength * 7 / 8; if ( valLength % 7 != 0 ) { nbBytes++; } byte[] result = new byte[nbBytes]; int pos = nbBytes - 1; int valEnd = valStart + valLength - 1; int j = 0; while ( j < valLength - 8 ) { result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 1] << 7 ) | ( oidBytes[valEnd - j] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 2] << 6 ) | ( ( oidBytes[valEnd - j - 1] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 3] << 5 ) | ( ( oidBytes[valEnd - j - 2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 4] << 4 ) | ( ( oidBytes[valEnd - j - 3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 5] << 3 ) | ( ( oidBytes[valEnd - j - 4] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 6] << 2 ) | ( ( oidBytes[valEnd - j - 5] & 0x60 ) >> 5 ) ); result[pos--] = ( byte ) ( ( oidBytes[valEnd - j - 7] << 1 ) | ( ( oidBytes[valEnd - j - 6] & 0x40 ) >> 6 ) ); j += 8; } switch ( valLength - j ) { case 7 : result[pos--] = ( byte ) ( ( oidBytes[5] << 7 ) | ( oidBytes[6] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[4] << 6 ) | ( ( oidBytes[5] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 5 ) | ( ( oidBytes[4] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 4 ) | ( ( oidBytes[3] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 3 ) | ( ( oidBytes[2] & 0x70 ) >> 4 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 2 ) | ( ( oidBytes[1] & 0x60 ) >> 5 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x40 ) >> 6 ); break; case 6 : result[pos--] = ( byte ) ( ( oidBytes[4] << 7 ) | ( oidBytes[5] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[3] << 6 ) | ( ( oidBytes[4] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 5 ) | ( ( oidBytes[3] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 4 ) | ( ( oidBytes[2] & 0x78 ) >> 3 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 3 ) | ( ( oidBytes[1] & 0x70 ) >> 4 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x60 ) >> 5 ); break; case 5 : result[pos--] = ( byte ) ( ( oidBytes[3] << 7 ) | ( oidBytes[4] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[2] << 6 ) | ( ( oidBytes[3] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 5 ) | ( ( oidBytes[2] & 0x7C ) >> 2 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 4 ) | ( ( oidBytes[1] & 0x78 ) >> 3 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x70 ) >> 4 ); break; case 4 : result[pos--] = ( byte ) ( ( oidBytes[2] << 7 ) | ( oidBytes[3] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[1] << 6 ) | ( ( oidBytes[2] & 0x7E ) >> 1 ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 5 ) | ( ( oidBytes[1] & 0x7C ) >> 2 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x78 ) >> 3 ); break; case 3 : result[pos--] = ( byte ) ( ( oidBytes[1] << 7 ) | ( oidBytes[2] & 0x7F ) ); result[pos--] = ( byte ) ( ( oidBytes[0] << 6 ) | ( ( oidBytes[1] & 0x7E ) >> 1 ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7C ) >> 2 ); break; case 2 : result[pos--] = ( byte ) ( ( oidBytes[0] << 7 ) | ( oidBytes[1] & 0x7F ) ); result[pos] = ( byte ) ( ( oidBytes[0] & 0x7E ) >> 1 ); break; case 1 : result[pos] = ( byte ) ( oidBytes[0] & 0x7F ); break; default : break; } BigInteger bigInteger; if ( ( result[0] & 0x80 ) == 0x80 ) { byte[] newResult = new byte[result.length + 1]; System.arraycopy( result, 0, newResult, 1, result.length ); result = newResult; } bigInteger = new BigInteger( result ); if ( firstArc ) { bigInteger = bigInteger.subtract( JOINT_ISO_ITU_T ); builder.append( '2' ); } builder.append( '.' ).append( bigInteger.toString() ); } else { if ( firstArc ) { if ( value >= 80 ) { builder.append( '2' ); value = value - 80; } else { long one = value / 40; long two = value % 40; if ( ( one < 0 ) || ( one > 2 ) || ( two < 0 ) || ( ( one < 2 ) && ( two > 39 ) ) ) { throw new DecoderException( I18n.err( I18n.ERR_00003_INVALID_OID, Arrays.toString( oidBytes ) ) ); } if ( one < 2 ) { builder.append( one ); value = two; } } firstArc = false; } builder.append( '.' ).append( value ); } valStart = i; valLength = 0; value = 0; } } return new Oid( builder.toString(), oidBytes ); } private Oid( String oidString, byte[] oidBytes ); @Override boolean equals( Object other ); static Oid fromBytes( byte[] oidBytes ); static Oid fromString( String oidString ); int getEncodedLength(); @Override int hashCode(); static boolean isOid( String oidString ); byte[] toBytes(); @Override String toString(); void writeBytesTo( ByteBuffer buffer ); void writeBytesTo( OutputStream outputStream ); } |
@Test public void testTelephoneNumberNormalizerTwoSpaces() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "", normalizer.normalize( " " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testTelephoneNumberNormalizerNSpaces() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "", normalizer.normalize( " " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testTelephoneNumberNormalizerOneHyphen() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "", normalizer.normalize( "-" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testTelephoneNumberNormalizerTwoHyphen() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "", normalizer.normalize( "--" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testTelephoneNumberNormalizerHyphensSpaces() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "", normalizer.normalize( " -- - -- " ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testInsignifiantSpacesStringOneChar() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "1", normalizer.normalize( "1" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testInsignifiantSpacesStringTwoChars() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "11", normalizer.normalize( "11" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testInsignifiantSpacesStringNChars() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "123456", normalizer.normalize( "123456" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testInsignifiantTelephoneNumberCharsSpaces() throws LdapException { Normalizer normalizer = new TelephoneNumberNormalizer(); assertEquals( "1", normalizer.normalize( " 1" ) ); assertEquals( "1", normalizer.normalize( "1 " ) ); assertEquals( "1", normalizer.normalize( " 1 " ) ); assertEquals( "11", normalizer.normalize( "1 1" ) ); assertEquals( "11", normalizer.normalize( " 1 1" ) ); assertEquals( "11", normalizer.normalize( "1 1 " ) ); assertEquals( "11", normalizer.normalize( "1 1" ) ); assertEquals( "11", normalizer.normalize( " 1 1 " ) ); assertEquals( "123456789", normalizer.normalize( " 123 456 789 " ) ); assertEquals( "1", normalizer.normalize( "-1" ) ); assertEquals( "1", normalizer.normalize( "1-" ) ); assertEquals( "1", normalizer.normalize( "-1-" ) ); assertEquals( "11", normalizer.normalize( "1-1" ) ); assertEquals( "11", normalizer.normalize( "-1-1" ) ); assertEquals( "11", normalizer.normalize( "1-1-" ) ); assertEquals( "11", normalizer.normalize( "1--1" ) ); assertEquals( "11", normalizer.normalize( "-1---1-" ) ); assertEquals( "1(2)+3456789", normalizer.normalize( "---1(2)+3 456- 789 --" ) ); } | @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } | TelephoneNumberNormalizer extends Normalizer { @Override public String normalize( String value ) throws LdapException { return normalize( value, PrepareString.AssertionType.ATTRIBUTE_VALUE ); } TelephoneNumberNormalizer(); @Override String normalize( String value ); @Override String normalize( String value, PrepareString.AssertionType assertiontype ); } |
@Test public void testEqualsNull() throws Exception { assertFalse( objectClassA.equals( null ) ); } | @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); boolean isValidSyntax( Object value ); void setSchemaManager( SchemaManager schemaManager ); @Override boolean equals( Object o ); @Override String toString(); } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); boolean isValidSyntax( Object value ); void setSchemaManager( SchemaManager schemaManager ); @Override boolean equals( Object o ); @Override String toString(); static final long serialVersionUID; } |
@Test public void testTrimRight() { assertEquals( "", Strings.trimRight( ( String ) null ) ); assertEquals( "", Strings.trimRight( "" ) ); assertEquals( "", Strings.trimRight( " " ) ); assertEquals( "", Strings.trimRight( " " ) ); assertEquals( "a", Strings.trimRight( "a " ) ); assertEquals( " a", Strings.trimRight( " a" ) ); assertEquals( " a", Strings.trimRight( " a " ) ); } | public static String trimRight( String str ) { if ( isEmpty( str ) ) { return ""; } int length = str.length(); int end = length; while ( ( end > 0 ) && ( str.charAt( end - 1 ) == ' ' ) ) { if ( ( end > 1 ) && ( str.charAt( end - 2 ) == '\\' ) ) { break; } end--; } return end == length ? str : str.substring( 0, end ); } | Strings { public static String trimRight( String str ) { if ( isEmpty( str ) ) { return ""; } int length = str.length(); int end = length; while ( ( end > 0 ) && ( str.charAt( end - 1 ) == ' ' ) ) { if ( ( end > 1 ) && ( str.charAt( end - 2 ) == '\\' ) ) { break; } end--; } return end == length ? str : str.substring( 0, end ); } } | Strings { public static String trimRight( String str ) { if ( isEmpty( str ) ) { return ""; } int length = str.length(); int end = length; while ( ( end > 0 ) && ( str.charAt( end - 1 ) == ' ' ) ) { if ( ( end > 1 ) && ( str.charAt( end - 2 ) == '\\' ) ) { break; } end--; } return end == length ? str : str.substring( 0, end ); } private Strings(); } | Strings { public static String trimRight( String str ) { if ( isEmpty( str ) ) { return ""; } int length = str.length(); int end = length; while ( ( end > 0 ) && ( str.charAt( end - 1 ) == ' ' ) ) { if ( ( end > 1 ) && ( str.charAt( end - 2 ) == '\\' ) ) { break; } end--; } return end == length ? str : str.substring( 0, end ); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static String trimRight( String str ) { if ( isEmpty( str ) ) { return ""; } int length = str.length(); int end = length; while ( ( end > 0 ) && ( str.charAt( end - 1 ) == ' ' ) ) { if ( ( end > 1 ) && ( str.charAt( end - 2 ) == '\\' ) ) { break; } end--; } return end == length ? str : str.substring( 0, end ); } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void testNotEqualDiffValue() throws Exception { assertFalse( objectClassA.equals( objectClassC ) ); assertFalse( objectClassC.equals( objectClassA ) ); } | @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); boolean isValidSyntax( Object value ); void setSchemaManager( SchemaManager schemaManager ); @Override boolean equals( Object o ); @Override String toString(); } | SyntaxChecker extends LoadableSchemaObject { @Override public boolean equals( Object o ) { if ( !super.equals( o ) ) { return false; } return o instanceof SyntaxChecker; } protected SyntaxChecker( String oid ); protected SyntaxChecker(); boolean isValidSyntax( Object value ); void setSchemaManager( SchemaManager schemaManager ); @Override boolean equals( Object o ); @Override String toString(); static final long serialVersionUID; } |
@Test public void testEscapeBackSlash() throws IOException { String result = PrepareString.normalize( "C:\\a\\b\\c" ); System.out.println( result ); } | public static String normalize( String value ) { if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) ) { return Normalizer.normalize( value, Normalizer.Form.NFKC ); } else { return value; } } | PrepareString { public static String normalize( String value ) { if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) ) { return Normalizer.normalize( value, Normalizer.Form.NFKC ); } else { return value; } } } | PrepareString { public static String normalize( String value ) { if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) ) { return Normalizer.normalize( value, Normalizer.Form.NFKC ); } else { return value; } } private PrepareString(); } | PrepareString { public static String normalize( String value ) { if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) ) { return Normalizer.normalize( value, Normalizer.Form.NFKC ); } else { return value; } } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String normalize( String value ) { if ( !Normalizer.isNormalized( value, Normalizer.Form.NFKC ) ) { return Normalizer.normalize( value, Normalizer.Form.NFKC ); } else { return value; } } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialNull() throws InvalidCharacterException { char[] empty = null; assertEquals( " ", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialEmpty() throws InvalidCharacterException { char[] empty = new char[]{}; assertEquals( " ", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ ' ' }; assertEquals( " ", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', ' '}; assertEquals( " ", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialA() throws InvalidCharacterException { char[] empty = new char[]{ 'a' }; assertEquals( " a", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialABC() throws InvalidCharacterException { char[] empty = new char[]{ 'a', 'b', 'c' }; assertEquals( " abc", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialOneSpaceA() throws InvalidCharacterException { char[] empty = new char[]{ ' ', 'a' }; assertEquals( " a", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialNSpacesA() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', 'a' }; assertEquals( " a", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void testAreEqualsFull() { assertEquals( 6, Strings.areEquals( AZERTY, 0, "azerty" ) ); } | public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void insignificantSpacesStringInitialOneSpaceABC() throws InvalidCharacterException { char[] empty = new char[]{ ' ', 'a', 'b', 'c' }; assertEquals( " abc", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialNSpacesABC() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', 'a', 'b', 'c' }; assertEquals( " abc", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialInnerOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', 'b', ' ', 'c' }; assertEquals( " a b c", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialInnerNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', 'b', ' ', ' ', ' ', ' ', 'c' }; assertEquals( " a b c", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialEndingOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ' }; assertEquals( " a ", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialEndingNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', ' ' }; assertEquals( " a ", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringInitialAll() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', 'b', ' ', ' ', ' ', ' ', 'c', ' ', ' ', ' ' }; assertEquals( " a b c ", PrepareString.insignificantSpacesStringInitial( empty ) ); } | public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringInitial( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalNull() throws InvalidCharacterException { char[] empty = null; assertEquals( " ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalEmpty() throws InvalidCharacterException { char[] empty = new char[]{}; assertEquals( " ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ ' ' }; assertEquals( " ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void testAreEqualsDiff() { assertEquals( -1, Strings.areEquals( AZERTY, 0, "Azerty" ) ); } | public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void insignificantSpacesStringFinalNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', ' '}; assertEquals( " ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalA() throws InvalidCharacterException { char[] empty = new char[]{ 'a' }; assertEquals( "a ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalABC() throws InvalidCharacterException { char[] empty = new char[]{ 'a', 'b', 'c' }; assertEquals( "abc ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalAOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ' }; assertEquals( "a ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalANSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', ' ' }; assertEquals( "a ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalABCOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', 'b', 'c', ' ' }; assertEquals( "abc ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalABCNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', 'b', 'c', ' ', ' ', ' ' }; assertEquals( "abc ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalInnerOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', 'b', ' ', 'c' }; assertEquals( "a b c ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalInnerNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', 'b', ' ', ' ', ' ', ' ', 'c' }; assertEquals( "a b c ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalStartingOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ ' ', 'a' }; assertEquals( " a ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void testAreEqualsEmpty() { assertEquals( -1, Strings.areEquals( AZERTY, 0, "" ) ); } | public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void insignificantSpacesStringFinalStartingNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', 'a'}; assertEquals( " a ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringFinalAll() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', 'a', ' ', ' ', 'b', ' ', ' ', ' ', ' ', 'c', ' ', 'd' }; assertEquals( " a b c d ", PrepareString.insignificantSpacesStringFinal( empty ) ); } | public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringFinal( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { target[newPos++] = ' '; normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyNull() throws InvalidCharacterException { char[] empty = null; assertEquals( " ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyEmpty() throws InvalidCharacterException { char[] empty = new char[]{}; assertEquals( " ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ ' ' }; assertEquals( " ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', ' '}; assertEquals( " ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyA() throws InvalidCharacterException { char[] empty = new char[]{ 'a' }; assertEquals( "a", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyABC() throws InvalidCharacterException { char[] empty = new char[]{ 'a', 'b', 'c' }; assertEquals( "abc", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyAOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ' }; assertEquals( "a ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyANSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', ' ' }; assertEquals( "a ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void testAreEqualsFirstCharDiff() { assertEquals( -1, Strings.areEquals( AZERTY, 0, "Azerty" ) ); } | public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void insignificantSpacesStringAnyOneSpaceA() throws InvalidCharacterException { char[] empty = new char[]{ ' ', 'a' }; assertEquals( " a", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyNSpacesA() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', 'a' }; assertEquals( " a", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyABCOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', 'b', 'c', ' ' }; assertEquals( "abc ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyABCNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', 'b', 'c', ' ', ' ', ' ' }; assertEquals( "abc ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyOneSpaceABC() throws InvalidCharacterException { char[] empty = new char[]{ ' ', 'a', 'b', 'c' }; assertEquals( " abc", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyNSpacesABC() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', 'a', 'b', 'c' }; assertEquals( " abc", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyInnerOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', 'b', ' ', 'c' }; assertEquals( "a b c", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyInnerNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', 'b', ' ', ' ', ' ', ' ', 'c' }; assertEquals( "a b c", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyStartingOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ ' ', 'a' }; assertEquals( " a", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyStartingNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ ' ', ' ', ' ', 'a'}; assertEquals( " a", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void testAreEqualsMiddleCharDiff() { assertEquals( -1, Strings.areEquals( AZERTY, 0, "azeRty" ) ); } | public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); } | Strings { public static boolean areEquals( String string, int index, String text ) { if ( ( string == null ) || ( text == null ) ) { return false; } int length1 = string.length(); int length2 = text.length(); if ( ( length1 == 0 ) || ( length1 <= index ) || ( index < 0 ) || ( length2 == 0 ) || ( length2 > ( length1 + index ) ) ) { return false; } else { return string.substring( index ).startsWith( text ); } } private Strings(); static String dumpBytes( byte[] buffer ); static String byteToString( byte b ); static String dumpByte( byte octet ); static char dumpHex( byte hex ); static String dumpHexPairs( byte[] buffer ); static String deepTrim( String str, boolean toLowerCase ); static String deepTrimToLower( String string ); static String deepTrim( String string ); static String trimConsecutiveToOne( String str, char ch ); static String centerTrunc( String str, int head, int tail ); static String toHexString( byte[] res ); static byte[] toByteArray( String hexString ); static String formatHtml( String source, boolean replaceNl, boolean replaceTag,
boolean replaceQuote ); static boolean areEquals( String string, int index, String text ); static boolean isCharASCII( byte[] byteArray, int index, char car ); static boolean isCharASCII( char[] charArray, int index, char car ); static boolean isCharASCII( String string, int index, char car ); static String utf8ToString( byte[] bytes ); static String utf8ToString( byte[] bytes, int length ); static String utf8ToString( byte[] bytes, int start, int length ); static int areEquals( byte[] bytes, int index, String text ); static int areEquals( char[] chars, int index, String text ); static int areEquals( char[] chars, int index, String text, boolean caseSensitive ); static int areEquals( char[] chars, int index, char[] chars2 ); static int areEquals( char[] chars, int index, char[] chars2, boolean caseSensitive ); static int areEquals( byte[] bytes, int index, byte[] bytes2 ); static boolean isEmpty( String str ); static boolean isEmpty( byte[] bytes ); static String trim( String str ); static byte[] trim( byte[] bytes ); static String trimLeft( String str ); static int trimLeft( char[] chars, int pos ); static void trimLeft( String string, Position pos ); static void trimLeft( byte[] bytes, Position pos ); static int trimLeft( byte[] bytes, int pos ); static String trimRight( String str ); static String trimRight( String str, int escapedSpace ); static int trimRight( char[] chars, int pos ); static String trimRight( String string, Position pos ); static String trimRight( byte[] bytes, Position pos ); static int trimRight( byte[] bytes, int pos ); static char charAt( String string, int index ); static byte byteAt( byte[] bytes, int index ); static char charAt( char[] chars, int index ); static String asciiBytesToString( byte[] bytes ); static byte[] getBytesUtf8( String string ); static byte[] getBytesUtf8Ascii( String string ); static String getDefaultCharsetName(); static boolean equals( String str1, String str2 ); static String listToString( List<?> list ); static String setToString( Set<?> set ); static String listToString( List<?> list, String tabs ); static String mapToString( Map<?, ?> map ); static String mapToString( Map<?, ?> map, String tabs ); @Deprecated static String toLowerCase( String value ); static String toLowerCaseAscii( String value ); static String toLowerCase( byte[] value ); @Deprecated static String toUpperCase( String value ); static String toUpperCaseAscii( String value ); static String upperCase( String str ); static String lowerCase( String str ); static String lowerCaseAscii( String str ); static boolean isPrintableString( String str ); static boolean isNotEmpty( String str ); static boolean isIA5String( String str ); static boolean isValidUuid( String uuid ); static String uuidToString( byte[] bytes ); static byte[] uuidToBytes( String string ); static byte[] copy( byte[] value ); static String getString( final byte[] data, int offset, int length, String charset ); static String getString( final byte[] data, int offset, int length, Charset charset ); static String getString( final byte[] data, String charset ); static String getString( final byte[] data, Charset charset ); static String getUUID( long value ); static int parseInt( String value ); static int compare( byte[] b1, byte[] b2 ); static final byte[] HEX_CHAR; static final byte[] EMPTY_BYTES; static final String EMPTY_STRING; static final String[] EMPTY_STRING_ARRAY; } |
@Test public void insignificantSpacesStringAnyEndingOneSpace() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ' }; assertEquals( "a ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
@Test public void insignificantSpacesStringAnyEndingNSpaces() throws InvalidCharacterException { char[] empty = new char[]{ 'a', ' ', ' ', ' ' }; assertEquals( "a ", PrepareString.insignificantSpacesStringAny( empty ) ); } | public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); } | PrepareString { public static String insignificantSpacesStringAny( char[] origin ) { if ( origin == null ) { return " "; } int pos = 0; char[] target = new char[origin.length * 2 + 1]; int newPos = 0; NormStateEnum normState = NormStateEnum.START; while ( normState != NormStateEnum.END ) { switch ( normState ) { case START : if ( pos == origin.length ) { return " "; } char c = origin[pos]; if ( c == ' ' ) { pos++; normState = NormStateEnum.INITIAL_SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case INITIAL_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; case INITIAL_SPACES : if ( pos == origin.length ) { return " "; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.INITIAL_CHAR; } break; case CHARS : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { target[newPos++] = ' '; pos++; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; } break; case SPACES : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; } else { target[newPos++] = ' '; target[newPos++] = c; pos++; normState = NormStateEnum.SPACE_CHAR; } break; case SPACE_CHAR : if ( pos == origin.length ) { normState = NormStateEnum.END; break; } c = origin[pos]; if ( c == ' ' ) { pos++; target[newPos++] = ' '; normState = NormStateEnum.SPACES; } else { target[newPos++] = c; pos++; normState = NormStateEnum.CHARS; } break; default : break; } } return new String( target, 0, newPos ); } private PrepareString(); static String transcode( byte[] bytes ); static String normalize( String value ); static String mapCaseSensitive( String unicode ); static void checkProhibited( char[] value ); static String insignificantNumericStringHandling( char[] source ); static String insignificantTelephoneNumberStringHandling( char[] source ); static String insignificantSpacesStringValue( char[] origin ); static String insignificantSpacesStringInitial( char[] origin ); static String insignificantSpacesStringAny( char[] origin ); static String insignificantSpacesStringFinal( char[] origin ); static String mapIgnoreCase( String unicode ); static final boolean CASE_SENSITIVE; static final boolean IGNORE_CASE; } |
Subsets and Splits