Example usage for org.apache.commons.lang StringUtils startsWith

List of usage examples for org.apache.commons.lang StringUtils startsWith

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils startsWith.

Prototype

public static boolean startsWith(String str, String prefix) 

Source Link

Document

Check if a String starts with a specified prefix.

Usage

From source file:com.kinglcc.spring.jms.core.DestinationType.java

public static DestinationType asDestinationType(String destinationName) {
    if (StringUtils.isNotBlank(destinationName)) {
        if (StringUtils.startsWith(destinationName, TOPIC_PREFIX)) {
            return asTopicType(destinationName);
        }//from  w w w  .j  av  a  2  s .c om
    }
    return QUEUE;
}

From source file:com.enonic.cms.core.search.IndexSettingsBuilderImpl.java

private Map<String, String> getIndexPropertyMap() {
    return configProperties.getSubMap(new Predicate<String>() {
        @Override//from  ww w .  j av a  2s .  c om
        public boolean apply(final String input) {
            return StringUtils.startsWith(input, INDEX_PROPERTIES_PREFIX);
        }
    });
}

From source file:com.adaptris.core.services.metadata.compare.StartsWith.java

@Override
public MetadataElement compare(MetadataElement firstItem, MetadataElement secondItem) {
    return new MetadataElement(getResultKey(),
            String.valueOf(StringUtils.startsWith(firstItem.getValue(), secondItem.getValue())));
}

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 .  jav a  2s . c  om
        // 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: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.taobao.tdhs.jdbc.util.StringUtil.java

public static String escapeField(String field) {
    field = StringUtils.trim(field);// w  ww  .j a  va 2s  . c om
    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:cec.easyshop.storefront.web.wrappers.UrlEncodeHttpRequestWrapper.java

@Override
public String getRequestURI() {
    final String originalRequestURI = super.getRequestURI();
    final String originalContextPath = super.getContextPath();
    final String contextPath = this.getContextPath();
    final String originalRequestUriMinusAnyContextPath;

    if (StringUtils.startsWith(originalRequestURI, contextPath)) {
        originalRequestUriMinusAnyContextPath = StringUtils.remove(originalRequestURI, contextPath);
    } else if (StringUtils.startsWith(originalRequestURI, originalContextPath)) {
        originalRequestUriMinusAnyContextPath = StringUtils.remove(originalRequestURI, originalContextPath);
    } else {//from www  . ja v a 2s .co  m
        originalRequestUriMinusAnyContextPath = originalRequestURI;
    }

    return getContextPath() + originalRequestUriMinusAnyContextPath;
}

From source file:com.ctc.storefront.web.wrappers.UrlEncodeHttpRequestWrapper.java

@Override
public String getRequestURI() {
    final String originalRequestURI = super.getRequestURI();
    final String originalContextPath = super.getContextPath();
    final String contextPath = this.getContextPath();
    final String originalRequestUriMinusAnyContextPath;

    if (StringUtils.startsWith(originalRequestURI, contextPath)) {
        originalRequestUriMinusAnyContextPath = StringUtils.removeStart(originalRequestURI, contextPath);
    } else if (StringUtils.startsWith(originalRequestURI, originalContextPath)) {
        originalRequestUriMinusAnyContextPath = StringUtils.removeStart(originalRequestURI,
                originalContextPath);//from   www  .  j  a v  a2 s  . co m
    } else {
        originalRequestUriMinusAnyContextPath = originalRequestURI;
    }

    return getContextPath() + originalRequestUriMinusAnyContextPath;
}

From source file:com.thinkbiganalytics.feedmgr.service.EncryptionService.java

public String encrypt(String str) {
    String encrypted = null;/*from  w  w w  .  j av a2 s. co  m*/
    if (!isEncrypted(str)) {
        encrypted = encryptionController.encrypt(str, MediaType.TEXT_PLAIN);
        if (!StringUtils.startsWith(encrypted, encryptedPrefix)) {
            encrypted = encryptedPrefix + encrypted;
        }
    } else {
        encrypted = str;
    }
    return encrypted;
}

From source file:io.wcm.tooling.netbeans.sightly.completion.classLookup.MemberLookupResult.java

/**
 *
 * @param variableName//from   w w w .  j a v  a 2s.  c  o m
 * @param methodName
 * @param returnType
 */
public MemberLookupResult(String variableName, String methodName, String returnType) {
    this.variableName = variableName;
    this.methodName = methodName;

    //TODO: this is a hack to get support for list, set, map, enumeration, array and collection
    String tmp = returnType;
    if (StringUtils.startsWith(returnType, List.class.getName())
            || StringUtils.startsWith(returnType, Set.class.getName())
            || StringUtils.startsWith(returnType, Map.class.getName())
            || StringUtils.startsWith(returnType, Iterator.class.getName())
            || StringUtils.startsWith(returnType, Enum.class.getName())
            || StringUtils.startsWith(returnType, Collection.class.getName())) {
        while (StringUtils.contains(tmp, "<") && StringUtils.contains(tmp, ">")) {
            tmp = StringUtils.substringBetween(tmp, "<", ">");
        }
        if (StringUtils.contains(tmp, ",")) {
            // we want the first variable
            tmp = StringUtils.substringBefore(tmp, ",");
        }
    } else if (StringUtils.endsWith(returnType, "[]")) {
        tmp = StringUtils.substringBeforeLast(returnType, "[]");
    }

    this.returnType = tmp;
}