/** * Check if the string is <code>null</code> or empty after trimming. * * @param s * The string to check. May be <code>null</code>. * @return <code>true</code> if the string is <code>null</code> or empty or * consists only of whitespaces, <code>false</code> otherwise */ public static boolean isEmptyAfterTrim (@Nullable final String s) { return hasNoTextAfterTrim (s); }
@Nullable public static String [] getSearchTexts (@Nullable final String sSearchText) { if (StringHelper.hasNoTextAfterTrim (sSearchText)) return null; return RegExHelper.getSplitToArray (sSearchText, "\\s+"); }
public CSSExpressionMemberMathUnitSimple (@Nonnull @Nonempty final String sText) { if (StringHelper.hasNoTextAfterTrim (sText)) throw new IllegalArgumentException ("text"); m_sText = sText.trim (); m_eUnit = CSSNumberHelper.getMatchingUnitExclPercentage (m_sText); }
public CSSExpressionMemberMathUnitSimple (@Nonnull @Nonempty final String sText) { if (StringHelper.hasNoTextAfterTrim (sText)) throw new IllegalArgumentException ("text"); m_sText = sText.trim (); m_eUnit = CSSNumberHelper.getMatchingUnitExclPercentage (m_sText); }
/** * Initialization method. * * @param sSearchTerms * The search term string. It is internally separated into multiple * tokens by using a "\s+" regular expression. * @return this */ @Nonnull protected Finder initialize (@Nonnull @Nonempty final String sSearchTerms) { if (StringHelper.hasNoTextAfterTrim (sSearchTerms)) throw new IllegalArgumentException ("SearchTerms"); // Split search terms by white spaces m_aSearchTerms = RegExHelper.getSplitToArray (sSearchTerms.trim (), "\\s+"); if (m_aSearchTerms.length == 0) throw new IllegalStateException ("Weird - splitting of '" + sSearchTerms.trim () + "' failed!"); for (final String sSearchTerm : m_aSearchTerms) if (sSearchTerm.length () == 0) throw new IllegalArgumentException ("Weird - empty search term present!"); return this; }
if (StringHelper.hasNoTextAfterTrim (sClass)) throw new IllegalStateException ("Persistence file " + aURL + ": class name is missing!"); GenericReflection.getClassFromName (sClass.trim ());
@Override @Nonnull protected final IAjaxResponse mainHandleRequest (@Nonnull final LECTYPE aLEC) throws Exception { final String sOriginalQuery = getQueryString (aLEC); if (StringHelper.hasNoTextAfterTrim (sOriginalQuery)) { // May happen when the user enters " " (only spaces) return AjaxDefaultResponse.createSuccess (aLEC.getRequestScope (), new JsonObject ()); } // Create the main Finder object final Finder aFinder = createFinder (sOriginalQuery, aLEC); // Map from ID to name final List <? extends TypeaheadDatum> aMatchingDatums = getAllMatchingDatums (aFinder, aLEC); // Convert to JSON, sorted by display name using the current display locale final JsonArray ret = new JsonArray (); for (final TypeaheadDatum aDatum : aMatchingDatums) ret.add (aDatum.getAsJson ()); // Use the simple response, because the response layout is predefined! return new AjaxSimpleResponse (true, ret); } }