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:AIR.Common.Web.UrlHelper.java
public static String buildUrl(String firstPart, String secondPart) { String separatorChar = "/"; if (StringUtils.endsWith(firstPart, "/") || StringUtils.startsWith(secondPart, "/")) separatorChar = ""; return String.format("%s%s%s", firstPart, separatorChar, secondPart); }
From source file:com.sonar.it.jenkins.orchestrator.container.JenkinsDistribution.java
public boolean isRelease() { return !StringUtils.endsWith(version, "-SNAPSHOT"); }
From source file:com.btobits.automator.fix.comparator.MailComparator.java
public static void compare(final FixMessageType inMsg, final SMTPMessage inSmtpMessage) throws Exception { final List<String> errors = new ArrayList<String>(); try {//from w w w . j a v a 2 s . c o m // compare header field for (final FixMessageType.Field field : inMsg.getFields()) { if (!field.isGroup()) { final String value = getHeaderField(field.getName(), inSmtpMessage); if (StringUtils.isBlank(value) && StringUtils.isBlank(field.getValue())) { continue; } else if (StringUtils.isBlank(value)) { errors.add("Field [" + field.getName() + "] is absend in receive email."); } else if (!StringUtils.equals(field.getValue(), value) && StringUtils.startsWith(value, "<") && StringUtils.endsWith(value, ">")) { final String subValue = StringUtils.substringBetween(value, "<", ">"); if (StringUtils.isBlank(subValue)) { errors.add("Field [" + field.getName() + "] is not eq receive email field ['" + field.getValue() + " != " + value + "']."); } else if (!StringUtils.equalsIgnoreCase(subValue, field.getValue())) { errors.add("Field [" + field.getName() + "] is not eq receive email field ['" + field.getValue() + " != " + value + "']."); } } else if (!StringUtils.equals(field.getValue(), value)) { errors.add("Field [" + field.getName() + "] is not eq receive email field ['" + field.getValue() + " != " + value + "']."); } } else { // compare group final List<String> body = getDataFields(inSmtpMessage); final LinkedList<FixMessageType.Field> fields = field.getFields(); int count = 0; for (FixMessageType.Field grFld : fields) { final String value = getValueOnPosition(body, count); if (StringUtils.equals(grFld.getName(), FIX_MESSAGE_FLD)) { String fixMessage = getFixField("Original FIX message:", inSmtpMessage); if (!StringUtils.equals(fixMessage, grFld.getValue())) { errors.add( "Data fix field [" + grFld.getName() + "] is not eq receive email field ['" + grFld.getValue() + " != " + fixMessage + "']."); } } else { if (StringUtils.isBlank(value) && StringUtils.isBlank(grFld.getValue())) { } else { if (!StringUtils.equals(value, grFld.getValue())) { errors.add( "Data field [" + grFld.getName() + "] is not eq receive email field ['" + grFld.getValue() + " != " + value + "']."); } } } count++; } } } } catch (Exception ex) { throw new BuildException("Error compare message", ex); } if (!errors.isEmpty()) { throw new MessageDifferenceException(FixUtils.toString(errors)); } }
From source file:com.taobao.tdhs.jdbc.util.StringUtil.java
public static String escapeField(String field) { field = StringUtils.trim(field);//from ww w. j a va 2 s . com if (StringUtils.startsWith(field, VALUE_ESCAPE_QUOTATION_1) || StringUtils.endsWith(field, VALUE_ESCAPE_QUOTATION_1) || StringUtils.startsWith(field, VALUE_ESCAPE_QUOTATION_2) || StringUtils.endsWith(field, VALUE_ESCAPE_QUOTATION_2)) { return null; } if (StringUtils.startsWith(field, FIELD_ESCAPE_QUOTATION) && !StringUtils.endsWith(field, FIELD_ESCAPE_QUOTATION)) { return null; } if (!StringUtils.startsWith(field, FIELD_ESCAPE_QUOTATION) && StringUtils.endsWith(field, FIELD_ESCAPE_QUOTATION)) { return null; } if (StringUtils.startsWith(field, FIELD_ESCAPE_QUOTATION) && StringUtils.endsWith(field, FIELD_ESCAPE_QUOTATION)) { if (field.length() > 1) return field.substring(1, field.length() - 1); else return null; } return field; }
From source file:com.ewcms.web.filter.render.ResourceRender.java
/** * ?/*from w ww . ja v a 2 s.co m*/ * * @param response * @param uri ? * @return * @throws IOException */ @Override protected boolean output(HttpServletResponse response, String uri) throws IOException { //TODO windowUnix Resource resource = resourceService.getResourceByUri(uri); if (resource == null) { logger.debug("Resource is not exist,uri is {}", uri); return false; } String realPath = resource.getPath(); if (StringUtils.endsWith(resource.getThumbUri(), uri)) { realPath = resource.getThumbPath(); } try { IOUtils.copy(new FileInputStream(realPath), response.getOutputStream()); } catch (Exception e) { logger.warn("Resource is not exit,real path is{}", realPath); } response.flushBuffer(); return true; }
From source file:com.renatodelgaudio.awsupdate.EnvUtil.java
public static String INSTALL_DIR() { String root = System.getProperty(PROP_INSTALL_DIR); if (isBlank(root)) { log.error(/* w ww. j av a2 s. co m*/ "Environment not initiazed properly. Please make sure Java is started with a not empty value for -D" + PROP_INSTALL_DIR); throw new ConfigurationException("-D" + PROP_INSTALL_DIR + " is missing or empty. Program aborted"); } String trim = trim(root); if (!StringUtils.endsWith(trim, "/") && !StringUtils.endsWith(trim, "\\")) trim += File.separator; return trim; }
From source file:com.google.code.configprocessor.processing.properties.model.PropertyMapping.java
public void parse(String text, boolean trim) { String[] splitted = StringUtils.splitPreserveAllTokens(text, SEPARATOR_1 + SEPARATOR_2, 2); if (splitted.length > 1) { String name = splitted[0]; String value = splitted[1]; while (StringUtils.endsWith(name, SEPARATOR_ESCAPE)) { String[] aux = StringUtils.splitPreserveAllTokens(value, SEPARATOR_1 + SEPARATOR_2, 2); String charToAdd = Character.toString(text.charAt(name.length())); name += charToAdd;// www . j a v a 2s . c o m if (aux.length > 1) { name += aux[0]; value = aux[1]; } else if ((charToAdd.equals(SEPARATOR_1)) || (charToAdd.equals(SEPARATOR_2))) { name += value; value = null; } else { value = aux[0]; } } splitted[0] = name; splitted[1] = value; } if (trim) { propertyName = splitted[0].trim(); } else { propertyName = splitted[0]; } if (splitted.length == 1) { propertyValue = null; } else { propertyValue = splitted[1]; } }
From source file:com.glaf.core.entity.mybatis.MyBatisSessionFactory.java
public static Map<String, byte[]> getZipBytesMap(ZipInputStream zipInputStream) { Map<String, byte[]> zipMap = new java.util.HashMap<String, byte[]>(); java.util.zip.ZipEntry zipEntry = null; ByteArrayOutputStream baos = null; BufferedOutputStream bos = null; byte tmpByte[] = null; try {//from ww w . jav a 2 s . com while ((zipEntry = zipInputStream.getNextEntry()) != null) { String name = zipEntry.getName(); if (StringUtils.endsWith(name, "Mapper.xml")) { tmpByte = new byte[BUFFER]; baos = new ByteArrayOutputStream(); bos = new BufferedOutputStream(baos, BUFFER); int i = 0; while ((i = zipInputStream.read(tmpByte, 0, BUFFER)) != -1) { bos.write(tmpByte, 0, i); } bos.flush(); byte[] bytes = baos.toByteArray(); IOUtils.closeStream(baos); IOUtils.closeStream(baos); zipMap.put(zipEntry.getName(), bytes); } } } catch (Exception ex) { throw new RuntimeException(ex); } finally { IOUtils.closeStream(baos); IOUtils.closeStream(baos); } return zipMap; }
From source file:com.htmlhifive.tools.jslint.parse.JsFileInfo.java
/** * ?.//from www.ja v a2 s .com * * @param jsfile ? * @throws IOException */ public void append(File jsfile) throws IOException { if (!StringUtils.endsWith(jsfile.getName(), "." + JSLintPluginConstant.EXTENTION_JS)) { throw new IllegalArgumentException(); } BufferedReader reader = new BufferedReader(new FileReader(jsfile)); append(reader); }
From source file:eu.annocultor.converters.solr.SolrPlacesTagger.java
@Override void afterTermMatched(Term term) { if (!StringUtils.endsWith(term.getProperty("division"), "A.PCLI")) { if (coordinates == null || !coordinates.isAssigned()) { coordinates = new Coordinates(term.getProperty("latitude"), term.getProperty("longitude")); }//from ww w . ja v a2s. co m } }