/** * Appends a {@code CharSequence} to the {@code CharArrayWriter}. The method * works the same way as {@code write(csq.toString())}. If {@code csq} is * {@code null}, then it will be substituted with the string {@code "null"}. * * @param csq * the {@code CharSequence} appended to the {@code * CharArrayWriter}, may be {@code null}. * @return this CharArrayWriter. */ public new virtual CharArrayWriter append(java.lang.CharSequence csq) { if (null == csq) { append(new java.lang.StringJ(TOKEN_NULL), 0, TOKEN_NULL.length()); } else { append(csq, 0, csq.length()); } return(this); }
/* * Writes chars of the given {@code CharSequence} to the current position of * this buffer, and increases the position by the number of chars written. * * @param csq * the {@code CharSequence} to write. * @param start * the first char to write, must not be negative and not greater * than {@code csq.length()}. * @param end * the last char to write (excluding), must be less than * {@code start} and not greater than {@code csq.length()}. * @return this buffer. * @exception BufferOverflowException * if {@code remaining()} is less than {@code end - start}. * @exception IndexOutOfBoundsException * if either {@code start} or {@code end} is invalid. * @exception ReadOnlyBufferException * if no changes may be made to the contents of this buffer. */ public virtual CharBuffer append(java.lang.CharSequence csq, int start, int end) { if (csq == null) { //csq = "null"; return(put("null")); } java.lang.CharSequence cs = csq.subSequence(start, end); if (cs.length() > 0) { return(put(cs.toString())); } else { return(this); } }
/* * Creates a new char buffer by wrapping the given char sequence. * <p/> * The new buffer's position will be {@code start}, limit will be * {@code end}, capacity will be the length of the char sequence. The new * buffer is read-only. * * @param chseq * the char sequence which the new buffer will be based on. * @param start * the start index, must not be negative and not greater than * {@code chseq.length()}. * @param end * the end index, must be no less than {@code start} and no * greater than {@code chseq.length()}. * @return the created char buffer. * @exception IndexOutOfBoundsException * if either {@code start} or {@code end} is invalid. */ public static CharBuffer wrap(java.lang.CharSequence chseq, int start, int end) { if (chseq == null) { throw new java.lang.NullPointerException(); } if (start < 0 || end < start || end > chseq.length()) { throw new java.lang.IndexOutOfBoundsException(); } CharBuffer result = BufferFactory.newCharBuffer(chseq); result.positionJ = start; result.limitJ = end; return(result); }
internal CharSequenceAdapter(java.lang.CharSequence chseq) : base(chseq.length()) { sequence = chseq; }