List of usage examples for org.apache.commons.lang3 StringUtils endsWith
public static boolean endsWith(final CharSequence str, final CharSequence suffix)
Check if a CharSequence ends with a specified suffix.
null s are handled without exceptions.
From source file:AIR.Common.Utilities.Path.java
public static String getDirectoryName(String path) { if (StringUtils.endsWith(path, "/") || StringUtils.endsWith(path, "\\")) return path.substring(0, path.length() - 1); File f = new File(path); return f.getParent(); }
From source file:com.xpn.xwiki.render.macro.TableBuilder.java
public static Table build(String content) { Table table = new Table(); StringTokenizer tokenizer = new StringTokenizer(content, "|\n", true); String lastToken = null;/*from ww w . j av a 2s. co m*/ boolean firstCell = true; while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken(); if (token.equals("\r")) { continue; } // If a token contains [, then all tokens up to one containing a ] are concatenated. Kind of a block marker. if (token.indexOf('[') != -1 && token.indexOf(']') == -1) { String linkToken = ""; while (token.indexOf(']') == -1 && tokenizer.hasMoreTokens()) { linkToken += token; token = tokenizer.nextToken(); } token = linkToken + token; } if ("\n".equals(token)) { // New line: either new row, or a literal newline. lastToken = (lastToken == null) ? "" : lastToken; if (!StringUtils.endsWith(lastToken, "\\")) { // A new row, not a literal newline. // If the last cell didn't contain any data, then it was skipped. Add a blank cell to compensate. if ((StringUtils.isEmpty(lastToken) || "|".equals(lastToken)) && !firstCell) { table.addCell(" "); } table.newRow(); } else { // A continued row, with a literal newline. String cell = lastToken; // Keep concatenating while the cell data ends with \\ while (cell.endsWith("\\") && tokenizer.hasMoreTokens()) { token = tokenizer.nextToken(); if (!"|".equals(token)) { cell = cell + token; } else { break; } } firstCell = false; table.addCell(cell.trim()); if (!tokenizer.hasMoreTokens()) { table.newRow(); } } } else if (!"|".equals(token)) { // Cell data if (!token.endsWith("\\")) { // If the cell data ends with \\, then it will be continued. Current data is stored in lastToken. table.addCell(token.trim()); firstCell = false; } else if (!tokenizer.hasMoreTokens()) { // Remove backslashes from the end while (token.endsWith("\\")) { token = StringUtils.chop(token); } table.addCell(token.trim()); } } else if ("|".equals(token)) { // Cell delimiter if ((StringUtils.isEmpty(lastToken) && firstCell) || "|".equals(lastToken)) { // If the last cell didn't contain any data, then it was skipped. Add a blank cell to compensate. table.addCell(" "); firstCell = false; } else if (StringUtils.endsWith(lastToken, "\\")) { // The last cell wasn't added because it ended with a continuation mark (\\). Add it now. table.addCell(lastToken.trim()); firstCell = false; } } lastToken = token; } return table; }
From source file:io.wcm.devops.conga.resource.ClasspathResourceCollectionImpl.java
private static boolean isFolder(org.springframework.core.io.Resource classpathResource) throws IOException { return StringUtils.endsWith(classpathResource.getURL().toString(), "/"); }
From source file:com.yqboots.fss.core.support.FileTypeFilterPredicate.java
/** * {@inheritDoc}/*from w ww. j ava 2s .c o m*/ */ @Override public boolean test(final Path path) { if (!Files.isRegularFile(path)) { return false; } boolean result = false; for (final String fileType : acceptedFileTypes) { if (StringUtils.endsWith(path.getFileName().toString(), fileType)) { result = true; break; } } return result; }
From source file:com.sonicle.webtop.core.bol.OShare.java
public static boolean isRootKey(String key) { return StringUtils.endsWith(key, KEYSUFFIX_ROOT); }
From source file:com.wallissoftware.pushstate.client.PushStateHistorianImpl.java
/** * constructor./*from w w w . jav a 2 s . c o m*/ * * @param prelativePath relative path to use */ PushStateHistorianImpl(final String prelativePath) { this.relativePath = StringUtils.endsWith(prelativePath, "/") ? prelativePath : StringUtils.defaultString(prelativePath) + "/"; this.initToken(); this.registerPopstateHandler(); }
From source file:de.micromata.genome.logging.CollectLogEntryCallback.java
@Override public void onRow(LogEntry le) { if (nodePostfix != null) { LogAttribute attr = le.getAttributeByType(GenomeAttributeType.NodeName); if (attr != null && StringUtils.endsWith(attr.getValue(), nodePostfix) == false) { // ignore log entry return; }//from ww w .ja va 2s . c om } entries.add(le); }
From source file:com.willwinder.universalgcodesender.uielements.components.FirmwareSettingsFileTypeFilter.java
@Override public boolean accept(File f) { if (f.isDirectory()) { return true; }//www . j ava 2 s.c o m return StringUtils.endsWith(f.getName(), ".settings"); }
From source file:com.sonicle.webtop.core.bol.OShare.java
public static boolean isFolderKey(String key) { return StringUtils.endsWith(key, KEYSUFFIX_FOLDER); }
From source file:com.erudika.para.storage.LocalFileStore.java
/** * Consturcts a new instance based on a given folder. * @param folder the folder to store files in *//*from www . j av a 2s .com*/ public LocalFileStore(String folder) { if (StringUtils.endsWith(folder, File.separator)) { this.folder = folder; } else { this.folder = folder.concat(File.separator); } }