Java Code Examples for org.apache.commons.lang.StringUtils#lastIndexOf()
The following examples show how to use
org.apache.commons.lang.StringUtils#lastIndexOf() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImpexCommandContentAssistProcessor.java From hybris-commerce-eclipse-plugin with Apache License 2.0 | 6 votes |
private Collection<? extends ICompletionProposal> addHeaderAttributes(String oldWord, int offset) { int bracketPos = StringUtils.lastIndexOf(oldWord, "["); int wordLength = oldWord.length(); int replacementPos = wordLength - bracketPos; String word = StringUtils.substringAfterLast(oldWord, "["); List<String> keywords = Formatter.IMPEX_KEYWORDS_ATTRIBUTES; Collection<ICompletionProposal> result = Lists.newArrayList(); for (String keyword : keywords) { if (keyword.toUpperCase(Locale.ENGLISH).startsWith(word.toUpperCase(Locale.ENGLISH)) && word.length() < keyword.length()) { result.add(new CompletionProposal(keyword + "=", (offset - replacementPos) + 1, word.length(), keyword.length() + 1)); } } return result; }
Example 2
Source File: RangerRESTUtils.java From ranger with Apache License 2.0 | 6 votes |
public String getHostnameFromPluginId(String pluginId, String serviceName) { String ret = ""; if (StringUtils.isNotBlank(pluginId)) { int lastIndex; String[] parts = pluginId.split("@"); int index = parts.length > 1 ? 1 : 0; if (StringUtils.isNotBlank(serviceName)) { lastIndex = StringUtils.lastIndexOf(parts[index], serviceName); if (lastIndex > 1) { ret = parts[index].substring(0, lastIndex-1); } } else { lastIndex = StringUtils.lastIndexOf(parts[index], "-"); if (lastIndex > 0) { ret = parts[index].substring(0, lastIndex); } } } return ret; }
Example 3
Source File: ArtifactFile.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ArtifactFile(File file, String version) { name = file.getName(); extension = ""; classifier = ""; boolean done = false; int startVersion = StringUtils.lastIndexOf(name, "-" + version); if (startVersion >= 0) { int endVersion = startVersion + version.length() + 1; if (endVersion == name.length()) { name = name.substring(0, startVersion); done = true; } else if (endVersion < name.length() && name.charAt(endVersion) == '-') { String tail = name.substring(endVersion + 1); name = name.substring(0, startVersion); classifier = StringUtils.substringBeforeLast(tail, "."); extension = StringUtils.substringAfterLast(tail, "."); done = true; } else if (endVersion < name.length() && StringUtils.lastIndexOf(name, ".") == endVersion) { extension = name.substring(endVersion + 1); name = name.substring(0, startVersion); done = true; } } if (!done) { extension = StringUtils.substringAfterLast(name, "."); name = StringUtils.substringBeforeLast(name, "."); } if (extension.length() == 0) { extension = null; } if (classifier.length() == 0) { classifier = null; } }
Example 4
Source File: ArtifactFile.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ArtifactFile(File file, String version) { name = file.getName(); extension = ""; classifier = ""; boolean done = false; int startVersion = StringUtils.lastIndexOf(name, "-" + version); if (startVersion >= 0) { int endVersion = startVersion + version.length() + 1; if (endVersion == name.length()) { name = name.substring(0, startVersion); done = true; } else if (endVersion < name.length() && name.charAt(endVersion) == '-') { String tail = name.substring(endVersion + 1); name = name.substring(0, startVersion); classifier = StringUtils.substringBeforeLast(tail, "."); extension = StringUtils.substringAfterLast(tail, "."); done = true; } else if (endVersion < name.length() && StringUtils.lastIndexOf(name, ".") == endVersion) { extension = name.substring(endVersion + 1); name = name.substring(0, startVersion); done = true; } } if (!done) { extension = StringUtils.substringAfterLast(name, "."); name = StringUtils.substringBeforeLast(name, "."); } if (extension.length() == 0) { extension = null; } if (classifier.length() == 0) { classifier = null; } }
Example 5
Source File: DalgenLoader.java From mybatis-dalgen with Apache License 2.0 | 5 votes |
/** * Gets class and import. * * @param base the base * @param classType the class type * @return the class and import */ private String getClassAndImport(Base base, String classType) { Validate.notEmpty(classType, "DalgenLoader.getClassAndImport error classType 不能为 null Base=" + base); int lastIdx = StringUtils.lastIndexOf(classType, "."); if (lastIdx > 0) { base.addImport(classType); } //返回方法 return StringUtils.substring(classType, lastIdx + 1); }
Example 6
Source File: FuncSubstringIndex.java From antsdb with GNU Lesser General Public License v3.0 | 5 votes |
private String lastIndexOf(String str, String delim, Long count) { int pos = str.length(); for (int i=0; i<count; i++) { pos = StringUtils.lastIndexOf(str, delim, pos-1); if (pos < 0) { return str; } } return str.substring(pos+1); }
Example 7
Source File: ArtifactFile.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ArtifactFile(File file, String version) { name = file.getName(); extension = ""; classifier = ""; boolean done = false; int startVersion = StringUtils.lastIndexOf(name, "-" + version); if (startVersion >= 0) { int endVersion = startVersion + version.length() + 1; if (endVersion == name.length()) { name = name.substring(0, startVersion); done = true; } else if (endVersion < name.length() && name.charAt(endVersion) == '-') { String tail = name.substring(endVersion + 1); name = name.substring(0, startVersion); classifier = StringUtils.substringBeforeLast(tail, "."); extension = StringUtils.substringAfterLast(tail, "."); done = true; } else if (endVersion < name.length() && StringUtils.lastIndexOf(name, ".") == endVersion) { extension = name.substring(endVersion + 1); name = name.substring(0, startVersion); done = true; } } if (!done) { extension = StringUtils.substringAfterLast(name, "."); name = StringUtils.substringBeforeLast(name, "."); } if (extension.length() == 0) { extension = null; } if (classifier.length() == 0) { classifier = null; } }
Example 8
Source File: ArtifactFile.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ArtifactFile(File file, String version) { name = file.getName(); extension = ""; classifier = ""; boolean done = false; int startVersion = StringUtils.lastIndexOf(name, "-" + version); if (startVersion >= 0) { int endVersion = startVersion + version.length() + 1; if (endVersion == name.length()) { name = name.substring(0, startVersion); done = true; } else if (endVersion < name.length() && name.charAt(endVersion) == '-') { String tail = name.substring(endVersion + 1); name = name.substring(0, startVersion); classifier = StringUtils.substringBeforeLast(tail, "."); extension = StringUtils.substringAfterLast(tail, "."); done = true; } else if (endVersion < name.length() && StringUtils.lastIndexOf(name, ".") == endVersion) { extension = name.substring(endVersion + 1); name = name.substring(0, startVersion); done = true; } } if (!done) { extension = StringUtils.substringAfterLast(name, "."); name = StringUtils.substringBeforeLast(name, "."); } if (extension.length() == 0) { extension = null; } if (classifier.length() == 0) { classifier = null; } }
Example 9
Source File: UtilLoggingXmlLogImporter.java From otroslogviewer with Apache License 2.0 | 5 votes |
protected String extractFileName(String clazz) { int clazzStart = StringUtils.lastIndexOf(clazz, '.') + 1; clazzStart = Math.max(0, clazzStart); int clazzEnd = StringUtils.indexOf(clazz, '$'); if (clazzEnd < 0) { clazzEnd = clazz.length(); } return StringUtils.substring(clazz, clazzStart, clazzEnd); }
Example 10
Source File: ServiceREST.java From ranger with Apache License 2.0 | 5 votes |
private String getGeneratedTagServiceName(String resourceServiceName) { int lastIndexOfMarker = StringUtils.lastIndexOf(resourceServiceName, '_'); if (lastIndexOfMarker != -1) { return resourceServiceName.substring(0, lastIndexOfMarker) + "_tag"; } else { return null; } }
Example 11
Source File: EBusCommandProcessor.java From openhab1-addons with Eclipse Public License 2.0 | 4 votes |
/** * @param provider * @param itemName * @param type * @return */ public byte[] composeSendData(EBusBindingProvider provider, String itemName, Command command) { if (configurationProvider == null || configurationProvider.isEmpty()) { logger.debug("eBus configuration provider not ready, can't get send data yet."); return null; } byte[] data = null; String cmd = provider.getCommand(itemName); Byte dst = provider.getTelegramDestination(itemName); Byte src = provider.getTelegramSource(itemName); HashMap<String, Object> values = null; if (StringUtils.isEmpty(cmd)) { // use id instead String id = provider.getId(itemName); if (!StringUtils.isEmpty(id)) { String[] split = StringUtils.split(id, "."); if (split.length > 1) { cmd = split[0] + "." + split[1]; } } } if (src == null) { src = connector.getSenderId(); } if (command == null) { // polling data = composeEBusTelegram(cmd, dst, src, values); } else { String setValue = provider.getSet(itemName); int index = StringUtils.lastIndexOf(setValue, "."); String cmdId = StringUtils.left(setValue, index); String valueName = StringUtils.substring(setValue, index + 1); // try to convert command to a supported value Object value = StateUtils.convertFromState(command); if (value != null) { values = new HashMap<String, Object>(); values.put(valueName, value); } data = composeEBusTelegram(cmdId, dst, src, values); } // first try, data-ON, data-OFF, etc. if (data == null) { String type = command != null ? command.toString().toLowerCase() : null; if (StringUtils.isNotEmpty(type)) { data = provider.getTelegramData(itemName, type); } } if (data == null) { // ok, try data param data = provider.getTelegramData(itemName); } return data; }