@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; }