use of org.apache.http.util.CharArrayBuffer in project XobotOS by xamarin.
the class BasicLineParser method parseRequestLine.
public static final RequestLine parseRequestLine(final String value, LineParser parser) throws ParseException {
if (value == null) {
throw new IllegalArgumentException("Value to parse may not be null.");
}
if (parser == null)
parser = BasicLineParser.DEFAULT;
CharArrayBuffer buffer = new CharArrayBuffer(value.length());
buffer.append(value);
ParserCursor cursor = new ParserCursor(0, value.length());
return parser.parseRequestLine(buffer, cursor);
}
use of org.apache.http.util.CharArrayBuffer in project XobotOS by xamarin.
the class ParserCursor method toString.
public String toString() {
CharArrayBuffer buffer = new CharArrayBuffer(16);
buffer.append('[');
buffer.append(Integer.toString(this.lowerBound));
buffer.append('>');
buffer.append(Integer.toString(this.pos));
buffer.append('>');
buffer.append(Integer.toString(this.upperBound));
buffer.append(']');
return buffer.toString();
}
use of org.apache.http.util.CharArrayBuffer in project XobotOS by xamarin.
the class BasicHeaderValueFormatter method formatHeaderElement.
// non-javadoc, see interface HeaderValueFormatter
public CharArrayBuffer formatHeaderElement(CharArrayBuffer buffer, final HeaderElement elem, final boolean quote) {
if (elem == null) {
throw new IllegalArgumentException("Header element must not be null.");
}
int len = estimateHeaderElementLen(elem);
if (buffer == null) {
buffer = new CharArrayBuffer(len);
} else {
buffer.ensureCapacity(len);
}
buffer.append(elem.getName());
final String value = elem.getValue();
if (value != null) {
buffer.append('=');
doFormatValue(buffer, value, quote);
}
final int parcnt = elem.getParameterCount();
if (parcnt > 0) {
for (int i = 0; i < parcnt; i++) {
buffer.append("; ");
formatNameValuePair(buffer, elem.getParameter(i), quote);
}
}
return buffer;
}
use of org.apache.http.util.CharArrayBuffer in project XobotOS by xamarin.
the class BasicHeaderValueFormatter method formatNameValuePair.
// non-javadoc, see interface HeaderValueFormatter
public CharArrayBuffer formatNameValuePair(CharArrayBuffer buffer, final NameValuePair nvp, final boolean quote) {
if (nvp == null) {
throw new IllegalArgumentException("NameValuePair must not be null.");
}
int len = estimateNameValuePairLen(nvp);
if (buffer == null) {
buffer = new CharArrayBuffer(len);
} else {
buffer.ensureCapacity(len);
}
buffer.append(nvp.getName());
final String value = nvp.getValue();
if (value != null) {
buffer.append('=');
doFormatValue(buffer, value, quote);
}
return buffer;
}
use of org.apache.http.util.CharArrayBuffer in project XobotOS by xamarin.
the class BasicHeaderValueParser method parseHeaderElement.
/**
* Parses an element with the given parser.
*
* @param value the header element to parse
* @param parser the parser to use, or <code>null</code> for default
*
* @return the parsed header element
*/
public static final HeaderElement parseHeaderElement(final String value, HeaderValueParser parser) throws ParseException {
if (value == null) {
throw new IllegalArgumentException("Value to parse may not be null");
}
if (parser == null)
parser = BasicHeaderValueParser.DEFAULT;
CharArrayBuffer buffer = new CharArrayBuffer(value.length());
buffer.append(value);
ParserCursor cursor = new ParserCursor(0, value.length());
return parser.parseHeaderElement(buffer, cursor);
}
Aggregations