/** * Appends the specified character sequence. * The default implementation delegates to {@link #append(CharSequence, int, int)}. * * @param sequence the character sequence to append, or {@code null}. * @return a reference to this {@code Appendable}. * @throws IOException if an I/O error occurred. */ @Override public Appendable append(CharSequence sequence) throws IOException { if (sequence == null) { sequence = "null"; } return append(sequence, 0, sequence.length()); }
/** * Appends the specified character sequence. * The default implementation delegates to {@link #append(CharSequence, int, int)}. * * @param sequence the character sequence to append, or {@code null}. * @return a reference to this {@code Appendable}. * @throws IOException if an I/O error occurred. */ @Override public Appendable append(CharSequence sequence) throws IOException { if (sequence == null) { sequence = "null"; } return append(sequence, 0, sequence.length()); }
/** * If the given sequence begins with a low surrogate completing a previous high surrogate, * delegates to {@link #append(char)} and returns {@code start+1}. The intent is to avoid * processing a character sequence which starts by an invalid code point. * * @param sequence the character sequence to write. * @param start index of the first character to write by this method or by the caller. * @param end index after the last character to be written by the caller. * @return index of the first character which need to be written by the caller. */ final int appendSurrogate(final CharSequence sequence, int start, final int end) throws IOException { if (start != end && highSurrogate != 0) { final char c = sequence.charAt(start); if (Character.isLowSurrogate(c)) { append(c); start++; } else { throw new CharConversionException(); } } return start; }
/** * If the given sequence begins with a low surrogate completing a previous high surrogate, * delegates to {@link #append(char)} and returns {@code start+1}. The intend is to avoid * processing a character sequence which starts by an invalid code point. * * @param sequence the character sequence to write. * @param start index of the first character to write by this method or by the caller. * @param end index after the last character to be written by the caller. * @return index of the first character which need to be written by the caller. */ final int appendSurrogate(final CharSequence sequence, int start, final int end) throws IOException { if (start != end && highSurrogate != 0) { final char c = sequence.charAt(start); if (Character.isLowSurrogate(c)) { append(c); start++; } else { throw new CharConversionException(); } } return start; }