/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or <code>null</code> * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) return 0; int result = (nvps.length-1) * 2; // "; " between the parameters for (int i=0; i<nvps.length; i++) { result += estimateNameValuePairLen(nvps[i]); } return result; }
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; }
/** * Estimates the length of a formatted header element. * * @param elem the header element to format, or <code>null</code> * * @return a length estimate, in number of characters */ protected int estimateHeaderElementLen(final HeaderElement elem) { if (elem == null) return 0; int result = elem.getName().length(); // name final String value = elem.getValue(); if (value != null) { // assume quotes, but no escaped characters result += 3 + value.length(); // ="value" } final int parcnt = elem.getParameterCount(); if (parcnt > 0) { for (int i=0; i<parcnt; i++) { result += 2 + // ; <param> estimateNameValuePairLen(elem.getParameter(i)); } } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or <code>null</code> * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) return 0; int result = (nvps.length-1) * 2; // "; " between the parameters for (int i=0; i<nvps.length; i++) { result += estimateNameValuePairLen(nvps[i]); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or <code>null</code> * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) return 0; int result = (nvps.length-1) * 2; // "; " between the parameters for (int i=0; i<nvps.length; i++) { result += estimateNameValuePairLen(nvps[i]); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or <code>null</code> * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) return 0; int result = (nvps.length-1) * 2; // "; " between the parameters for (int i=0; i<nvps.length; i++) { result += estimateNameValuePairLen(nvps[i]); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or <code>null</code> * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) return 0; int result = (nvps.length-1) * 2; // "; " between the parameters for (int i=0; i<nvps.length; i++) { result += estimateNameValuePairLen(nvps[i]); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or {@code null} * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) { return 0; } int result = (nvps.length-1) * 2; // "; " between the parameters for (final NameValuePair nvp : nvps) { result += estimateNameValuePairLen(nvp); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or {@code null} * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) { return 0; } int result = (nvps.length-1) * 2; // "; " between the parameters for (final NameValuePair nvp : nvps) { result += estimateNameValuePairLen(nvp); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or <code>null</code> * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) { return 0; } int result = (nvps.length-1) * 2; // "; " between the parameters for (final NameValuePair nvp : nvps) { result += estimateNameValuePairLen(nvp); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or {@code null} * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) { return 0; } int result = (nvps.length-1) * 2; // "; " between the parameters for (final NameValuePair nvp : nvps) { result += estimateNameValuePairLen(nvp); } return result; }
/** * Estimates the length of formatted parameters. * * @param nvps the parameters to format, or {@code null} * * @return a length estimate, in number of characters */ protected int estimateParametersLen(final NameValuePair[] nvps) { if ((nvps == null) || (nvps.length < 1)) { return 0; } int result = (nvps.length-1) * 2; // "; " between the parameters for (final NameValuePair nvp : nvps) { result += estimateNameValuePairLen(nvp); } return result; }
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; }
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; }
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; }
@Override public CharArrayBuffer formatNameValuePair(final CharArrayBuffer charBuffer, final NameValuePair nvp, final boolean quote) { Args.notNull(nvp, "Name / value pair"); final int len = estimateNameValuePairLen(nvp); CharArrayBuffer buffer = charBuffer; 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; }
@Override public CharArrayBuffer formatNameValuePair(final CharArrayBuffer charBuffer, final NameValuePair nvp, final boolean quote) { Args.notNull(nvp, "Name / value pair"); final int len = estimateNameValuePairLen(nvp); CharArrayBuffer buffer = charBuffer; 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; }
@Override public CharArrayBuffer formatNameValuePair(final CharArrayBuffer charBuffer, final NameValuePair nvp, final boolean quote) { Args.notNull(nvp, "Name / value pair"); final int len = estimateNameValuePairLen(nvp); CharArrayBuffer buffer = charBuffer; 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; }
public CharArrayBuffer formatNameValuePair(final CharArrayBuffer charBuffer, final NameValuePair nvp, final boolean quote) { Args.notNull(nvp, "Name / value pair"); final int len = estimateNameValuePairLen(nvp); CharArrayBuffer buffer = charBuffer; 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; }
@Override public CharArrayBuffer formatNameValuePair(final CharArrayBuffer charBuffer, final NameValuePair nvp, final boolean quote) { Args.notNull(nvp, "Name / value pair"); final int len = estimateNameValuePairLen(nvp); CharArrayBuffer buffer = charBuffer; 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; }