Create a {@code rtrim(str)} expression

<p>Returns a character string after truncating all trailing blanks.</p>

@param str string
@return rtrim(str)
337164
public static StringExpression rtrim(Expression<String> str) {
        return Expressions.stringOperation(Ops.StringOps.RTRIM, str);
    }
1356970
public static String trimEncoding(String str, boolean upperCase)
    {
        int i = 0;
        int len = str.length();

        // Let's first check if String is fine as is:
        for (; i < len; ++i) {
            char c = str.charAt(i);
            if (c <= CHAR_SPACE || !Character.isLetterOrDigit(c)) {
                break;
            }
        }

        if (i == len) {
            return str;
        }

        // Nope: have to trim it
        StringBuilder sb = new StringBuilder();
        if (i > 0) {
            sb.append(str.substring(0, i));
        }
        for (; i < len; ++i) {
            char c = str.charAt(i);
            if (c > CHAR_SPACE && Character.isLetterOrDigit(c)) {
                if (upperCase) {
                    c = Character.toUpperCase(c);
                }
                sb.append(c);
            }
        }

        return sb.toString();
    }
950285
public static List<String> split(
                    final String str
                    )
    {
        String  s = str;
        if (s != null) {
            s = s.trim();
        }

        List<String>  list = new ArrayList<String>();
        if (s == null || s.length() == 0) {
            return list;
        }

        String[]  tokens = s.split( "[ \t\n\r\f]" );
        // NOTE: tokens[i] may be an empty string "".

        // excludes empty strings.
        for (String  t : tokens) {
            if (t.length() > 0) {
                list.add( t );
            }
        }

        return list;
    }
254982
@Nonnull
    public static IRI create(@Nonnull String str) {
        checkNotNull(str, "str cannot be null");
        int index = XMLUtils.getNCNameSuffixIndex(str);
        if (index < 0) {
            // no ncname
            return new IRI(str, "");
        }
        return new IRI(str.substring(0, index), str.substring(index));
    }
1049504
public static UTF8String fromString(String str) {
    return str == null ? null : fromBytes(str.getBytes(StandardCharsets.UTF_8));
  }
1362364
public static String sqlEscapeString(final String str) {
        StringBuilder buffer = new StringBuilder(str.length() * 2);
        boolean neededEscaping = false;
        for (int i = 0; i < str.length(); i++) {
            final char c = str.charAt(i);
            if (needsEscaping((byte) c)) {
                neededEscaping = true;
                buffer.append('\\');
            }
            buffer.append(c);
        }
        return neededEscaping ? buffer.toString() : str;
    }
1369324
public static String wrap(String str, int wrapTextLength) {
	if (wrapTextLength <= 0) return str;

	StringBuilder rtn = new StringBuilder();
	String ls = SystemUtil.getOSSpecificLineSeparator();
	Array arr = ListUtil.listToArray(str, ls);
	int len = arr.size();

	for (int i = 1; i <= len; i++) {
	    rtn.append(wrapLine(Caster.toString(arr.get(i, ""), ""), wrapTextLength));
	    if (i + 1 < len) rtn.append(ls);
	}
	return rtn.toString();
    }
613695
public static String initCap(String str) {
        assertStringNotNull(str);
        if (is_Null_or_Empty(str)) {
            return str;
        }
        if (str.length() == 1) {
            return str.toUpperCase();
        }
        final char chars[] = str.toCharArray();
        chars[0] = Character.toUpperCase(chars[0]);
        return new String(chars);
    }
152748
public static String[] splitLongString(String str, char separator)
    {
        int len = (str == null) ? 0 : str.length();
        if (str == null || len == 0)
        {
            return ArrayUtils.EMPTY_STRING_ARRAY;
        }

        int       oldPos = 0;
        ArrayList list = new ArrayList();
        int pos = str.indexOf(separator);
        while(pos >= 0)
        {
            list.add(substring(str, oldPos, pos));
            oldPos = (pos + 1);
            pos = str.indexOf(separator, oldPos);
        }


        list.add(substring(str, oldPos, len));

        return (String[]) list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
    }
1088755
public static String trim(String str) {
		return str != null && str.length() > 0 ? str.trim() : str;
	}
1050188
public static Long parseLong(final String str) {
        if (null != str) {
            try {
                return new Long(Long.parseLong(str.trim()));
            } catch (final Exception e) {
                // :IGNORE:
            }
        }
        return null;
    }
744250
protected String rtrim(String s)
    {
        if (s == null || s.length() == 0)
        {
            return s;
        }

        int pos = s.length();

        while (pos > 0 && Character.isWhitespace(s.charAt(pos - 1)))
        {
            --pos;
        }

        return s.substring(0, pos);
    }
1347965
public IStringBuffer append( String str )
    {
        if ( str == null )
            throw new NullPointerException();
        //check the necessary to resize the buffer.
        if ( count + str.length() > buff.length ) {
            resizeTo( (count + str.length()) * 2 + 1 );
        }
        
        for ( int j = 0; j < str.length(); j++ ) {
            buff[count++] = str.charAt(j);
        }
        
        return this;
    }
344005
public FormatStringBuffer format(String str) {

        if (str == null) str = "<NULL>";

        Format fmt = getFormat();

        if (fmt.type != STRING) throw new IllegalArgumentException("Expected a String format");

        int len = str.length();
        if (fmt.precision != -1 && len > fmt.precision) len = fmt.precision;

        if ((fmt.flags & LEFT) != LEFT) while (len < fmt.fieldWidth--)
            buffer.append(' ');

        for (int i = 0; i < len; ++i)
            buffer.append(str.charAt(i));

        while (len < fmt.fieldWidth--)
            buffer.append(' ');

        return this;
    }
1138873
public static String trimTrailingCharacter(String str, char trailingCharacter) {
        if (!hasLength(str)) {
            return str;
        }
        StringBuilder buf = new StringBuilder(str);
        while (buf.length() > 0 && buf.charAt(buf.length() - 1) == trailingCharacter) {
            buf.deleteCharAt(buf.length() - 1);
        }
        return buf.toString();
    }
964186
public static String rTrim(final String value) {
        if (value == null) {
            return null;
        }

        String trimmed = value;
        int offset = value.length() - 1;
        while (offset > -1 && (value.charAt(offset) == ' ' || value.charAt(offset) == '\t')) {
            offset--;
        }

        if (offset < value.length() - 1) {
            trimmed = value.substring(0, offset + 1);
        }

        return trimmed;
    }
210792
public static boolean isEmpty(final String str, final boolean trim) {
	if (!trim) return isEmpty(str);
	return str == null || str.trim().length() == 0;
    }