public static boolean endsWithIgnoreCase (@Nullable final CharSequence aCS, final char c) { return hasText (aCS) && Character.toLowerCase (getLastChar (aCS)) == Character.toLowerCase (c); }
public static boolean endsWithAny (@Nullable final CharSequence aCS, @Nullable final char [] aChars) { if (hasText (aCS) && aChars != null) { final char cLast = getLastChar (aCS); for (final char c : aChars) if (cLast == c) return true; } return false; }
public static boolean endsWith (@Nullable final CharSequence aCS, final char c) { return hasText (aCS) && getLastChar (aCS) == c; }
/** * Check if the passed character sequence ends with a path separation * character. * * @param s * The character sequence to check. May be <code>null</code> or empty. * @return <code>true</code> if the character sequences ends with a Windows- * or Unix-style path character. */ public static boolean endsWithPathSeparatorChar (@Nullable final CharSequence s) { return isPathSeparatorChar (StringHelper.getLastChar (s)); }
/** * Get the stack trace of a throwable as string. * * @param t * The throwable to be converted. May be <code>null</code>. * @param bOmitCommonStackTraceElements * If <code>true</code> the stack trace is cut after certain class * names occurring. If <code>false</code> the complete stack trace is * returned. * @return the stack trace as newline separated string. If the passed * Throwable is <code>null</code> an empty string is returned. */ @Nonnull public static String getStackAsString (@Nullable final Throwable t, final boolean bOmitCommonStackTraceElements) { if (t == null) return ""; // convert call stack to string final StringBuilder aCallStack = _getRecursiveStackAsStringBuilder (t, null, null, 1, bOmitCommonStackTraceElements); // avoid having a separator at the end -> remove the last char if (StringHelper.getLastChar (aCallStack) == STACKELEMENT_LINESEP) aCallStack.deleteCharAt (aCallStack.length () - 1); // no changes return aCallStack.toString (); }
/** * Remove surrounding quotes (single or double) of a string (if present). If * the start and the end quote are not equal, nothing happens. * * @param sStr * The string where the quotes should be removed * @return The string without quotes. */ @Nullable public static String extractStringValue (@Nullable final String sStr) { if (StringHelper.hasNoText (sStr) || sStr.length () < 2) return sStr; final char cFirst = sStr.charAt (0); if ((cFirst == '"' || cFirst == '\'') && StringHelper.getLastChar (sStr) == cFirst) { // Remove quotes around the string return _trimBy (sStr, 1, 1); } return sStr; }
/** * Remove surrounding quotes (single or double) of a string (if present). If * the start and the end quote are not equal, nothing happens. * * @param sStr * The string where the quotes should be removed * @return The string without quotes. */ @Nullable public static String extractStringValue (@Nullable final String sStr) { if (StringHelper.hasNoText (sStr) || sStr.length () < 2) return sStr; final char cFirst = sStr.charAt (0); if ((cFirst == '"' || cFirst == '\'') && StringHelper.getLastChar (sStr) == cFirst) { // Remove quotes around the string return _trimBy (sStr, 1, 1); } return sStr; }
final char cLast = StringHelper.getLastChar (aSB); if (cLast != QUESTIONMARK && cLast != AMPERSAND) aSB.append (AMPERSAND); if (StringHelper.getLastChar (aSB) != HASH) aSB.append (HASH); aSB.append (sAnchor);
break; case PLAIN_TEXT_WRAPPED_IN_COMMENT: if (StringHelper.getLastChar (sContent) == '\n') aElement.appendComment (sLineSeparator + sContent + "//"); else case CDATA_IN_COMMENT: aElement.appendText ("//"); if (StringHelper.getLastChar (sContent) == '\n') aElement.appendCDATA (sLineSeparator + sContent + "//"); else