Append <tt>String</tt> value.

@param stringValue
@param nullTerminated <tt>true<tt> means C-Octet String.
The default value is <tt>true</tt>.
@return the latest length of the buffer.
181268
public int append(String stringValue, boolean nullTerminated) {
        if (stringValue != null)
            append(stringValue.getBytes());
        if (nullTerminated)
            append((byte)0);
        return bytesLength;
    }
1209566
public static String getExtension(String strFile, String defaultValue) {
	int pos = strFile.lastIndexOf('.');
	if (pos == -1) return defaultValue;
	return strFile.substring(pos + 1);
    }
163291
private void insertAfter(final URI hrefValue, final StringBuffer parentResult, final CharSequence tmpContent) {
        int insertpoint = parentResult.lastIndexOf("</");
        final int end = parentResult.indexOf(">", insertpoint);

        if (insertpoint == -1 || end == -1) {
            logger.error(MessageUtils.getMessage("DOTJ033E", hrefValue.toString()).toString());
        } else {
            if (ELEMENT_NAME_DITA.equals(parentResult.substring(insertpoint, end).trim())) {
                insertpoint = parentResult.lastIndexOf("</", insertpoint - 1);
            }
            parentResult.insert(insertpoint, tmpContent);
        }
    }
468447
public static String trim(String str, String defaultValue) {
	if (str == null) return defaultValue;
	return str.trim();
    }
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;
		}
	}
1370331
public StrBuilder append(final StrBuilder str) {
        if (str == null) {
            return appendNull();
        }
        final int strLen = str.length();
        if (strLen > 0) {
            final int len = length();
            ensureCapacity(len + strLen);
            System.arraycopy(str.buffer, 0, buffer, len, strLen);
            size += strLen;
        }
        return this;
    }
552975
public static Long hexToLongObject(@Nullable String str, Long defaultValue) {
		if (StringUtils.isEmpty(str)) {
			return defaultValue;
		}
		try {
			return Long.decode(str);
		} catch (final NumberFormatException nfe) {
			return defaultValue;
		}
	}
760117
private void emitStringValue(String s) {
    raw('"');
    char b = 0, c = 0;
    for (int i = 0; i < s.length(); i++) {
      b = c;
      c = s.charAt(i);

      switch (c) {
        case '\\':
        case '"':
          raw('\\');
          raw(c);
          break;
        case '/':
          // Special case to ensure that </script> doesn't appear in JSON
          // output
          if (b == '<')
            raw('\\');
          raw(c);
          break;
        case '\b':
          raw("\\b");
          break;
        case '\t':
          raw("\\t");
          break;
        case '\n':
          raw("\\n");
          break;
        case '\f':
          raw("\\f");
          break;
        case '\r':
          raw("\\r");
          break;
        default:
          if (shouldBeEscaped(c)) {
            String t = "000" + Integer.toHexString(c);
            raw("\\u" + t.substring(t.length() - "0000".length()));
          } else {
            raw(c);
          }
      }
    }

    raw('"');
  }
284573
private static long __parseLong(String strLong, long defaultValue) {
        try {
            return Long.parseLong(strLong);
        } catch (NumberFormatException ex) {
            return defaultValue;
        }
    }
1122134
public static Double toDoubleObject(@Nullable String str, Double defaultValue) {
		if (StringUtils.isEmpty(str)) {
			return defaultValue;
		}
		try {
			return Double.valueOf(str);
		} catch (final NumberFormatException nfe) {
			return defaultValue;
		}
	}
430094
protected final Stringifier registerNullStringifier(final String nullValue) {
		Stringifier nullStringifier = new Stringifier() {
			public String toString(Object object) {
				return nullValue;
			}
		};
		compositeStringifier.setNullStringifier(nullStringifier);
		return nullStringifier;
	}
580014
public static String stringOrDefault(String str, String defaultValue) {
		if(isStringValued(str)) return str;
		return defaultValue;
	}
1351378
public static String ltrim(String str, String defaultValue) {
	if (str == null) return defaultValue;
	int len = str.length();
	int st = 0;

	while ((st < len) && (str.charAt(st) <= ' ')) {
	    st++;
	}
	return ((st > 0)) ? str.substring(st) : str;
    }
1229654
def p_stringValueList(p):
    
    if len(p) == 2:
        p[0] = _fixStringValue(p[1], p)
    else:
        p[0] = p[1] + _fixStringValue(p[2], p)
712182
public static void insertFromString(final String stringValue, final DeviceData deviceDataArgin,
	    final int dataType) throws DevFailed {

	Double doubleValue = Double.NaN;
	try {
	    doubleValue = Double.valueOf(stringValue);
	} catch (final NumberFormatException e) {
	    doubleValue = Double.NaN;
	}

	if (doubleValue.isNaN() && dataType != TangoConst.Tango_DEV_STRING) {
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "Cannot insert " + stringValue
		    + " as a numerical value.",
		    "CommandHelper.insertFromString(String value,deviceDataArgin)");
	}

	switch (dataType) {
	case TangoConst.Tango_DEV_SHORT:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert(doubleValue.shortValue());
	    }
	    break;
	case TangoConst.Tango_DEV_USHORT:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert_us(doubleValue.shortValue());
	    }
	    break;
	case TangoConst.Tango_DEV_CHAR:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR",
		    "input type Tango_DEV_CHAR not supported",
		    "CommandHelper.insertFromString(String value,deviceDataArgin)");
	    break;
	case TangoConst.Tango_DEV_UCHAR:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert(doubleValue.shortValue());
	    }
	    break;
	case TangoConst.Tango_DEV_LONG:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert(doubleValue.intValue());
	    }
	    break;
	case TangoConst.Tango_DEV_ULONG:
	    deviceDataArgin.insert_ul(doubleValue.longValue());
	    break;
	case TangoConst.Tango_DEV_LONG64:
	    deviceDataArgin.insert(doubleValue.intValue());
	    break;
	case TangoConst.Tango_DEV_ULONG64:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert_u64(doubleValue.longValue());
	    }
	    break;
	case TangoConst.Tango_DEV_INT:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert(doubleValue.intValue());
	    }
	    break;
	case TangoConst.Tango_DEV_FLOAT:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert(doubleValue.floatValue());
	    }
	    break;
	case TangoConst.Tango_DEV_DOUBLE:
	    if (!doubleValue.isNaN()) {
		deviceDataArgin.insert(doubleValue.doubleValue());
	    }
	    break;
	case TangoConst.Tango_DEV_STRING:
	    deviceDataArgin.insert(stringValue);
	    break;
	case TangoConst.Tango_DEV_BOOLEAN:
	    if (!doubleValue.isNaN()) {
		if (doubleValue.doubleValue() == 1) {
		    deviceDataArgin.insert(true);
		} else {
		    deviceDataArgin.insert(false);
		}
	    }
	    break;
	case TangoConst.Tango_DEV_STATE:
	    if (!doubleValue.isNaN()) {
		final DevState tmpDevState = StateUtilities.getStateForName(stringValue);
		deviceDataArgin.insert(tmpDevState);
	    }
	    break;
	default:
	    Except.throw_exception("TANGO_WRONG_DATA_ERROR", "input type "
		    + deviceDataArgin.getType() + " not supported",
		    "CommandHelper.insertFromString(String value,deviceDataArgin)");
	    break;
	}
    }
102280
@Override
    public String tagValue(String value) {
        String formattedValue = StringEscapeUtils.escapeJson(delegate.tagValue(value));
        return StringUtils.truncate(formattedValue, TAG_VALUE_MAX_LENGTH);
    }
400042
@GwtIncompatible("incompatible method")
    public StrBuilder append(final CharBuffer buf) {
        if (buf == null) {
            return appendNull();
        }
        if (buf.hasArray()) {
            final int length = buf.remaining();
            final int len = length();
            ensureCapacity(len + length);
            System.arraycopy(buf.array(), buf.arrayOffset() + buf.position(), buffer, len, length);
            size += length;
        } else {
            append(buf.toString());
        }
        return this;
    }