List of usage examples for org.apache.commons.lang StringUtils endsWith
public static boolean endsWith(String str, String suffix)
Check if a String ends with a specified suffix.
From source file:com.enonic.cms.business.core.content.ContentNameValidator.java
public static void validate(String contentName) { if (StringUtils.isEmpty(contentName)) { throw new ContentNameValidatorException("Content name cannot be empty"); }/*w ww.j av a 2s.c o m*/ if (StringUtils.startsWith(contentName, " ") || StringUtils.endsWith(contentName, " ")) { throw new ContentNameValidatorException("Content name cannot start or end with whitespace"); } if (StringUtils.containsAny(contentName, FORBIDDEN_CHARS)) { throw new ContentNameValidatorException( "Content name cannot contain any of these characters: " + FORBIDDEN_CHARS); } if (contentName.length() > CONTENT_NAME_MAX_LENGTH) { throw new ContentNameValidatorException("Content name is too long: " + contentName.length() + " . Maximum length is " + CONTENT_NAME_MAX_LENGTH + " characters."); } }
From source file:com.hangum.tadpole.mongodb.erd.core.utils.MongodbUtils.java
/** * Is mongodb reference key//w w w.j ava2 s . c o m * * @param type * @param field * @return */ public static boolean isReferenceKey(String type, String field) { if ("ObjectId".equals(type) && !StringUtils.startsWith(field, "_id") && StringUtils.endsWith(field, "_id")) { return true; } return false; }
From source file:com.xx_dev.apn.proxy.ApnProxyLocalAddressChooser.java
public static String choose(String hostName) { for (ApnProxyLocalIpRule localIpRule : ApnProxyConfig.getConfig().getLocalIpRuleList()) { for (String originalHost : localIpRule.getOriginalHostList()) { if (StringUtils.equals(originalHost, hostName) || StringUtils.endsWith(hostName, "." + originalHost)) { return localIpRule.getLocalIp(); }/*from w ww. j a va2 s.c o m*/ } } return null; }
From source file:com.adobe.acs.commons.rewriter.impl.SaxElementUtils.java
public static boolean isCss(final String elementName, final Attributes attrs) { final String type = attrs.getValue("", "type"); final String href = attrs.getValue("", "href"); if (StringUtils.equals("link", elementName) && StringUtils.equals(type, CSS_TYPE) && StringUtils.startsWith(href, "/") && !StringUtils.startsWith(href, "//") && StringUtils.endsWith(href, LibraryType.CSS.extension)) { return true; }//from w ww .java 2s .c om return false; }
From source file:com.dcsquare.hivemq.spi.topic.PermissionTopicMatcher.java
private static boolean matchesWildcards(final String topicSubscription, final String actualTopic) { if (topicSubscription.contains("#")) { if (!StringUtils.endsWith(topicSubscription, "/#") && topicSubscription.length() > 1) { return false; }/*from w ww .j a v a2s . com*/ } final String[] subscription = StringUtils.splitPreserveAllTokens(topicSubscription, "/"); final String[] topic = StringUtils.splitPreserveAllTokens(actualTopic, "/"); final int smallest = min(subscription.length, topic.length); for (int i = 0; i < smallest; i++) { final String sub = subscription[i]; final String t = topic[i]; if (!sub.equals(t)) { if (sub.equals("#")) { return true; } else if (sub.equals("+")) { //Matches Topic Level wildcard, so we can just ignore } else { //Does not match a wildcard and is not equal to the topic token return false; } } } //If the length is equal or the subscription token with the number x+1 (where x is the topic length) is a wildcard, //everything is alright. return subscription.length == topic.length || (subscription.length - topic.length == 1 && (subscription[subscription.length - 1].equals("#"))); }
From source file:com.adobe.acs.commons.rewriter.impl.SaxElementUtils.java
public static boolean isJavaScript(final String elementName, final Attributes attrs) { final String type = attrs.getValue("", "type"); final String src = attrs.getValue("", "src"); if (StringUtils.equals("script", elementName) && StringUtils.equals(type, JS_TYPE) && StringUtils.startsWith(src, "/") && !StringUtils.startsWith(src, "//") && StringUtils.endsWith(src, LibraryType.JS.extension)) { return true; }// w w w. ja va 2 s. c om return false; }
From source file:eu.eidas.auth.commons.PropertiesLoader.java
/** * Loads the properties defined in an xml file with the format <//?xml version="1.0" encoding="UTF-8" * standalone="no"?> <//!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> * <comment>Comment</comment> <entry key="keyName">Some Value</entry> </properties> * * @param xmlFilePath the file path// ww w . j a v a 2 s .c o m * @return Object @Properties */ @Nonnull public static Properties loadPropertiesXMLFile(@Nonnull String xmlFilePath) { Properties props; InputStream fileProperties = null; try { if (StringUtils.isEmpty(xmlFilePath) || !StringUtils.endsWith(xmlFilePath, "xml")) { throw new InternalErrorEIDASException(EidasErrorKey.INTERNAL_ERROR.errorCode(), EidasErrorKey.INTERNAL_ERROR.errorMessage(), "Not valid file!"); } props = new Properties(); fileProperties = new FileInputStream(xmlFilePath); //load the xml file into properties format props.loadFromXML(fileProperties); return props; } catch (InternalErrorEIDASException e) { LOG.error("ERROR : " + e.getMessage()); throw e; } catch (Exception e) { LOG.error("ERROR : " + e.getMessage()); throw new InternalErrorEIDASException(EidasErrorKey.INTERNAL_ERROR.errorCode(), EidasErrorKey.INTERNAL_ERROR.errorMessage(), e); } finally { try { if (fileProperties != null) { fileProperties.close(); } } catch (IOException ioe) { LOG.error("error closing the file: " + ioe, ioe); } } }
From source file:com.ning.hfind.primary.SizePrimary.java
public SizePrimary(String size) { if (StringUtils.endsWith(size, SIZE_CHARACTER)) { blockMode = false;// w w w . j a v a 2 s . c om size = StringUtils.chop(size); } operandModifier = new OperandModifier(size); this.size = operandModifier.getSanitizedArgument(); }
From source file:com.intel.cosbench.driver.generator.DefaultSizeGenerator.java
public long setUnit(String unit) { if (StringUtils.endsWith(unit, "GB")) return (base = 1000 * 1000 * 1000); if (StringUtils.endsWith(unit, "MB")) return (base = 1000 * 1000); if (StringUtils.endsWith(unit, "KB")) return (base = 1000); if (StringUtils.endsWith(unit, "B")) return (base = 1); String msg = "unrecognized size unit: " + unit; throw new ConfigException(msg); }
From source file:com.adaptris.core.services.metadata.compare.EndsWith.java
@Override public MetadataElement compare(MetadataElement firstItem, MetadataElement secondItem) { return new MetadataElement(getResultKey(), String.valueOf(StringUtils.endsWith(firstItem.getValue(), secondItem.getValue()))); }