List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling null .
From source file:org.xwiki.validator.DutchWebGuidelinesValidator.java
/** * Use (at least) the meta element to specify the character set and place this element as high as possible in the * head section of the markup.//from w ww . j a va 2 s .c o m */ public void validateRpd16s4() { Node meta = getElement(ELEM_META); assertTrue(Type.ERROR, "rpd16s4.position", hasAttribute(meta, ATTR_CONTENT) && StringUtils.containsIgnoreCase(getAttributeValue(meta, ATTR_CONTENT), CONTENT_CHARSET_FRAGMENT)); }
From source file:org.xwiki.validator.HTML5DutchWebGuidelinesValidator.java
/** * Do not describe the mechanism behind following a link. *///from www.j a v a2 s. c o m public void validateRpd8s1() { List<String> forbiddenLinkTexts = Arrays.asList(messages.getString("rpd8s1.forbiddenLinkTexts").split(",")); for (Element link : getElements(ELEM_LINK)) { for (Element linkChild : link.getAllElements()) { if (linkChild.hasText()) { for (String forbiddenLinkText : forbiddenLinkTexts) { assertFalse(Type.ERROR, "rpd8s1.link", StringUtils.containsIgnoreCase(linkChild.text(), forbiddenLinkText)); } } } } }
From source file:org.xwiki.validator.HTML5DutchWebGuidelinesValidator.java
/** * Specify the character set for web pages. *///from w ww. ja va 2s. co m public void validateRpd16s1() { String charset = getMetaCharset(); assertTrue(Type.ERROR, "rpd16s1.nometa", charset != null); assertTrue(Type.ERROR, "rpd16s1.charset", StringUtils.containsIgnoreCase(charset, CONTENT_CHARSET_FRAGMENT)); }
From source file:org.xwiki.validator.HTML5DutchWebGuidelinesValidator.java
/** * Specify the UTF-8 character set./*w w w. j a v a2 s .c o m*/ */ public void validateRpd16s2() { String charset = getMetaCharset(); assertTrue(Type.ERROR, "rpd16s2.nometa", charset != null); assertTrue(Type.ERROR, "rpd16s2.notutf8", StringUtils.containsIgnoreCase(charset, "charset=utf-8")); }
From source file:org.xwiki.validator.HTML5DutchWebGuidelinesValidator.java
/** * Use (at least) the meta element to specify the character set and place this element as high as possible in the * head section of the markup./* w ww .j a v a 2 s . co m*/ */ public void validateRpd16s4() { Element meta = getElement(ELEM_META); assertTrue(Type.ERROR, "rpd16s4.position", hasAttribute(meta, ATTR_CONTENT) && StringUtils.containsIgnoreCase(getAttributeValue(meta, ATTR_CONTENT), CONTENT_CHARSET_FRAGMENT)); }
From source file:org.yamj.common.model.YamjInfo.java
/** * Calculate the database name and IP address from the connection URL *///from w w w . j av a 2s . c om private void findDatabaseInfo() { String dbUrl = PropertyTools.getProperty("yamj3.database.url", ""); if (StringUtils.containsIgnoreCase(dbUrl, "derby")) { this.databaseName = "Derby Embedded"; this.databaseIp = "localhost"; } else if (dbUrl.contains("/") && StringUtils.containsIgnoreCase(dbUrl, "mysql")) { this.databaseName = dbUrl.substring(dbUrl.lastIndexOf('/') + 1); this.databaseIp = dbUrl.substring(dbUrl.indexOf("//") + 2, dbUrl.lastIndexOf('/')); } else { this.databaseName = "UNKNOWN"; this.databaseIp = "UNKNOWN"; } }
From source file:org.yamj.core.api.options.OptionsIdArtwork.java
private void splitArtwork() { this.artworkTypes.clear(); if (StringUtils.containsIgnoreCase(artwork, "ALL")) { // Add all the types to the list for (ArtworkType at : ArtworkType.values()) { artworkTypes.add(at.toString()); }/*from w w w . j a v a 2s .c o m*/ // Remove the unknown type artworkTypes.remove(ArtworkType.UNKNOWN.toString()); } else { for (String param : StringUtils.split(artwork, ",")) { // Validate that the string passed is a correct artwork type ArtworkType at = ArtworkType.fromString(param); if (at != ArtworkType.UNKNOWN) { artworkTypes.add(at.toString()); } } } }
From source file:org.yamj.core.api.options.OptionsIndexVideo.java
/** * Get a list of the video types to search for * * @return/*from www . j ava 2s .co m*/ */ public List<MetaDataType> splitTypes() { if (CollectionUtils.isEmpty(videoTypes)) { if (StringUtils.containsIgnoreCase(type, "ALL") || StringUtils.isEmpty(type)) { videoTypes.add(MetaDataType.MOVIE); videoTypes.add(MetaDataType.SERIES); videoTypes.add(MetaDataType.SEASON); } else { for (String param : StringUtils.split(type, ",")) { // Validate that the string passed is a correct artwork type MetaDataType mdt = MetaDataType.fromString(param); if (mdt != MetaDataType.UNKNOWN) { videoTypes.add(mdt); } } } } return videoTypes; }
From source file:org.yamj.core.service.file.FileTools.java
public static boolean isWithinSpecialFolder(StageFile stageFile, String folderName) { if (StringUtils.isBlank(folderName) || stageFile == null) { return false; }//w ww . j a va 2 s . co m StageDirectory directory = stageFile.getStageDirectory(); if (directory == null) { return false; } if (directory.getDirectoryName().equalsIgnoreCase(folderName)) { return true; } return StringUtils.containsIgnoreCase(directory.getDirectoryPath(), getPathFragment(folderName)); }
From source file:org.yamj.core.service.metadata.nfo.InfoReader.java
/** * Try and read a NFO file for information * * @param nfoFile/* w w w. j a v a 2s.c o m*/ * @param nfoText * @param dto */ public void readNfoFile(StageFile stageFile, InfoDTO dto) { String nfoFilename = stageFile.getFileName(); File nfoFile = new File(stageFile.getFullPath()); String nfoContent = null; try { nfoContent = FileUtils.readFileToString(nfoFile, FileTools.DEFAULT_CHARSET); } catch (Exception e) { LOG.error("Unable to read NFO file: " + stageFile.getFullPath(), e); nfoFile = null; nfoContent = stageFile.getContent(); if (StringUtils.isBlank(nfoContent)) { LOG.warn("NFO file '{}' is not readable", nfoFilename); try { stageFile.setStatus(StatusType.INVALID); this.stagingService.updateStageFile(stageFile); } catch (Exception ignore) { // error can be ignored } // nothing to do for this stage file return; } LOG.warn("NFO file '{}' is not readable; try stage file content", nfoFilename); } boolean parsedNfo = Boolean.FALSE; // was the NFO XML parsed correctly or at all boolean hasXml = Boolean.FALSE; if (StringUtils.containsIgnoreCase(nfoContent, XML_START + DOMHelper.TYPE_MOVIE) || StringUtils.containsIgnoreCase(nfoContent, XML_START + DOMHelper.TYPE_TVSHOW) || StringUtils.containsIgnoreCase(nfoContent, XML_START + DOMHelper.TYPE_EPISODE)) { hasXml = Boolean.TRUE; } // If the file has XML tags in it, try reading it as a pure XML file if (hasXml) { parsedNfo = this.readXmlNfo(nfoFile, nfoContent, nfoFilename, dto); } // If it has XML in it, but didn't parse correctly, try splitting it out if (hasXml && !parsedNfo) { int posMovie = findPosition(nfoContent, DOMHelper.TYPE_MOVIE); int posTv = findPosition(nfoContent, DOMHelper.TYPE_TVSHOW); int posEp = findPosition(nfoContent, DOMHelper.TYPE_EPISODE); int start = Math.min(posMovie, Math.min(posTv, posEp)); posMovie = StringUtils.indexOf(nfoContent, XML_END + DOMHelper.TYPE_MOVIE); posTv = StringUtils.indexOf(nfoContent, XML_END + DOMHelper.TYPE_TVSHOW); posEp = StringUtils.indexOf(nfoContent, XML_END + DOMHelper.TYPE_EPISODE); int end = Math.max(posMovie, Math.max(posTv, posEp)); if ((end > -1) && (end > start)) { end = StringUtils.indexOf(nfoContent, '>', end) + 1; // Send text to be read String nfoTrimmed = StringUtils.substring(nfoContent, start, end); parsedNfo = readXmlNfo(null, nfoTrimmed, nfoFilename, dto); nfoTrimmed = StringUtils.remove(nfoContent, nfoTrimmed); if (parsedNfo && StringUtils.isNotBlank(nfoTrimmed)) { // we have some text left, so scan that with the text scanner readTextNfo(nfoTrimmed, dto); } } } // If the XML wasn't found or parsed correctly, then fall back to the old method if (parsedNfo) { LOG.debug("Successfully scanned {} as XML format", nfoFilename); } else { // If the XML wasn't found or parsed correctly, then fall back to the old method parsedNfo = readTextNfo(nfoContent, dto); if (parsedNfo) { LOG.debug("Successfully scanned {} as text format", nfoFilename); } else { LOG.warn("Failed to find any information in {}", nfoFilename); try { stageFile.setStatus(StatusType.INVALID); this.stagingService.updateStageFile(stageFile); } catch (Exception ignore) { // error can be ignored cause will be retried later } } } }