/** * 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; }
public CSSFiles(@Nonnull final IReadableResource aFile) { final IMicroDocument aDoc = MicroReader.readMicroXML(aFile); if (aDoc != null) { final IMicroElement eRoot = aDoc.getDocumentElement(); if (eRoot.getTagName().equals("list")) { // Old style s_aLogger.warn("CSS file " + aFile.getPath() + " is in old syntax"); final List<String> aAllCSSFiles = new ArrayList<String>(); if (XMLListHandler.readList(eRoot, aAllCSSFiles).isFailure()) s_aLogger.error("Failed to read " + aFile.getPath()); for (final String sCSS : aAllCSSFiles) addGlobalItem(null, sCSS, null); } else { // New style for (final IMicroElement eChild : eRoot.getAllChildElements("css")) { final String sCondComment = eChild.getAttribute("condcomment"); final String sPath = eChild.getAttribute("path"); if (StringHelper.hasNoText(sPath)) { s_aLogger.error("Found CSS item without a path in " + aFile.getPath()); continue; } final String sMedia = eChild.getAttribute("media"); // ESCA-JAVA0261: final Set<ECSSMedium> aMediaList = new LinkedHashSet<ECSSMedium>(); if (sMedia != null) for (final String sMedium : RegExHelper.getSplitToArray(sMedia, ",\\s*")) { final ECSSMedium eMedium = ECSSMedium.getFromNameOrNull(sMedium); if (eMedium == null) { s_aLogger.warn( "CSS item '" + sPath + "' in " + aFile.getPath() + " has an invalid medium '" + sMedium + "' - ignoring"); continue; } aMediaList.add(eMedium); } addGlobalItem(sCondComment, sPath, aMediaList); } } } }