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

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

Introduction

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

Prototype

public static boolean startsWithIgnoreCase(String str, String prefix) 

Source Link

Document

Case insensitive check if a String starts with a specified prefix.

Usage

From source file:bammerbom.ultimatecore.spongeapi.UltimateCommands.java

@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
    if (Overrider.checkOverridden(sender, cmd, label, args)) {
        return null;
    }//w w  w.j  a v a2  s  . c om
    List<String> rtrn = null;
    if (label.startsWith("ultimatecore:")) {
        label = label.replaceFirst("ultimatecore:", "");
    }
    for (UltimateCommand cmdr : cmds) {
        if (cmdr.getName().equals(label) || cmdr.getAliases().contains(label)) {
            try {
                rtrn = cmdr.onTabComplete(sender, cmd, label, args, args[args.length - 1], args.length - 1);
            } catch (Exception ex) {
                ErrorLogger.log(ex, "Failed tabcompleting for " + label);
            }
            break;
        }
    }
    if (rtrn == null) {
        rtrn = new ArrayList<>();
        for (Player p : r.getOnlinePlayers()) {
            rtrn.add(p.getName());
        }
    }
    if (!StringUtil.nullOrEmpty(args[args.length - 1])) {
        List<String> remv = new ArrayList<>();
        for (String s : rtrn) {
            if (!StringUtils.startsWithIgnoreCase(s, args[args.length - 1])) {
                remv.add(s);
            }
        }
        rtrn.removeAll(remv);
    }
    return rtrn;
}

From source file:com.sfs.whichdoctor.beans.AddressBean.java

/**
 * Checks if the address has been verified.
 *
 * @return true, if the address is verified
 */// www . java  2  s.co m
public final boolean isVerified() {
    boolean verified = false;

    if (StringUtils.startsWithIgnoreCase(this.getVerificationStatus(), "Verified")) {
        verified = true;
    }
    return verified;
}

From source file:com.activecq.samples.replication.impl.ReverseReplicatorImpl.java

public boolean process(Event event) {
    if (!enabled) {
        return false;
    }/*from www.  j av  a2  s  .c  o m*/

    ResourceResolver adminResourceResolver = null;
    try {
        adminResourceResolver = resourceResolverFactory.getAdministrativeResourceResolver(null);

        final String resourcePath = (String) event.getProperty("path");

        for (final String path : paths) {
            if (StringUtils.startsWithIgnoreCase(resourcePath, path)) {
                log.debug("Processing Reverse Replication Event for: " + resourcePath);

                Resource resource = adminResourceResolver.resolve(resourcePath);
                if (resource == null) {
                    continue;
                }

                log.debug("Primary Type: " + hasValidPrimaryType(resource));
                log.debug("Property: " + hasValidProperty(resource));
                log.debug("Whitelist: " + isWhitelisted(resource));
                log.debug("Not Blacklist: " + !isBlacklisted(resource));
                log.debug("Event: " + event.getTopic());
                log.debug("is Delete: " + isDeleteEvent(event));

                if (!isDeleteEvent(event)) {
                    if (!hasValidPrimaryType(resource) || !hasValidProperty(resource)) {
                        continue;
                    }
                }
                if (!isWhitelisted(resource) || isBlacklisted(resource)) {
                    continue;
                }
                if (!shouldReplicate(resource, event)) {
                    continue;
                }

                try {
                    replicate(resource, event);
                    log.debug("*** REPLICATION KICKED OFF ***");
                    break;
                } catch (ReplicationException ex) {
                    log.debug("*** REPLICATION FAILED ***");
                    log.debug(ex.getMessage());
                }
            }
        }
    } catch (Exception ex) {
        log.debug("*** REPLICATION FAILED : REPOSITORY EXCEPTION GETTING ADMIN RESOURCE RESOLVER ***");
        log.debug(ex.getMessage());
    } finally {
        if (adminResourceResolver != null) {
            adminResourceResolver.close();
        }
    }

    return true;
}

From source file:hydrograph.ui.menus.importWizards.ImportEngineXmlWizardPage.java

public IFile createNewFile() {
    LOGGER.debug("Creating new files");
    UiConverterUtil uiConverterUtil = new UiConverterUtil();
    IFile jobFile = ResourcesPlugin.getWorkspace().getRoot().getFile(jobFilePath);
    IFile parameterFile = ResourcesPlugin.getWorkspace().getRoot().getFile(parameterFilePath);
    Object[] containerArray = null;
    try {//  w w w  . j a v  a  2 s. c om
        containerArray = uiConverterUtil.convertToUiXml(new File(targetxmlFilePath), jobFile, parameterFile,
                false);
        LOGGER.debug("Successfully created *job,*properties files in workspace");
    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException
            | InvocationTargetException | NoSuchMethodException | SecurityException | EngineException
            | IOException | ComponentNotFoundException exception) {

        LOGGER.error("Error occurred while creating new files in workspace", exception);
        showMessageBox(exception.getMessage(), Messages.EXCEPTION_OCCURED);
        return null;
    } catch (JAXBException | ParserConfigurationException | SAXException exception) {
        LOGGER.error("Error occurred while creating new files in workspace", exception);
        if (StringUtils.startsWithIgnoreCase(exception.getMessage(), "DOCTYPE is disallowed")) {
            showMessageBox(null, Messages.EXTERNAL_DTD_NOT_ALLOWED);
        } else {
            showMessageBox(exception.getMessage(), Messages.INVALID_TARGET_FILE_ERROR);
        }
        return null;
    }
    LOGGER.debug("Importing *xml file");
    ImportedJobsRepository.INSTANCE.flush();
    if (containerArray[1] == null) {
        return super.createNewFile();
    }
    return (IFile) containerArray[1];
}

From source file:bammerbom.ultimatecore.bukkit.UltimateCommands.java

@Override
public List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) {
    if (Overrider.checkOverridden(sender, cmd, label, args)) {
        return null;
    }//w w w.j  a  v a  2s  .  com
    List<String> rtrn = null;
    if (label.startsWith("ultimatecore:")) {
        label = label.replaceFirst("ultimatecore:", "");
    }
    for (UltimateCommand cmdr : cmds) {
        if (cmdr.getName().equals(label) || cmdr.getAliases().contains(label)) {
            try {
                rtrn = cmdr.onTabComplete(sender, cmd, label, args, args[args.length - 1], args.length - 1);
            } catch (Exception ex) {
                ErrorLogger.log(ex, "Failed tabcompleting for " + label);
            }
            break;
        }
    }
    if (rtrn == null) {
        rtrn = new ArrayList<>();
        for (Player p : r.getOnlinePlayers()) {
            rtrn.add(p.getName());
        }
    }
    ArrayList<String> rtrn2 = new ArrayList<>();
    rtrn2.addAll(rtrn);
    rtrn = rtrn2;
    if (!StringUtil.nullOrEmpty(args[args.length - 1])) {
        List<String> remv = new ArrayList<>();
        for (String s : rtrn) {
            if (!StringUtils.startsWithIgnoreCase(s, args[args.length - 1])) {
                remv.add(s);
            }
        }
        rtrn.removeAll(remv);
    }
    return rtrn;
}

From source file:jp.primecloud.auto.process.ComponentProcess.java

protected ComponentProcessContext createContext(Long farmNo) {
    ComponentProcessContext context = new ComponentProcessContext();
    context.setFarmNo(farmNo);/*from   ww w .  j a  va  2s  .  com*/

    // ????
    List<Instance> instances = instanceDao.readByFarmNo(farmNo);
    List<Long> runningInstanceNos = new ArrayList<Long>();
    for (Instance instance : instances) {
        // ?????????
        if (InstanceStatus.fromStatus(instance.getStatus()) != InstanceStatus.RUNNING) {
            continue;
        }

        // ????
        if (BooleanUtils.isTrue(instance.getLoadBalancer())) {
            continue;
        }

        // PuppetInstance????  ???OS?windows????
        PuppetInstance puppetInstance = puppetInstanceDao.read(instance.getInstanceNo());
        Image image = imageDao.read(instance.getImageNo());
        if (puppetInstance == null
                && !StringUtils.startsWithIgnoreCase(image.getOs(), PCCConstant.OS_NAME_WIN)) {
            continue;
        }

        runningInstanceNos.add(instance.getInstanceNo());
    }
    context.setRunningInstanceNos(runningInstanceNos);

    // ?????
    List<ComponentInstance> componentInstances = componentInstanceDao.readInInstanceNos(runningInstanceNos);
    Map<Long, List<Long>> enableInstanceNoMap = new HashMap<Long, List<Long>>();
    Map<Long, List<Long>> disableInstanceNoMap = new HashMap<Long, List<Long>>();
    for (ComponentInstance componentInstance : componentInstances) {
        Map<Long, List<Long>> map;
        if (BooleanUtils.isTrue(componentInstance.getEnabled())) {
            map = enableInstanceNoMap;
        } else {
            map = disableInstanceNoMap;
        }

        List<Long> list = map.get(componentInstance.getComponentNo());
        if (list == null) {
            list = new ArrayList<Long>();
            map.put(componentInstance.getComponentNo(), list);
        }
        list.add(componentInstance.getInstanceNo());
    }
    context.setEnableInstanceNoMap(enableInstanceNoMap);
    context.setDisableInstanceNoMap(disableInstanceNoMap);

    // ????
    List<LoadBalancer> loadBalancers = loadBalancerDao.readByFarmNo(farmNo);
    List<Long> loadBalancerNos = new ArrayList<Long>();
    for (LoadBalancer loadBalancer : loadBalancers) {
        LoadBalancerStatus status = LoadBalancerStatus.fromStatus(loadBalancer.getStatus());

        if (BooleanUtils.isTrue(loadBalancer.getEnabled())) {
            // ?????????
            if (status != LoadBalancerStatus.RUNNING) {
                continue;
            }
        } else {
            // ????????????
            if (status != LoadBalancerStatus.RUNNING && status != LoadBalancerStatus.WARNING) {
                continue;
            }
        }

        loadBalancerNos.add(loadBalancer.getLoadBalancerNo());
    }
    context.setTargetLoadBalancerNos(loadBalancerNos);

    return context;
}

From source file:com.hangum.tadpole.rdb.core.dialog.db.UpdateDeleteConfirmDialog.java

/**
 * table? Column? ?./* www .ja  v  a2  s  . c  o  m*/
 */
public static void createTableColumn(final RequestQuery reqQuery, final TableViewer tableViewer,
        final ResultSetUtilDTO rsDAO, final boolean isEditable) {
    //  column? .
    Table table = tableViewer.getTable();
    int columnCount = table.getColumnCount();
    for (int i = 0; i < columnCount; i++) {
        table.getColumn(0).dispose();
    }

    if (rsDAO.getColumnName() == null)
        return;

    try {
        for (int i = 0; i < rsDAO.getColumnName().size(); i++) {
            final int columnAlign = RDBTypeToJavaTypeUtils.isNumberType(rsDAO.getColumnType().get(i))
                    ? SWT.RIGHT
                    : SWT.LEFT;
            String strColumnName = rsDAO.getColumnLabelName().get(i);

            /**  ? ? ?   */
            if (StringUtils.startsWithIgnoreCase(strColumnName,
                    PublicTadpoleDefine.SPECIAL_USER_DEFINE_HIDE_COLUMN))
                continue;

            final TableViewerColumn tv = new TableViewerColumn(tableViewer, columnAlign);
            final TableColumn tc = tv.getColumn();

            tc.setText(strColumnName);
            tc.setResizable(true);
            tc.setMoveable(true);
        } // end for

    } catch (Exception e) {
        logger.error("SQLResult TableViewer", e);
    }
}

From source file:adalid.commons.util.FilUtils.java

public static FileFilter nameStartsWithFilter(final String prefix) {
    return new FileFilter() {

        @Override/*  www. j  a  v  a2  s.  c om*/
        public boolean accept(File file) {
            return isVisibleFile(file) && StringUtils.startsWithIgnoreCase(file.getName(), prefix);
        }

    };
}

From source file:adalid.commons.util.ObjUtils.java

public static Boolean startsWith(Object x, Object y) {
    if (x == null || y == null) {
        return false;
    } else if (x instanceof String) {
        return y instanceof String ? StringUtils.startsWithIgnoreCase(((String) x), ((String) y))
                : StringUtils.startsWithIgnoreCase(((String) x), toString(y));
    }/*from ww w  .j  a va  2s  .c o  m*/
    return startsWith(toString(x), y);
}

From source file:com.microsoft.alm.plugin.external.commands.Command.java

protected String[] getLines(final String buffer, final boolean skipWarnings) {
    final List<String> lines = new ArrayList<String>(Arrays.asList(buffer.replace("\r\n", "\n").split("\n")));
    if (skipWarnings) {
        while (lines.size() > 0 && StringUtils.startsWithIgnoreCase(lines.get(0), WARNING_PREFIX)) {
            lines.remove(0);//from  w  ww  .  j  ava 2  s. c om
        }
    }
    return lines.toArray(new String[lines.size()]);
}