/** * @ibm-api */ public String upto( char c ) throws IOException { FastStringBuffer b = new FastStringBuffer(); do { int cc = getChar(); if( cc<0 || cc==c ) { return b.toString(); } b.append(cc); count--; index++; position++; } while(true); }
/** * Format a string. * Format a string using a formt string and parameters. Each entry like {n} in the format string * is replaced by the actual parameter value converted to a string. * @param fmt the format string * @param p1 the first message parameter * @param p2 the second message parameter * @param p3 the third message parameter * @param p4 the fourth message parameter * @param p5 the fifth message parameter * @param p6 the sixth message parameter * @return the formatted string * @ibm-api */ public static final String format( String fmt, Object... parameters) { if( fmt!=null ) { FastStringBuffer buffer = new FastStringBuffer(); return buffer.appendFormat( fmt, parameters ).toString(); } return ""; //$NON-NLS-1$ }
/** * Format a string to be a JavaSource string. * <p> * This replace all the special characters by escape sequences. * </p> * @ibm-api */ public static String toJavaString(String s, boolean addQuotes) { FastStringBuffer b = new FastStringBuffer(); b.appendJavaString(s,addQuotes); return b.toString(); }
public final FastStringBuffer prt( String fmt, Object p1, Object p2, Object p3, Object p4, Object p5 ) { // if( prtIndent!=null ) { // append( prtIndent ); // } appendFormat( fmt, p1, p2, p3, p4, p5 ); append( '\n' ); return this; } public final FastStringBuffer prt( String fmt, Object p1, Object p2, Object p3, Object p4 ) {
/** * Read a string from a reader. * @ibm-api */ public static String readString(Reader reader) throws IOException { FastStringBuffer sb = new FastStringBuffer(); sb.load(reader); return sb.toString(); }
/** * Convert a integer to its string representation and fill with characters * on left to match the number of digits required. * If the number cannot fit in the specified digits, then the return string * is only composed of '*'. * @param value the value to be converted * @param digits the number of desired digits * @param fill the character used to fill * @return the string representing the integer * @ibm-api */ public static final String toString( int value, int digits, char fill ) { FastStringBuffer b = new FastStringBuffer(); String s = Integer.toString( value ); if( s.length()<=digits ) { b.repeat( fill, digits-s.length() ); b.append(s); } else { b.repeat( '*', digits ); } return b.toString(); } /**
public String writeToString() { FastStringBuffer b = new FastStringBuffer(4096); for( Map.Entry<String,String> e: _properties.entrySet() ) { String key = e.getKey(); String value = e.getValue(); if(b.length()>0) { b.append((char)0); } b.append(key); b.append('='); b.append(value); } return b.toString(); }
private static void encryptChar( FastStringBuffer b, int offset, char c ) { int xor = ENCRYPTION[offset%ENCRYPTION.length]; int val = ((int)c) ^ xor; char c1 = (char)((val&0x00F0)/16+(int)'A'); char c2 = (char)((val&0x000F)+(int)'A'); b.append(c1); b.append(c2); } private static char decryptChar( String pwd, int offset, int pos ) {
int newcount = count + nextObject-pos; if (newcount > value.length) { expandCapacity(newcount); int index = c1 - '0'; index = c2 - '0' + (index * 10); not_valid = addArg(args, index); append(fmt.substring(pos, pos+4)); int index = c1 - '0'; not_valid = addArg(args, index); append(fmt.substring(pos, pos+3));
/** * Appends the string representation of the <code>char</code> * argument to this string buffer. * <p> * The argument is appended to the contents of this string buffer. * The length of this string buffer increases by <code>1</code>. * * @param ch a <code>char</code>. * @return this string buffer. */ public final FastStringBuffer append(char c) { int newcount = count + 1; if (newcount > value.length) { expandCapacity(newcount); } value[count++] = c; return this; }
/** * */ public final FastStringBuffer append( FastStringBuffer b, int srcBegin, int srcEnd ) { if (b == null) { return this; } if( srcBegin>=srcEnd ) { return this; } // Ensure that the buffer is zied enough int newcount = count + srcEnd-srcBegin; if (newcount > value.length) { expandCapacity(newcount); } // Copy the desired characters b.getChars(srcBegin, srcEnd, value, count); count = newcount; return this; } public final FastStringBuffer append( FastStringBuffer b ) {
/** * Convert a integer to its string representation and fill with characters * on left to match the number of digits required. * If the number cannot fit in the specified digits, then the return string * is only composed of '*'. * @param value the value to be converted * @param digits the number of desired digits * @param fill the character used to fill * @return the string representing the integer * @ibm-api */ public static final String toString( int value, int digits, char fill ) { FastStringBuffer b = new FastStringBuffer(); String s = Integer.toString( value ); if( s.length()<=digits ) { b.repeat( fill, digits-s.length() ); b.append(s); } else { b.repeat( '*', digits ); } return b.toString(); } /**
public String writeToString() { FastStringBuffer b = new FastStringBuffer(4096); for( Map.Entry<String,String> e: _properties.entrySet() ) { String key = e.getKey(); String value = e.getValue(); if(b.length()>0) { b.append((char)0); } b.append(key); b.append('='); b.append(value); } return b.toString(); }
/** * Read a string from a reader. * @ibm-api */ public static String readString(Reader reader) throws IOException { FastStringBuffer sb = new FastStringBuffer(); sb.load(reader); return sb.toString(); }
/** * Append a repeated character. * @param toRepeat the character to repeat * @param count the number of repetition */ public final void repeat( char toRepeat, int count ) { for( int i=0; i<count; i++ ) { append(toRepeat); } }