private void escapeAndAppendString(char[] buf, int start, int len) throws IOException { final char NE = (char)ESCAPE_TABLE.length; final String[] escapes = ESCAPE_TABLE; int end = start+len; int lastPos = start; int pos; for (pos=start; pos<end; pos++) { char c = buf[pos]; if (c >= NE) continue; String escape = escapes[c]; if (escape == null) continue; if (lastPos < pos) append(buf, lastPos, pos-lastPos); lastPos = pos + 1; append(escape); } if (lastPos < pos) append(buf, lastPos, pos-lastPos); }
public XmlSerializer startTag(String namespace, String name) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">\n"); } if (mIndent) { appendIndent(mNesting); } mNesting++; append('<'); if (namespace != null) { append(namespace); append(':'); } append(name); mInTag = true; mLineStart = false; return this; }
public XmlSerializer attribute(String namespace, String name, String value) throws IOException, IllegalArgumentException, IllegalStateException { append(' '); if (namespace != null) { append(namespace); append(':'); } append(name); append("=\""); escapeAndAppendString(value); append('"'); mLineStart = false; return this; }
public XmlSerializer endTag(String namespace, String name) throws IOException, IllegalArgumentException, IllegalStateException { mNesting--; if (mInTag) { append(" />\n"); } else { if (mIndent && mLineStart) { appendIndent(mNesting); } append("</"); if (namespace != null) { append(namespace); append(':'); } append(name); append(">\n"); } mLineStart = true; mInTag = false; return this; }
private void append(String str) throws IOException { append(str, 0, str.length()); }
private void escapeAndAppendString(final String string) throws IOException { final int N = string.length(); final char NE = (char)ESCAPE_TABLE.length; final String[] escapes = ESCAPE_TABLE; int lastPos = 0; int pos; for (pos=0; pos<N; pos++) { char c = string.charAt(pos); if (c >= NE) continue; String escape = escapes[c]; if (escape == null) continue; if (lastPos < pos) append(string, lastPos, pos-lastPos); lastPos = pos + 1; append(escape); } if (lastPos < pos) append(string, lastPos, pos-lastPos); }
private void appendIndent(int indent) throws IOException { indent *= 4; if (indent > sSpace.length()) { indent = sSpace.length(); } append(sSpace, 0, indent); }
public XmlSerializer text(String text) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">"); mInTag = false; } escapeAndAppendString(text); if (mIndent) { mLineStart = text.length() > 0 && (text.charAt(text.length()-1) == '\n'); } return this; }
public XmlSerializer text(char[] buf, int start, int len) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">"); mInTag = false; } escapeAndAppendString(buf, start, len); if (mIndent) { mLineStart = buf[start+len-1] == '\n'; } return this; }
private void append(String str, int i, final int length) throws IOException { if (length > BUFFER_LEN) { final int end = i + length; while (i < end) { int next = i + BUFFER_LEN; append(str, i, next<end ? BUFFER_LEN : (end-i)); i = next; } return; } int pos = mPos; if ((pos+length) > BUFFER_LEN) { flush(); pos = mPos; } str.getChars(i, i+length, mText, pos); mPos = pos + length; }
private void append(char[] buf, int i, final int length) throws IOException { if (length > BUFFER_LEN) { final int end = i + length; while (i < end) { int next = i + BUFFER_LEN; append(buf, i, next<end ? BUFFER_LEN : (end-i)); i = next; } return; } int pos = mPos; if ((pos+length) > BUFFER_LEN) { flush(); pos = mPos; } System.arraycopy(buf, i, mText, pos, length); mPos = pos + length; }
public XmlSerializer attribute(String namespace, String name, String value) throws IOException, IllegalArgumentException, IllegalStateException { append(' '); if (namespace != null) { append(namespace); append(':'); } append(name); append("=\""); escapeAndAppendString(value); append('"'); mLineStart = false; return this; }
public XmlSerializer attribute(String namespace, String name, String value) throws IOException, IllegalArgumentException, IllegalStateException { append(' '); if (namespace != null) { append(namespace); append(':'); } append(name); append("=\""); escapeAndAppendString(value); append('"'); mLineStart = false; return this; }
private void appendIndent(int indent) throws IOException { indent *= 4; if (indent > sSpace.length()) { indent = sSpace.length(); } append(sSpace, 0, indent); }
private void append(String str) throws IOException { append(str, 0, str.length()); }
private void appendIndent(int indent) throws IOException { indent *= 4; if (indent > sSpace.length()) { indent = sSpace.length(); } append(sSpace, 0, indent); }
public XmlSerializer text(char[] buf, int start, int len) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">"); mInTag = false; } escapeAndAppendString(buf, start, len); if (mIndent) { mLineStart = buf[start+len-1] == '\n'; } return this; }
public XmlSerializer text(String text) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">"); mInTag = false; } escapeAndAppendString(text); if (mIndent) { mLineStart = text.length() > 0 && (text.charAt(text.length()-1) == '\n'); } return this; }
public XmlSerializer text(String text) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">"); mInTag = false; } escapeAndAppendString(text); if (mIndent) { mLineStart = text.length() > 0 && (text.charAt(text.length()-1) == '\n'); } return this; }
public XmlSerializer text(char[] buf, int start, int len) throws IOException, IllegalArgumentException, IllegalStateException { if (mInTag) { append(">"); mInTag = false; } escapeAndAppendString(buf, start, len); if (mIndent) { mLineStart = buf[start+len-1] == '\n'; } return this; }