private static char[] getCharsFromStringBuilder(StringBuilder sbuf) { final int length = sbuf.length(); char[] array2 = new char[length]; sbuf.getChars(0, length, array2, 0); return array2; }
public Lexer(StringBuilder content, String fileName) { int len = content.length(); buf = new char[len + 1]; content.getChars(0, content.length(), buf, 0); buf[len] = EOF; this.fileName = fileName; }
/** * Reads characters into an array. * * @param pos The position of this file to start reading from * @param cbuf Destination buffer * @param off Offset at which to start storing characters * @param len Maximum number of characters to read (> 0) * @return The number of characters read (0 if no characters remain) * @see java.io.Reader#read(char[], int, int) */ public int read( int pos, char[] cbuf, int off, int len ) { len = Math.min( content.length() - pos, len ); content.getChars( pos, pos + len, cbuf, off ); return len; } }
public char[] generateParameter(Table table, int current) { StringBuilder sb = new StringBuilder(); int i = 0; for (String d : delimiterList) { sb.append(d); int[] offset = offsetList.get(i++); sb.append(table.get(current + offset[0], offset[1])); } char[] o = new char[sb.length()]; sb.getChars(0, sb.length(), o, 0); return o; }
/** * Creates a {@code String} from the contents of the specified {@code * StringBuilder}. * * @throws NullPointerException * if {@code stringBuilder == null}. * @since 1.5 */ public String(StringBuilder stringBuilder) { if (stringBuilder == null) { throw new NullPointerException("stringBuilder == null"); } this.offset = 0; this.count = stringBuilder.length(); this.value = new char[this.count]; stringBuilder.getChars(0, this.count, this.value, 0); }
protected char[] getEscapeChars( boolean includeSingleQuote, boolean includeDoubleQuote ) { StringBuilder buf = new StringBuilder( 2 ); if ( includeSingleQuote ) { buf.append( '\'' ); } if ( includeDoubleQuote ) { buf.append( '\"' ); } char[] result = new char[buf.length()]; buf.getChars( 0, buf.length(), result, 0 ); return result; }
public void write(StringBuilder stringBuilder, int offset, int len) throws IOException { while (len > chars.length) { write(stringBuilder, offset, chars.length); offset += chars.length; len -= chars.length; } stringBuilder.getChars(offset, offset + len, chars, 0); out.write(chars, 0, len); }
/** * Encode the given {@link Password} to a char array. * * @param password the password to encode * @return a char array representing the encoded password * @throws InvalidKeySpecException if the given password is not supported or could be encoded */ public static char[] encode(Password password) throws InvalidKeySpecException { StringBuilder b = getCryptStringToBuilder(password); char[] chars = new char[b.length()]; b.getChars(0, b.length(), chars, 0); return chars; }
public char[] getChars() { if (chars != null) { return chars; } synchronized (this) { if (chars != null) { return chars; } if (content != null) { char[] charsTemp = new char[content.length()]; content.getChars(0, content.length(), charsTemp, 0); chars = charsTemp; content = null; return chars; } else { String strTemp = new String(bytes, charset); char[] charsTemp = new char[strTemp.length()]; strTemp.getChars(0, strTemp.length(), charsTemp, 0); chars = charsTemp; return chars; } } }
public void write(StringBuilder stringBuilder, int offset, int len) throws IOException { while (len > chars.length) { write(stringBuilder, offset, chars.length); offset += chars.length; len -= chars.length; } stringBuilder.getChars(offset, offset + len, chars, 0); int byteLen = encoder.encode(chars, 0, len, bytes); out.write(bytes, 0, byteLen); }
public ExprLexer(ParaToken paraToken, Location location) { this.location = location; StringBuilder content = paraToken.getContent(); beginRow = paraToken.getRow(); forwardRow = beginRow; if (content == null) { buf = new char[]{EOF}; return ; } int len = content.length(); buf = new char[len + 1]; content.getChars(0, content.length(), buf, 0); buf[len] = EOF; }
p.getChars(p.length() - 3, p.length(), data, 0); return f.append(data).toString();
@Override public final CharTermAttribute append(StringBuilder s) { if (s == null) // needed for Appendable compliance return appendNull(); final int len = s.length(); s.getChars(0, len, resizeBuffer(termLength + len), termLength); termLength += len; return this; }
((String) csq).getChars(0, len, this.value, index); } else if (csq instanceof StringBuilder) { ((StringBuilder) csq).getChars(0, len, this.value, index); } else if (csq instanceof StringBuffer) { ((StringBuffer) csq).getChars(0, len, this.value, index);
((String) csq).getChars(0, len, this.value, index); } else if (csq instanceof StringBuilder) { ((StringBuilder) csq).getChars(0, len, this.value, index); } else if (csq instanceof StringBuffer) { ((StringBuffer) csq).getChars(0, len, this.value, index);
/** * Appends a StringBuilder to this string builder. * Appending null will call {@link #appendNull()}. * * @param str the StringBuilder to append * @return this, to enable chaining * @since 3.2 */ public StrBuilder append(final StringBuilder str) { if (str == null) { return appendNull(); } final int strLen = str.length(); if (strLen > 0) { final int len = length(); ensureCapacity(len + strLen); str.getChars(0, strLen, buffer, len); size += strLen; } return this; }
public RootNode parseInternal(StringBuilderVar block) { char[] chars = block.getChars(); int[] ixMap = new int[chars.length + 1]; // map of cleaned indices to original indices // strip out CROSSED_OUT characters and build index map StringBuilder clean = new StringBuilder(); for (int i = 0; i < chars.length; i++) { char c = chars[i]; if (c != CROSSED_OUT) { ixMap[clean.length()] = i; clean.append(c); } } ixMap[clean.length()] = chars.length; // run inner parse char[] cleaned = new char[clean.length()]; clean.getChars(0, cleaned.length, cleaned, 0); RootNode rootNode = parseInternal(cleaned); // correct AST indices with index map fixIndices(rootNode, ixMap); return rootNode; }
_pad = ' '; prefix.getChars(0, _prefix.length, _prefix, 0);
/** * Appends part of a StringBuilder to this string builder. * Appending null will call {@link #appendNull()}. * * @param str the StringBuilder to append * @param startIndex the start index, inclusive, must be valid * @param length the length to append, must be valid * @return this, to enable chaining * @since 3.2 */ public StrBuilder append(final StringBuilder str, final int startIndex, final int length) { if (str == null) { return appendNull(); } if (startIndex < 0 || startIndex > str.length()) { throw new StringIndexOutOfBoundsException("startIndex must be valid"); } if (length < 0 || (startIndex + length) > str.length()) { throw new StringIndexOutOfBoundsException("length must be valid"); } if (length > 0) { final int len = length(); ensureCapacity(len + length); str.getChars(startIndex, startIndex + length, buffer, len); size += length; } return this; }
((String) csq).getChars(start, end, termBuffer, termLength); } else if (csq instanceof StringBuilder) { ((StringBuilder) csq).getChars(start, end, termBuffer, termLength); } else if (csq instanceof CharTermAttribute) { System.arraycopy(((CharTermAttribute) csq).buffer(), start, termBuffer, termLength, len);