Appends an XML-appropriate encoding of the given String to the given
StringBuffer.

@param in
The String to encode.
@param buf
The StringBuffer to write to.
768565
private static void enc(String in, StringBuilder out) {
        for (int i = 0; i < in.length(); i++) {
            enc(in.charAt(i), out);
        }
    }
169399
private void append(StringBuilder buffer, char c) {

		// version manually simplified
		// final boolean shouldAppend = rawOutput || escaped
		// || (c != quoteChar && c != escapeChar);
		// final boolean newEscaped = c == escapeChar && !escaped;
		// final boolean newQuoted = (c == quoteChar && !escaped) ? !quoted
		// : quoted;

		// side-effect free version directly extracted from if

		// final boolean shouldAppend = (c == escapeChar && (escaped ||
		// rawOutput))
		// || (c == quoteChar && (escaped || rawOutput))
		// || !(c == quoteChar || c == escapeChar);
		// final boolean newEscaped = c == escapeChar ? !escaped
		// : (c == quoteChar ? false : false);
		// final boolean newQuoted = c == escapeChar ? quoted
		// : (c == quoteChar ? (!escaped ? !quoted : quoted) : quoted);

		// if (shouldAppend) {
		// buffer.append(c);
		// }
		//
		// escaped = newEscaped;
		// quoted = newQuoted;

		// original version
		// XXX needed to revert to this original version as micro benchmark
		// tests
		// showed a slow down of more than 100%
		if (c == escapeChar) {
			if (escaped || rawOutput) {
				buffer.append(c);
			}
			escaped = !escaped;
		} else if (c == quoteChar) {
			if (escaped) {
				buffer.append(c);
				escaped = false;
			} else {
				quoted = !quoted;
				if (rawOutput) {
					buffer.append(c);
				}
			}
		} else {
			buffer.append(c);
			escaped = false;
		}
	}
786821
public void encode(ByteBuf buf) {

        buf.writeByte('*');
        CommandArgs.IntegerArgument.writeInteger(buf, 1 + (args != null ? args.count() : 0));

        buf.writeBytes(CommandArgs.CRLF);

        CommandArgs.BytesArgument.writeBytes(buf, type.getBytes());

        if (args != null) {
            args.encode(buf);
        }
    }
49898
public static void appendPrettyHexDump(StringBuilder dump, ByteBuf buf, int offset, int length) {
        HexUtil.appendPrettyHexDump(dump, buf, offset, length);
    }
390580
final public void write(char []buf, int offset, int length)
  {
    Writer out = this.out;
    if (out == null)
      return;

    try {
      out.write(buf, offset, length);
    } catch (IOException e) {
      log.log(Level.FINE, e.toString(), e);
    }
  }
954391
public static void encode(CharSequence in, Appendable out) throws IOException{
		encode(in, UTF_8, out);
	}
1015981
public static void append(StringBuilder buf, byte b, int base) {
        int bi = 0xff & b;
        int c = '0' + (bi / base) % base;
        if (c > '9')
            c = 'a' + (c - '0' - 10);
        buf.append((char) c);
        c = '0' + bi % base;
        if (c > '9')
            c = 'a' + (c - '0' - 10);
        buf.append((char) c);
    }
834874
private static <T extends Appendable> T _appendToPat(T buf, String s, boolean escapeUnprintable) {
        int cp;
        for (int i = 0; i < s.length(); i += Character.charCount(cp)) {
            cp = s.codePointAt(i);
            _appendToPat(buf, cp, escapeUnprintable);
        }
        return buf;
    }
1146394
protected void process(StringBuffer buf, Object lang) {
		buf.append("<rdf:li xml:lang=\"");
		buf.append(lang);
		buf.append("\" >");
		buf.append(get(lang));
		buf.append("</rdf:li>");
	}
349797
public void write(char[] buf) throws IOException {
	    if (writer != null) {
	        writer.write(buf);
	    } else {
	        write(buf, 0, buf.length);
	    }
    }
378791
void encode(ChannelBuffer buf) {
        buf.writeByte('*');
        writeInt(buf, 1 + (args != null ? args.count() : 0));
        buf.writeBytes(CRLF);
        buf.writeByte('$');
        writeInt(buf, type.bytes.length);
        buf.writeBytes(CRLF);
        buf.writeBytes(type.bytes);
        buf.writeBytes(CRLF);
        if (args != null) {
            buf.writeBytes(args.buffer());
        }
    }
555892
private static void appendToSentence(StringBuilder buf, String[] names) {
        for (int i=0; i<names.length; i++) {
            if (i > 0) {
                if (i + 1 >= names.length) {
                    buf.append(" or ");
                } else {
                    buf.append(", ");
                }
            }
            buf.append('"');
            buf.append(names[i]);
            buf.append('"');
        }
    }
1356573
public static StringBuilder encodeString(StringBuilder buf,
                                             String path,
                                             String encode) {
        if (buf == null) {
            for (int i = 0; i < path.length(); i++) {
                char c = path.charAt(i);
                if (c == '%' || encode.indexOf(c) >= 0) {
                    buf = new StringBuilder(path.length() << 1);
                    break;
                }
            }
            if (buf == null)
                return null;
        }

        for (int i = 0; i < path.length(); i++) {
            char c = path.charAt(i);
            if (c == '%' || encode.indexOf(c) >= 0) {
                buf.append('%');
                StringUtils.append(buf, (byte) (0xff & c), 16);
            } else
                buf.append(c);
        }

        return buf;
    }
1254530
public void appendToFsb(org.apache.xml.utils.FastStringBuffer fsb)
  {
    fsb.append(str());
  }
246326
public void sendReply(final String buf) {
    sendBuffer(HttpResponseStatus.OK,
               ChannelBuffers.copiedBuffer(buf, CharsetUtil.UTF_8));
  }
561223
public void flattenToBuffer(ByteBuffer buf) {
        buf.put(INCOMPLETE_ENCODING_FROM_JAVA); // encoding version
        buf.put((byte)1); // owns_loops_
        buf.put((byte)(m_loops.size() > 1 ? 1 : 0)); // has_holes_
        buf.putInt(m_loops.size());
        int depth = 0;
        for (List<XYZPoint> loop : m_loops) {
            flattenLoopToBuffer(loop, depth, buf);
            depth = 1;
        }
        flattenEmptyBoundToBuffer(buf);
    }
44970
public static StringBuilder appendSpace(StringBuilder buf, int spaces) {
    for(int i = spaces; i > 0; i -= SPACEPADDING.length) {
      buf.append(SPACEPADDING, 0, i < SPACEPADDING.length ? i : SPACEPADDING.length);
    }
    return buf;
  }