@Universal public static char[] add( char[] array, String str ) { return add( array, str.toCharArray() ); }
@Universal public static char[] add( char[] array, String str ) { return add( array, str.toCharArray() ); }
@Universal public static char[] add( char[] array, String str ) { return add( array, str.toCharArray() ); }
/** * remove chars from a string * @param string string to split * @param delimiters delimeters to remove * @return the split up string */ public static String removeChars( final String string, final char... delimiters ) { char[][] comps = CharScanner.splitByCharsNoneEmpty( FastStringUtils.toCharArray( string ), delimiters ); return new String(Chr.add ( comps )); }
/** * remove chars from a string * @param string string to split * @param delimiters delimeters to remove * @return the split up string */ public static String removeChars( final String string, final char... delimiters ) { char[][] comps = CharScanner.splitByCharsNoneEmpty( FastStringUtils.toCharArray( string ), delimiters ); return new String(Chr.add ( comps )); }
/** * remove chars from a string * @param string string to split * @param delimiters delimeters to remove * @return the split up string */ public static String removeChars( final String string, final char... delimiters ) { char[][] comps = CharScanner.splitByCharsNoneEmpty( FastStringUtils.toCharArray( string ), delimiters ); return new String(Chr.add ( comps )); }
@Universal public static char[] add( char[] array, StringBuilder stringBuilder ) { return add( array, getCharsFromStringBuilder( stringBuilder ) ); }
@Universal public static char[] add( char[] array, StringBuilder stringBuilder ) { return add( array, getCharsFromStringBuilder( stringBuilder ) ); }
@Universal public static char[] add( char[] array, StringBuilder stringBuilder ) { return add( array, getCharsFromStringBuilder( stringBuilder ) ); }
@Universal public static char[] insert( final char[] array, final int idx, final char v ) { Exceptions.requireNonNull( array ); if ( idx >= array.length ) { return add( array, v ); } final int index = calculateIndex( array, idx ); //Object newArray = Array.newInstance(array.getClass().getComponentType(), array.length+1); char[] newArray = new char[ array.length + 1 ]; if ( index != 0 ) { /* Copy up to the length in the array before the index. */ /* src sbegin dst dbegin length of copy */ arraycopy ( array, 0, newArray, 0, index ); } boolean lastIndex = index == array.length - 1; int remainingIndex = array.length - index; if ( lastIndex ) { /* Copy the area after the insert. Make sure we don't write over the end. */ /* src sbegin dst dbegin length of copy */ arraycopy ( array, index, newArray, index + 1, remainingIndex ); } else { /* Copy the area after the insert. */ /* src sbegin dst dbegin length of copy */ arraycopy ( array, index, newArray, index + 1, remainingIndex ); } newArray[ index ] = v; return newArray; }
/** * Add a char to a string * @param str string * @param c char * @return new string */ @Universal public static String add( String str, char c ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), c ) ); }
/** * Add a char to a string * @param str string * @param c char * @return new string */ @Universal public static String add( String str, char c ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), c ) ); }
/** * Add a char to a string * @param str string * @param c char * @return new string */ @Universal public static String add( String str, char c ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), c ) ); }
/** * Add one string to another * @param str string 1 * @param str2 string 2 * @return new string */ @Universal public static String add( String str, String str2 ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), FastStringUtils.toCharArray(str2) ) ); }
/** * Add one string to another * @param str string 1 * @param str2 string 2 * @return new string */ @Universal public static String add( String str, String str2 ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), FastStringUtils.toCharArray(str2) ) ); }
/** * Add one string to another * @param str string 1 * @param str2 string 2 * @return new string */ @Universal public static String add( String str, String str2 ) { return FastStringUtils.noCopyStringFromChars( Chr.add( FastStringUtils.toCharArray(str), FastStringUtils.toCharArray(str2) ) ); }
public char[] readNumber( ) { try { ensureBuffer(); char [] results = CharScanner.readNumber( readBuf, index, length); index += results.length; if (index >= length && more) { ensureBuffer(); if (length!=0) { char results2[] = readNumber(); return Chr.add(results, results2); } else { return results; } } else { return results; } } catch (Exception ex) { String str = CharScanner.errorDetails ( "readNumber issue", readBuf, index, ch ); return Exceptions.handle ( char[].class, str, ex ); } }
public char[] readNumber( ) { try { ensureBuffer(); char [] results = CharScanner.readNumber( readBuf, index, length); index += results.length; if (index >= length && more) { ensureBuffer(); if (length!=0) { char results2[] = readNumber(); return Chr.add(results, results2); } else { return results; } } else { return results; } } catch (Exception ex) { String str = CharScanner.errorDetails ( "readNumber issue", readBuf, index, ch ); return Exceptions.handle ( char[].class, str, ex ); } }
@Test public void addTest() { assertArrayEquals( array( 'a', 'b', 'c', 'd', 'e', 'f' ), add( array( 'a', 'b', 'c', 'd', 'e' ), 'f' ) ); }
@Test public void addTestArray() { assertArrayEquals( array( 'a', 'b', 'c', 'd', 'e', 'f', 'e' ), add( array( 'a', 'b', 'c', 'd', 'e' ), array( 'f', 'e' ) ) ); }