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

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

Introduction

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

Prototype

public static boolean equalsIgnoreCase(String str1, String str2) 

Source Link

Document

Compares two Strings, returning true if they are equal ignoring the case.

Usage

From source file:mitm.common.util.DomainUtils.java

/**
 * Return true if the domain is matched by the wildcard domain
 * // ww w . ja v a 2 s.  c  o m
 * Examples: 
 * - example.com is matched by *.example.com
 * - test.example.com is matched by *.example.com
 * - test.test.example.com is NOT matched by *.example.com
 */
public static boolean isWildcardMatchDomain(String domain, String wildcardDomain) {
    if (domain == null || wildcardDomain == null) {
        return false;
    }

    if (!isWildcardDomain(wildcardDomain)) {
        return false;
    }

    String validDomain = canonicalizeAndValidate(domain, DomainType.FULLY_QUALIFIED);

    if (validDomain == null) {
        return false;
    }

    String noWildcard = removeWildcard(wildcardDomain);

    if (StringUtils.equalsIgnoreCase(validDomain, noWildcard)) {
        return true;
    }

    /*
     * Check if we have a match when we remove the first part of the domain
     */
    return StringUtils.equalsIgnoreCase(getUpperLevelDomain(validDomain), noWildcard);
}

From source file:com.mmj.app.web.controller.msg.MessageController.java

@RequestMapping(value = "/message/read")
public ModelAndView readNotice(String isAll, String id) {
    if (StringUtils.isEmpty(isAll) && StringUtils.isEmpty(id)) {
        return createJsonMav("9998", ",??", 0);
    }//from w ww . j  a  v  a  2 s  .c  o m
    if (StringUtils.equalsIgnoreCase("true", isAll)) {
        List<NotificationDO> list = letterService
                .list(new NotificationQuery(WebUserTools.getUid(), UnReadEnum.UN_READ));
        for (NotificationDO notification : list) {
            letterService.update(new NotificationDO(notification.getId(), 0));
        }
        return createJsonMav("9999", "", 0);
    }

    try {
        if (id.contains(",")) {
            String[] ids = StringUtils.split(id, ",");
            for (String _id : ids) {
                Long _id_ = new Long(_id);
                if (!Argument.isNotPositive(_id_)) {
                    NotificationDO notificationById = letterService.getNotificationById(_id_);
                    if (notificationById == null) {
                        return createJsonMav("9998", ",??", 0);
                    }
                    letterService.update(new NotificationDO(_id_, 0));
                }
            }
        } else if (!Argument.isNotPositive(new Long(id))) {
            NotificationDO notificationById = letterService.getNotificationById(new Long(id));
            if (notificationById == null) {
                return createJsonMav("9998", ",??", 0);
            }
            letterService.update(new NotificationDO(new Long(id), 0));
        }
    } catch (Exception e) {
        return createJsonMav("9998", ",??", 0);
    }

    return createJsonMav("9999", "", 0);
}

From source file:AIR.Common.Web.Session.CaseInsensitiveFileNameFilter.java

public static String getFile(String directory, final String filePathSegment) {
    File f = new File(directory);
    if (f.isDirectory()) {
        String[] filesInFolder = f.list(new FilenameFilter() {
            @Override/*from  w ww.j  a v a  2s  . c  o  m*/
            public boolean accept(File dir, String name) {
                if (StringUtils.equalsIgnoreCase(name, filePathSegment))
                    return true;
                return false;
            }
        });
        // We are only expecting one match as we are doing a case insensitive
        // match.
        if (filesInFolder != null && filesInFolder.length > 0)
            return filesInFolder[0];
    }
    return filePathSegment;
}

From source file:hydrograph.ui.expression.editor.buttons.ValidateExpressionToolButton.java

/**
 * Complies the given expression using engine's jar from ELT-Project's build path. 
 * /*from   w w w  .  j a v  a2s  .  c  om*/
 * @param expressionStyledText
 * @param fieldMap
 * @param componentName
 * @return DiagnosticCollector 
 *          complete diagnosis of given expression
 * @throws JavaModelException
 * @throws InvocationTargetException
 * @throws ClassNotFoundException
 * @throws MalformedURLException
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 */
@SuppressWarnings({ "unchecked" })
public static DiagnosticCollector<JavaFileObject> compileExpresion(String expressionStyledText,
        Map<String, Class<?>> fieldMap, String componentName)
        throws JavaModelException, InvocationTargetException, ClassNotFoundException, MalformedURLException,
        IllegalAccessException, IllegalArgumentException {
    LOGGER.debug("Compiling expression using Java-Compiler");
    String expressiontext = getExpressionText(expressionStyledText);
    DiagnosticCollector<JavaFileObject> diagnostics = null;
    Object[] returObj = getBuildPathForMethodInvocation();
    List<URL> urlList = (List<URL>) returObj[0];
    String transfromJarPath = (String) returObj[1];
    String propertyFilePath = (String) returObj[2];
    URLClassLoader child = URLClassLoader.newInstance(urlList.toArray(new URL[urlList.size()]));

    Class<?> class1 = Class.forName(HYDROGRAPH_ENGINE_EXPRESSION_VALIDATION_API_CLASS, true, child);
    Thread.currentThread().setContextClassLoader(child);
    Method[] methods = class1.getDeclaredMethods();
    for (Method method : methods) {
        if (method.getParameterTypes().length == 4
                && StringUtils.equals(method.getName(),
                        COMPILE_METHOD_OF_EXPRESSION_JAR_FOR_TRANSFORM_COMPONENTS)
                && !StringUtils.equalsIgnoreCase(componentName, hydrograph.ui.common.util.Constants.FILTER)) {
            method.getDeclaringClass().getClassLoader();
            diagnostics = (DiagnosticCollector<JavaFileObject>) method.invoke(null, expressiontext,
                    propertyFilePath, fieldMap, transfromJarPath);

            break;
        } else if (method.getParameterTypes().length == 4
                && StringUtils.equals(method.getName(), COMPILE_METHOD_OF_EXPRESSION_JAR_FOR_FILTER_COMPONENT)
                && StringUtils.equalsIgnoreCase(componentName, hydrograph.ui.common.util.Constants.FILTER)) {
            method.getDeclaringClass().getClassLoader();
            diagnostics = (DiagnosticCollector<JavaFileObject>) method.invoke(null, expressiontext,
                    propertyFilePath, fieldMap, transfromJarPath);
            break;
        }

    }

    try {
        child.close();
    } catch (IOException ioException) {
        LOGGER.error("Error occurred while closing classloader", ioException);
    }
    return diagnostics;
}

From source file:com.yahoo.flowetl.commons.web.HttpPipe.java

/**
 * Makes the http output for the given input (already validated).
 * // w  w  w.ja v a 2s  .c  om
 * @param input
 * 
 * @return the http pipe result
 */
private PipeResult makeOutput(PipeResult input) {
    // services already existent
    HttpService sv = httpService;
    // extract params and/or default them
    URI uri = input.getParam(IN_URI);
    String inMethod = input.getParam(IN_METHOD);
    HttpParams p = null;
    if (StringUtils.equalsIgnoreCase(inMethod, "POST")) {
        Object addData = input.getParam(IN_POST_DATA);
        PostHttpParams tmp = new PostHttpParams();
        tmp.additionalData = addData;
        p = tmp;
    } else {
        p = new GetHttpParams();
    }
    Integer soTout = input.getParam(IN_TIMEOUT_MS);
    p.uri = uri;
    p.userAgent = input.getParam(IN_USER_AGENT);
    if (soTout != null && soTout > 0) {
        p.socketTO = soTout.intValue();
    }
    HttpResult res = sv.call(p);
    Result out = new Result();
    out.setParam(OUT_STATUS_CODE, res.statusCode);
    out.setParam(OUT_RESPONSE_BODY, res.responseBody);
    out.setParam(OUT_RESPONSE_HEADERS, res.headers);
    return out;
}

From source file:hydrograph.ui.propertywindow.ftp.FTPOperationConfigDialog.java

@Override
protected Control createDialogArea(Composite parent) {
    Composite container = (Composite) super.createDialogArea(parent);
    container.setLayout(new GridLayout(1, false));
    container.getShell().setText(windowLabel);

    if (StringUtils.equalsIgnoreCase(protocol, Constants.AWS_S3)) {
        COMPOSITE_CONST_HEIGHT = 330;//from   ww  w.  jav  a 2  s. com
    } else {
        COMPOSITE_CONST_HEIGHT = 276;
    }

    Shell shell = container.getShell();
    shell.addControlListener(new ControlAdapter() {
        @Override
        public void controlResized(ControlEvent e) {
            Rectangle rect = shell.getBounds();
            if (rect.width != COMPOSITE_CONST_HEIGHT) {
                shell.setBounds(rect.x, rect.y, rect.width, COMPOSITE_CONST_HEIGHT);
            }
        }
    });

    Composite composite = new Composite(container, SWT.BORDER);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));

    FTPWidgetUtility ftpWidgetUtility = new FTPWidgetUtility();
    Label operationLabel = (Label) ftpWidgetUtility.createLabel(composite, Messages.OPERATION);
    setPropertyHelpText(operationLabel, "Used to select the Operation");
    authenticationModeCombo = (Combo) ftpWidgetUtility.CreateCombo(composite, optionList);

    Composite composite2 = new Composite(container, SWT.NONE);
    composite2.setLayout(new GridLayout(1, false));
    composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));

    Composite stackComposite = new Composite(composite2, SWT.NONE);
    StackLayout layout = new StackLayout();
    stackComposite.setLayout(layout);
    stackComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    stackComposite.getShell().setText(Messages.OPERATION_CONFIG);
    createOperationConfigArea(stackComposite, layout);

    addModifyListener(text1);
    addModifyListener(text2);
    addModifyListener(text3);
    addModifyListener(text4);

    populateWidget();

    return container;
}

From source file:hydrograph.ui.validators.impl.TransformSchemaGridValidationRule.java

private boolean validateSchema(Schema schema, String propertyName) {
    List<GridRow> gridRowList = (List<GridRow>) schema.getGridRow();

    /*this list is used for checking duplicate names in the grid*/
    List<String> uniqueNamesList = new ArrayList<>();
    boolean fixedWidthGrid = false;
    if (gridRowList == null || gridRowList.isEmpty()) {
        errorMessage = propertyName + " is mandatory";
        return false;
    }/*www  .  ja v a  2s .c o  m*/
    GridRow gridRowTest = gridRowList.iterator().next();
    if (FixedWidthGridRow.class.isAssignableFrom(gridRowTest.getClass())) {
        fixedWidthGrid = true;
    }
    for (GridRow gridRow : gridRowList) {
        if (StringUtils.isBlank(gridRow.getFieldName())) {
            errorMessage = "Field name can not be blank";
            return false;
        }

        if (DATA_TYPE_BIG_DECIMAL.equalsIgnoreCase(gridRow.getDataTypeValue())) {
            if (StringUtils.isBlank(gridRow.getScale())
                    || !(gridRow.getScale().matches(REGULAR_EXPRESSION_FOR_NUMBER))) {
                errorMessage = "Scale should be positive integer.";
                return false;
            }
            try {
                Integer.parseInt(gridRow.getScale());
            } catch (NumberFormatException exception) {
                logger.debug("Failed to parse the scale", exception);
                errorMessage = "Scale must be integer value";
                return false;
            }
        } else if (DATA_TYPE_DATE.equalsIgnoreCase(gridRow.getDataTypeValue())
                && StringUtils.isBlank(gridRow.getDateFormat())) {
            errorMessage = "Date format is mandatory";
            return false;
        }

        if (StringUtils.equalsIgnoreCase(DATA_TYPE_BIG_DECIMAL, gridRow.getDataTypeValue())
                && (StringUtils.isBlank(gridRow.getScaleTypeValue())
                        || StringUtils.equalsIgnoreCase(SCALE_TYPE_NONE, gridRow.getScaleTypeValue()))) {
            errorMessage = "Scale type cannot be blank or none for Big Decimal data type";
            return false;
        }

        if (uniqueNamesList.isEmpty() || !uniqueNamesList.contains(gridRow.getFieldName())) {
            uniqueNamesList.add(gridRow.getFieldName());
        } else {
            errorMessage = "Schema grid must have unique names";
            return false;
        }
    }
    return true;
}

From source file:com.glaf.core.xml.XmlBuilder.java

public void processElement(String systemName, Element root, Map<String, Object> params) {
    /**//from   w  w w  .jav  a 2 s.c o m
     * ??
     */
    Map<String, DatasetModel> dataSetMap = new HashMap<String, DatasetModel>();
    List<?> elements = root.elements("DataSet");
    Iterator<?> iterator = elements.iterator();
    while (iterator.hasNext()) {
        Element element = (Element) iterator.next();
        String id = element.attributeValue("id");
        String sql = element.attributeValue("sql");
        String queryId = element.attributeValue("queryId");
        String title = element.attributeValue("title");
        String single = element.attributeValue("single");
        String splits = element.attributeValue("splits");
        String foreachPerRow = element.attributeValue("foreachPerRow");
        if (sql == null) {
            sql = element.elementText("sql");
        }

        DatasetModel dsm = new DatasetModel();
        dsm.setId(id);
        dsm.setSql(sql);
        dsm.setQueryId(queryId);
        dsm.setTitle(title);
        if (StringUtils.equalsIgnoreCase(single, "true")) {
            dsm.setSingle(true);
        }

        if (StringUtils.equalsIgnoreCase(foreachPerRow, "true")) {
            dsm.setForeachPerRow(true);
        }

        if (StringUtils.isNotEmpty(splits)) {
            dsm.setSplitList(StringTools.split(splits));
        }

        List<?> attrs = element.attributes();
        if (attrs != null && !attrs.isEmpty()) {
            Iterator<?> iter = attrs.iterator();
            while (iter.hasNext()) {
                Attribute attr = (Attribute) iter.next();
                dsm.addAttribute(attr.getName(), attr.getStringValue());
            }
        }

        List<?> providers = element.elements("FieldConverter");
        if (providers != null && !providers.isEmpty()) {
            Iterator<?> iter = providers.iterator();
            while (iter.hasNext()) {
                Element elem = (Element) iter.next();
                String fromName = elem.attributeValue("fromName");
                String toName = elem.attributeValue("toName");
                String provider = elem.attributeValue("provider");
                FieldController c = new FieldController();
                c.setFromName(fromName);
                c.setToName(toName);
                c.setProvider(provider);
                dsm.addController(c);
            }
        }
        dataSetMap.put(dsm.getId(), dsm);
    }

    elements = root.elements();
    iterator = elements.iterator();
    while (iterator.hasNext()) {
        Element element = (Element) iterator.next();
        if (StringUtils.equals(element.getName(), "DataSet")) {
            continue;
        }
        this.processNode(element, dataSetMap, systemName, params);
    }

    elements = root.elements("DataSet");
    iterator = elements.iterator();
    while (iterator.hasNext()) {
        Element element = (Element) iterator.next();
        root.remove(element);
    }
}

From source file:com.flexive.shared.search.ResultColumnInfo.java

/** {@inheritDoc} */
@Override//from  w w w  .j av  a2 s. c o  m
public boolean equals(Object o) {
    if (this == o)
        return true;
    if (o == null || getClass() != o.getClass())
        return false;

    ResultColumnInfo that = (ResultColumnInfo) o;

    return StringUtils.equalsIgnoreCase(propertyName, that.propertyName) && table.equals(that.table)
            && StringUtils.equalsIgnoreCase(suffix, that.suffix);

}

From source file:hydrograph.ui.engine.ui.converter.impl.LookupUiConverter.java

private void getPortLabels() {
    LOGGER.debug("Generating Port labels for -{}", componentName);
    if (lookup.getInSocket() != null) {
        for (TypeBaseInSocket inSocket : lookup.getInSocket()) {
            if (StringUtils.equalsIgnoreCase(inSocket.getType(), PortTypeEnum.LOOKUP.value()))
                uiComponent.getPorts().get(inSocket.getId()).setLabelOfPort(lookupLabel);
            else if (StringUtils.equalsIgnoreCase(inSocket.getType(), PortTypeEnum.DRIVER.value()))
                uiComponent.getPorts().get(inSocket.getId()).setLabelOfPort(driverLabel);
        }// w w w. jav a  2  s .com
    }
}