public Attribute setPreSpace (String preSpace) { if (preSpace == null) preSpace = " "; else if (preSpace.trim ().length () != 0) throw new IllegalArgumentException ("Space prefix must not contain anything besides whitespace: "+TextUtils.escapeJavaString(preSpace)); this.preSpace = preSpace; return this; }
public Attribute setEqualsSpace (String equalsSpace) { if (equalsSpace == null) equalsSpace = "="; else if (!"=".equals (equalsSpace.trim ())) throw new IllegalArgumentException ("Space around equals sign must not contain anything besides whitespace: "+TextUtils.escapeJavaString(equalsSpace)); this.equalsSpace = equalsSpace; return this; }
/** Return the text with all special characters (like line feed, new line, null bytes, characters * in the unicode range) escaped. * * <p>The result of this method can use used directly in a Java String. * * @return the text (without quotes) or <code>null</code> if there is no source */ public String getEscapedText () { return TextUtils.escapeJavaString (getText ()); }
public static char checkQuoteChar (String value, char quoteChar) { if (quoteChar == '\0') { if (!value.contains ("\"")) quoteChar = '"'; else if (!value.contains ("'")) quoteChar = '\''; else quoteChar = '"'; } else if (quoteChar != '"' && quoteChar != '\'') { char[] buffer = new char[1]; buffer[0] = (char)quoteChar; String s = new String (buffer); throw new XMLParseException ("Illegal quote charater: "+TextUtils.escapeJavaString (s)+" ("+(int)quoteChar+")"); } return quoteChar; }
protected String lookAheadForErrorMessage (String conditionalPrefix, int pos, int len) { String found = ""; if (pos < source.length ()) { int len2 = source.length () - pos; len = Math.min (len, len2); String s = source.substring (pos, pos+len); if (len != len2) s += "..."; if (conditionalPrefix == null) found = TextUtils.escapeJavaString (s); else found = " " + conditionalPrefix + " " + TextUtils.escapeJavaString (s); } return found; }