public boolean isValid (@Nullable final String sVATIN) { if (StringHelper.hasNoText (sVATIN)) return false; final String sRealVATIN = StringHelper.replaceAll (sVATIN, " ", "").toUpperCase (); return m_aPattern.matcher (sRealVATIN).matches (); }
public static boolean isValidDeclaration (@Nonnull @Nonempty final String sDeclaration) { return StringHelper.startsWith (sDeclaration, '@') && StringHelper.endsWithIgnoreCase (sDeclaration, "keyframes"); }
@Nullable private static String _getUntilLast (@Nullable final String sStr, @Nullable final String sSearch, final boolean bIncludingSearchChar) { if (hasNoText (sSearch)) return ""; final int nIndex = getLastIndexOf (sStr, sSearch); return nIndex == STRING_NOT_FOUND ? null : sStr.substring (0, nIndex + (bIncludingSearchChar ? sSearch.length () : 0)); }
@Nullable public static String makeDataAttrName (@Nullable final String sName) { return StringHelper.hasNoText (sName) ? sName : CHTMLAttributes.HTML5_PREFIX_DATA + sName; }
if (StringHelper.startsWith (sOrigValue, '[') && StringHelper.endsWith (sOrigValue, ']')) if (aObjStart[2] != null) sValue = StringHelper.getConcatenatedOnDemand (aObjStart[0], aObjStart[2]).trim (); if (sValue.length () > 0) sValue = StringHelper.replaceAll (sValue, "; ", ";\n"); aParts.addAll (StringHelper.getExploded ('\n', sValue));
/** * Concatenate a base URL and a sub path incl. the path cleansing. More or * less the same as calling <code>getCleanPath (sURL + sPath)</code> * * @param sURL * The base URL. May not be <code>null</code>. * @param sPath * The path to append. May not be <code>null</code>. * @return The combined, cleaned path. * @see #getCleanPath(String) */ @Nonnull public static String getCleanConcatenatedUrlPath (@Nonnull final String sURL, @Nonnull final String sPath) { ValueEnforcer.notNull (sURL, "URL"); ValueEnforcer.notNull (sPath, "Path"); // If nothing is to be appended, just clean the base URL if (StringHelper.hasNoText (sPath)) return getCleanPath (sURL); final String sRealURL = StringHelper.endsWith (sURL, '/') ? sURL : sURL + '/'; final String sRealPath = StringHelper.startsWith (sPath, '/') ? sPath.substring (1) : sPath; return getCleanPath (sRealURL + sRealPath); }
public boolean supportsReading (@Nullable final String sName) { // Class path resource supports all paths return StringHelper.hasText (sName); }
@Nullable public static HCA_MailTo createLinkedEmail (@Nullable final String sAddress, @Nullable final String sPersonal) { if (StringHelper.hasNoText (sAddress)) return null; final HCA_MailTo ret = new HCA_MailTo (sAddress); ret.addChild (StringHelper.getNotNull (sPersonal, sAddress)); return ret; } }
@Nonnull public static String getTextWithState (@Nonnull final String sText, @Nonnull final ELabelType eType) { ValueEnforcer.notNull (sText, "Text"); ValueEnforcer.notNull (eType, "Type"); // Trim optional trailing colon String sPlainText = StringHelper.trimEnd (sText.trim (), LABEL_END); // Append suffix only, if at least some text is present if (StringHelper.hasText (sPlainText)) sPlainText += getSuffix (eType, !StringHelper.endsWith (sPlainText, '?')); return sPlainText; }
@Nonnull @ReturnsMutableCopy private static Map <String, String> _getQueryStringAsMap (@Nullable final String sQueryString, @Nonnull final IDecoder <String> aParameterDecoder) { final Map <String, String> aMap = new LinkedHashMap <String, String> (); if (StringHelper.hasText (sQueryString)) { for (final String sKeyValuePair : StringHelper.getExploded (AMPERSAND, sQueryString)) if (sKeyValuePair.length () > 0) { final List <String> aParts = StringHelper.getExploded (EQUALS, sKeyValuePair, 2); final String sKey = aParts.get (0); // Maybe empty when passing something like "url?=value" if (StringHelper.hasText (sKey)) { final String sValue = aParts.size () == 2 ? aParts.get (1) : ""; if (sValue == null) throw new NullPointerException ("parameter value may not be null"); // Now decode the name and the value aMap.put (aParameterDecoder.decode (sKey), aParameterDecoder.decode (sValue)); } } } return aMap; }
private static String getTrackingOptOutMessage (@Nullable final Locale aDisplayLocale, @Nullable final String sTrackingOptOutMessage) { if (StringHelper.hasText (sTrackingOptOutMessage)) { return sTrackingOptOutMessage; } String sMsg = EText.MSG_TRACKING_OPT_OUT.getTextWithLocaleFallback (aDisplayLocale == null ? TextProvider.EN : aDisplayLocale); return StringHelper.getNotNull (sMsg, EText.MSG_TRACKING_OPT_OUT.getTextWithLocaleFallback (TextProvider.EN)); }
/** * Take a concatenated String and return a {@link List} of all elements in the * passed string, using specified separator string. * * @param cSep * The separator character to use. * @param sElements * The concatenated String to convert. May be <code>null</code> or * empty. * @return The {@link List} represented by the passed string. Never * <code>null</code>. If the passed input string is <code>null</code> * or "" an empty list is returned. */ @Nonnull @ReturnsMutableCopy public static List <String> getExploded (final char cSep, @Nullable final String sElements) { return getExploded (cSep, sElements, -1); }
@Nonnull public static <T extends IHCNodeWithChildren <?>> T getNodeWithState (@Nonnull final T aNode, @Nonnull final ELabelType eType) { ValueEnforcer.notNull (aNode, "Node"); ValueEnforcer.notNull (eType, "Type"); // Only append the suffix, if at least one text child is present if (HCUtils.recursiveContainsAtLeastOneTextNode (aNode)) { final String sPlainText = aNode.getPlainText (); if (sPlainText.length () > 0) { final String sSuffixString = getSuffixString (eType); if (StringHelper.hasText (sSuffixString) && StringHelper.endsWith (sPlainText, sSuffixString)) { // Append only colon aNode.addChild (LABEL_END); } else if (!StringHelper.endsWith (sPlainText, LABEL_END)) aNode.addChild (getSuffix (eType, true)); } } return aNode; } }
/** * Check if the passed MIME type has the same content type as this * * @param sMimeType * The MIME type string to be checked. May be <code>null</code>. * @return <code>true</code> if the passed MIME type has this content type, * <code>false</code> otherwise */ public boolean isTypeOf (@Nullable final String sMimeType) { return StringHelper.startsWith (sMimeType, m_sText + CMimeType.SEPARATOR_CONTENTTYPE_SUBTYPE); }
@Override public String getPlainText () { return StringHelper.getNotNull (m_sValue); }
@Nonnull public final String getIndent (@Nonnegative final int nCount) { return StringHelper.getRepeated (m_sIndent, nCount); }
/** * Same as {@link #replaceAll(String, String, CharSequence)} but allowing for * a <code>null</code> new-value, which is than interpreted as an empty string * instead. * * @param sInputString * The input string where the text should be replace. If this parameter * is <code>null</code> or empty, no replacement is done. * @param sSearchText * The string to be replaced. May neither be <code>null</code> nor * empty. * @param aReplacementText * The string with the replacement. May be <code>null</code> or empty. * @return The input string as is, if the input string is empty or if the * string to be replaced is not contained. */ public static String replaceAllSafe (@Nullable final String sInputString, @Nonnull final String sSearchText, @Nullable final CharSequence aReplacementText) { return replaceAll (sInputString, sSearchText, getNotNull (aReplacementText, "")); }
@Nonnull public CSSUnknownRule setParameterList (@Nullable final String sParameterList) { m_sParameterList = StringHelper.trim (sParameterList); return this; }
/** * Check if the passed filename is a CSS filename (independent if regular or * minified) * * @param sFilename * The filename to check. * @return <code>true</code> if the passed filename is a CSS filename. */ public static boolean isCSSFilename (@Nullable final String sFilename) { return StringHelper.endsWith (sFilename, CCSS.FILE_EXTENSION_CSS); }