Example usage for org.apache.commons.lang3 StringUtils equals

List of usage examples for org.apache.commons.lang3 StringUtils equals

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils equals.

Prototype

public static boolean equals(final CharSequence cs1, final CharSequence cs2) 

Source Link

Document

Compares two CharSequences, returning true if they represent equal sequences of characters.

null s are handled without exceptions.

Usage

From source file:com.google.dart.engine.services.internal.refactoring.RenameAngularHasAttributeSelectorRefactoringImpl.java

/**
 * If the given {@link AngularPropertyElement} is a property of an {@link AngularDecoratorElement}
 * then returns the {@link AngularHasAttributeSelectorElement} with the same name as the
 * {@link AngularPropertyElement}, or {@code null}.
 *///from w w w .j a v  a 2  s. com
public static AngularHasAttributeSelectorElement getAttributeSelectorElement(AngularPropertyElement property) {
    Element enclosing = property.getEnclosingElement();
    if (enclosing instanceof AngularDecoratorElement) {
        AngularDecoratorElement directive = (AngularDecoratorElement) enclosing;
        AngularSelectorElement selector = directive.getSelector();
        if (selector instanceof AngularHasAttributeSelectorElement) {
            AngularHasAttributeSelectorElement attributeSelector = (AngularHasAttributeSelectorElement) selector;
            if (StringUtils.equals(property.getName(), attributeSelector.getName())) {
                return attributeSelector;
            }
        }
    }
    return null;
}

From source file:com.hybris.mobile.app.commerce.barcode.CommerceBarcodeCheckerFactory.java

/**
 * Return the product value if the barcode value matches one of the pre-configured regular expression
 *
 * @param barcodeValue/*from w  ww  .  j  a v  a2  s  .  co  m*/
 * @param barcodeSymbology
 * @return
 */
private static String getProductCode(String barcodeValue, String barcodeSymbology) {

    // For product codes, we have to remove the leading/trailing 0 of specific barcode symbologies

    // These barcodes have leading '0's and a trailing '0' that needs to be accounted for (stripped out).
    if (StringUtils.equals(barcodeSymbology, Constants.BarCodeSymbology.EAN_13.getCodeSymbology())) {
        barcodeValue = StringUtils.stripStart(barcodeValue, "0");
        barcodeValue = StringUtils.removeEnd(barcodeValue, "0");
    }
    // These barcodes have leading '0's that needs to be accounted for (stripped out).
    else if (StringUtils.equals(barcodeSymbology, Constants.BarCodeSymbology.ITF.getCodeSymbology())) {
        barcodeValue = StringUtils.stripStart(barcodeValue, "0");
    }
    // These barcodes have a trailing '0' that needs to be accounted for (stripped out).
    else if (StringUtils.equals(barcodeSymbology, Constants.BarCodeSymbology.EAN_8.getCodeSymbology())) {
        barcodeValue = StringUtils.removeEnd(barcodeValue, "0");
    }

    // Trying to get a product code from the barcode value
    return RegexUtils.getProductCode(barcodeValue);

}

From source file:com.glaf.mail.config.JavaMailSenderConfiguration.java

@Bean(name = "javaMailSender")
public JavaMailSenderImpl buildJavaMailSender() {
    MailConfig cfg = new MailConfig();
    String filename = SystemProperties.getConfigRootPath() + Constants.MAIL_CONFIG;
    Properties properties = PropertiesUtils.loadFilePathResource(filename);
    cfg.setEncoding(properties.getProperty("mail.defaultEncoding", "GBK"));
    cfg.setHost(properties.getProperty("mail.host", "127.0.0.1"));
    cfg.setUsername(properties.getProperty("mail.username"));
    cfg.setPassword(properties.getProperty("mail.password"));
    if (StringUtils.equals(properties.getProperty("mail.auth"), "true")) {
        cfg.setAuth(true);//from www . j  ava2 s.  co m
    }

    int port = JavaMailSenderImpl.DEFAULT_PORT;
    if (properties.getProperty("mail.port") != null) {
        port = Integer.parseInt(properties.getProperty("mail.port"));
    }

    JavaMailSenderImpl sender = new JavaMailSenderImpl();
    sender.setJavaMailProperties(properties);
    sender.setHost(properties.getProperty("mail.host"));
    sender.setPort(port);
    sender.setProtocol(JavaMailSenderImpl.DEFAULT_PROTOCOL);
    sender.setUsername(properties.getProperty("mail.username"));
    sender.setPassword(properties.getProperty("mail.password"));
    sender.setDefaultEncoding(properties.getProperty("mail.defaultEncoding", "GBK"));

    return sender;
}

From source file:io.manasobi.security.UserDetailsController.java

@RequestMapping(value = "/reg/user", method = RequestMethod.POST)
public String register(String username, String password, String confirmPwd, Model model) {

    String viewName = "register";

    if (!StringUtils.equals(password, confirmPwd)) {

        model.addAttribute("PWD_ERROR_MSG", Result.ERROR_101002.getMessage());

    } else {//from   w ww  .j  a  v a2s . com

        List<GrantedAuthority> roles = Lists.newArrayList();
        roles.add(new SimpleGrantedAuthority("USER"));

        Client client = new Client();

        client.setUsername(username);
        client.setPassword(passwordEncoder.encode(password));
        client.setRoles(roles);

        Result result = userDetailsService.register(client);

        if (result == Result.ERROR_101001) {
            model.addAttribute("USERNAME_ERROR_MSG", result.getMessage());
        } else {
            viewName = "main";
        }
    }

    return viewName;
}

From source file:de.micromata.genome.gwiki.page.search.expr.SearchExpressionIndexerCallback.java

@Override
public void call() {
    try {//from   w  w  w. j a v a  2 s  . c o  m
        GLog.note(GWikiLogCategory.Wiki, "Start build full text index");
        String pageId = args.get("pageId");
        boolean full = false;
        if (StringUtils.equals(args.get("full"), "true") == true) {
            full = true;
        }
        if (StringUtils.isNotEmpty(pageId) == true) {
            List<GWikiElementInfo> eil = new ArrayList<GWikiElementInfo>();
            GWikiElementInfo ei = wikiContext.getWikiWeb().findElementInfo(pageId);
            if (ei != null) {
                eil.add(ei);
            }
            rebuildIndex(wikiContext, eil, full);
        } else {
            rebuildIndex(wikiContext, wikiContext.getWikiWeb().getElementInfos(), full);
        }
        GLog.note(GWikiLogCategory.Wiki, "Finished build full text index");
    } catch (Exception ex) {
        GWikiLog.warn("Job failed: " + SearchExpressionIndexerCallback.class.getName() + "; " + ex.getMessage(),
                ex);

    }
}

From source file:com.bazaarvoice.jolt.SortrTest.java

private static String verifyMapOrder(Map<String, Object> actual, Map<String, Object> expected) {

    Iterator<String> actualIter = actual.keySet().iterator();
    Iterator<String> expectedIter = expected.keySet().iterator();

    for (int index = 0; index < actual.size(); index++) {
        String actualKey = actualIter.next();
        String expectedKey = expectedIter.next();

        if (!StringUtils.equals(actualKey, expectedKey)) {
            return "Found out of order keys '" + actualKey + "' and '" + expectedKey + "'";
        }/*from  w ww .j  a  v a2  s. c o m*/

        String result = verifyOrder(actual.get(actualKey), expected.get(expectedKey));
        if (result != null) {
            return result;
        }
    }

    return null; // success
}

From source file:com.inkubator.hrm.batch.PayTempOvertimeUploadReader.java

public PayTempOvertimeUploadReader(String filePath) {

    this.extension = StringUtils.substringAfterLast(filePath, ".");
    this.pathUpload = filePath;

    if (StringUtils.equals(this.extension, "csv")) {
        this.initializationCsvReader(filePath);
    } else {/*from ww w .ja  va 2 s.  c om*/
        this.initializationExcelReader(filePath);
    }
}

From source file:de.micromata.genome.gwiki.page.impl.wiki.macros.GWikiHTMLcommentMacro.java

@Override
public boolean render(MacroAttributes attrs, GWikiContext ctx) {
    boolean hidden = StringUtils.equals(attrs.getDefaultValue(), "hidden");
    if (hidden == true) {
        return true;
    }/*from w ww  .  j a  v a 2  s. c om*/
    ctx.append("<!-- ");
    ctx.append(attrs.getBody());
    ctx.append("--!>");
    return true;
}

From source file:de.micromata.genome.gwiki.plugin.rogmp3_1_0.Composer.java

public String getDetailDescription() {
    StringBuilder sb = new StringBuilder();
    String born = get(BORN);//from  w ww.ja v a 2s .co  m
    if (StringUtils.equals(born, "0") == false) {
        sb.append("Life: ").append(esc(born)).append("-").append(get(DIED)).append("<br/>");
    }
    String country = get(COUNTRY);
    if (StringUtils.isNotBlank(country) == true) {
        sb.append("Land: ").append(esc(country)).append("<br/>");
    }
    // sb.append(esc(getName()));
    // String born = get(BORN);
    // if (StringUtils.equals(born, "0") == false) {
    // sb.append(" (").append(esc(born)).append("-").append(get(DIED)).append(")");
    // }

    return sb.toString();
}

From source file:ch.cyberduck.core.b2.B2FindFeature.java

@Override
public boolean find(final Path file) throws BackgroundException {
    try {/*from   w w w  .  j  av a2 s. co  m*/
        if (containerService.isContainer(file)) {
            final List<B2BucketResponse> buckets = session.getClient().listBuckets();
            for (B2BucketResponse bucket : buckets) {
                if (StringUtils.equals(containerService.getContainer(file).getName(), bucket.getBucketName())) {
                    return true;
                }
            }
        } else {
            try {
                return null != new B2FileidProvider(session).withCache(cache).getFileid(file,
                        new DisabledListProgressListener());
            } catch (NotfoundException e) {
                return false;
            }
        }
        return false;
    } catch (B2ApiException e) {
        throw new B2ExceptionMappingService().map(e);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map(e);
    }
}