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

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

Introduction

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

Prototype

public static boolean contains(String str, String searchStr) 

Source Link

Document

Checks if String contains a search String, handling null.

Usage

From source file:net.itransformers.toplogyviewer.gui.neo4j.Neo4jLoader.java

public void getNeighbourVertexes(String networkNodeId) {
    String query = "start network=node(" + networkNodeId
            + ") match network-->device-->interface-->neighbor where device.objectType='Node' and neighbor.objectType='DiscoveredNeighbor' return device.name, interface.name, neighbor.name, neighbor.Reachable?, neighbor.SNMPCommunity?,neighbor.DiscoveryMethod?,neighbor.LocalIPAddress?,neighbor.NeighborIPAddress?,neighbor.NeighborHostname?,neighbor.NeighborDeviceType?";
    String params = "";
    String output = executeCypherQuery(query, params);
    JSONObject json = null;//from w w  w. ja va2s . com
    try {
        json = (JSONObject) new JSONParser().parse(output);
    } catch (ParseException e) {
        e.printStackTrace();
    }
    JSONArray data = (JSONArray) json.get("data");
    JSONArray columns = (JSONArray) json.get("columns");

    HashMap<String, HashMap<String, String>> neighborMap = new HashMap<String, HashMap<String, String>>();

    Iterator dataIter = data.iterator();
    while (dataIter.hasNext()) {
        JSONArray temp = (JSONArray) dataIter.next();
        Iterator tempIter = temp.iterator();
        Iterator columnsIter = columns.iterator();
        String neighborName = null;
        String deviceName = null;
        String interfaceName = null;
        String edgeName = null;
        //        HashMap<String, GraphMLMetadata<String>> nodeMetaData = new HashMap<String, GraphMLMetadata<String>>();
        HashMap<String, GraphMLMetadata<String>> nodePropertiesMap = new HashMap<String, GraphMLMetadata<String>>();
        HashMap<String, GraphMLMetadata<String>> graphMLPropertiesMap = new HashMap<String, GraphMLMetadata<String>>();
        while (tempIter.hasNext() & columnsIter.hasNext()) {

            String column = columnsIter.next().toString();

            String keyNodeProperty = (String) tempIter.next();

            String columnsValue = null;
            if (column.contains("neighbor.")) {
                columnsValue = StringUtils.replace(StringUtils.substringAfter(column, "neighbor."), "%20", " ");
            } else {
                columnsValue = column;
            }
            if (columnsValue.equals("device.name")) {
                deviceName = keyNodeProperty;

            } else if (columnsValue.equals("interface.name")) {
                interfaceName = keyNodeProperty;
            } else if (columnsValue.equals("name")) {

                neighborName = keyNodeProperty;
                nodePropertiesMap.put(neighborName, null);

            } else {
                if (keyNodeProperty == null) {
                    keyNodeProperty = "";
                } else if (keyNodeProperty.equals("emptyValue")) {
                    keyNodeProperty = "";
                }
                HashMap<String, String> transformerValue = new HashMap<String, String>();
                transformerValue.put(neighborName, keyNodeProperty);
                MapSettableTransformer<String, String> transfrmer = new MapSettableTransformer<String, String>(
                        transformerValue);

                GraphMLMetadata<String> t = new GraphMLMetadata<String>(null, null, transfrmer);
                nodePropertiesMap.put(columnsValue, t);

            }

        }
        String[] tempArray = { deviceName, neighborName };
        Arrays.sort(tempArray);
        StringBuilder builder = new StringBuilder();

        for (int i = 0; i < tempArray.length; i++) {
            builder.append(tempArray[i]);
        }
        edgeName = builder.toString();
        Pair<String> endpoints = new Pair<String>(deviceName, neighborName);
        //Bogon filter
        if ((neighborName != null) && !entireGraph.containsVertex(neighborName) && (neighborName != "0.0.0.0")
                && !(StringUtils.contains(neighborName, "128.") || StringUtils.contains(neighborName, "127.")
                        || StringUtils.contains(neighborName, "169.254.")
                        || StringUtils.contains(neighborName, "0."))) {
            entireGraph.addVertex(neighborName);
            vertexMetadatas.put(neighborName, nodePropertiesMap);
            graphMetadatas.put(neighborName, graphMLPropertiesMap);

        }
        if (!entireGraph.containsEdge(edgeName)) {

            entireGraph.addEdge(edgeName, endpoints);
        }

    }

}

From source file:de.snertlab.xdccBee.settings.ServerSettings.java

public IrcServer getServerByName(String hostname) {
    for (IrcServer ircServer : getListServer()) {
        if (StringUtils.contains(hostname, ircServer.getHostname())) {
            return ircServer;
        }//from  w w  w  .  j  a va  2 s . c o m
    }
    return null;
}

From source file:com.hangum.tadpole.engine.sql.util.OracleObjectCompileUtils.java

/**
 * package compile//  w  ww . jav  a2  s.  co  m
 * 
 * @param objectName
 * @param userDB
 */
public static String packageCompile(String strObjectName, UserDBDAO userDB) throws Exception {
    //TODO: RequestQuery?   ? ?.  
    ProcedureFunctionDAO packageDao = new ProcedureFunctionDAO();
    if (StringUtils.contains(strObjectName, '.')) {
        //??   ?? ...
        packageDao.setSchema_name(StringUtils.substringBefore(strObjectName, "."));
        packageDao.setPackagename(StringUtils.substringAfter(strObjectName, "."));
        packageDao.setName(StringUtils.substringAfter(strObjectName, "."));
    } else {
        //    ?    .
        packageDao.setSchema_name(userDB.getSchema());
        packageDao.setPackagename(strObjectName);
        packageDao.setName(strObjectName);
    }

    return packageCompile(packageDao, userDB, userDB.getDBDefine() == DBDefine.ORACLE_DEFAULT);
}

From source file:com.acc.storefront.controllers.misc.StoreSessionController.java

protected String getReturnRedirectUrlForUrlEncoding(final HttpServletRequest request, final String old,
        final String current) {
    final String referer = request.getHeader("Referer");
    if (referer != null && !referer.isEmpty() && StringUtils.contains(referer, "/" + old + "/")) {
        return REDIRECT_PREFIX + StringUtils.replace(referer, "/" + old + "/", "/" + current + "/");
    }//from w w  w. java2  s .c  om
    return REDIRECT_PREFIX + '/';
}

From source file:com.sfs.whichdoctor.dao.onlineapplication.BasicTrainingOnlineApplicationHandler.java

/**
 * Gets the JSP key for the next step.//from   www . j a  va2s  .  c o  m
 * An error is thrown if the user does not have the privileges to access this step.
 *
 * @param application the online application
 * @param user the user
 * @param privileges the privileges
 * @return the next step
 * @throws WhichDoctorDaoException the which doctor dao exception
 */
public final String getNextJSPKey(final OnlineApplicationBean application, final UserBean user,
        final PrivilegesBean privileges) throws WhichDoctorDaoException {

    if (user == null) {
        throw new WhichDoctorDaoException("The user cannot be null");
    }
    if (privileges == null) {
        throw new WhichDoctorDaoException("The privileges cannot be null");
    }

    String key = "";

    String status = application.getStatus();
    if (StringUtils.contains(status, " )")) {
        status = StringUtils.substringBefore(status, " (");
    }
    if (StringUtils.equalsIgnoreCase(status, "Unprocessed")) {
        if (privileges.getPrivilege(user, "people", "create")) {
            key = "PEOPLE_DATAENTRY";
        } else {
            throw new WhichDoctorDaoException("Insufficient permissions to confirm membership details");
        }
    }
    if (StringUtils.equalsIgnoreCase(status, "Confirm email address")) {
        if (privileges.getPrivilege(user, "emails", "create")) {
            key = "EMAIL_DATAENTRY";
        } else {
            throw new WhichDoctorDaoException("Insufficient permissions to confirm email details");
        }
    }
    if (StringUtils.equalsIgnoreCase(status, "Confirm address")) {
        if (privileges.getPrivilege(user, "addresses", "create")) {
            key = "ADDRESS_DATAENTRY";
        } else {
            throw new WhichDoctorDaoException("Insufficient permissions to confirm address details");
        }
    }
    if (StringUtils.containsIgnoreCase(status, " phone") || StringUtils.containsIgnoreCase(status, " fax")) {
        if (privileges.getPrivilege(user, "phones", "create")) {
            key = "PHONE_DATAENTRY";
        } else {
            throw new WhichDoctorDaoException("Insufficient permissions to confirm phone details");
        }
    }
    if (StringUtils.equalsIgnoreCase(status, "Confirm secondary qualifications")) {
        if (privileges.getPrivilege(user, "qualifications", "create")) {
            key = "QUALIFICATION_DATAENTRY";
        } else {
            throw new WhichDoctorDaoException("Insufficient permissions to confirm qualifications details");
        }
    }
    if (StringUtils.equalsIgnoreCase(status, "Confirm rotation details")) {
        if (privileges.getPrivilege(user, "rotations", "create")) {
            key = "ROTATIONS_DATAENTRY";
        } else {
            throw new WhichDoctorDaoException("Insufficient permissions to confirm rotation details");
        }
    }
    if (StringUtils.equalsIgnoreCase(status, "Issue invoice")) {
        if (privileges.getPrivilege(user, "invoices", "create")) {
            key = "DEBITS_DATAENTRY";
        } else {
            throw new WhichDoctorDaoException("Insufficient permissions to issue invoice");
        }
    }

    return key;
}

From source file:com.zb.app.web.controller.account.AccountCustomerController.java

@RequestMapping(value = "/updateUser.htm", produces = "application/json", method = RequestMethod.POST)
@ResponseBody/*w w w .j  a v  a2  s .c  o  m*/
public JsonResult updateUser(TravelMemberDO memberDO) {
    if (StringUtils.isNotEmpty(memberDO.getmPassword())) {
        memberDO.setmPassword(EncryptBuilder.getInstance().encrypt(memberDO.getmPassword()));
    }
    if (StringUtils.isNotEmpty(memberDO.getmRole()) && StringUtils.contains(memberDO.getmRole(), ",")) {
        String role = memberDO.getmRole();
        role = AuthorityHelper.makeAuthority(role);
        memberDO.setmRole(role);
    }
    boolean b = memberService.update(memberDO);
    if (b) {
        return JsonResultUtils.success(memberDO, "?!");
    } else {
        return JsonResultUtils.error(memberDO, "!");
    }
}

From source file:edu.ku.brc.util.LatLonConverter.java

/**
 * @param str//  w ww. j  ava2  s  . com
 * @param actualFmt
 * @param addSymbols
 * @param inclZeroes
 * @return
 */
public static LatLonValueInfo adjustLatLonStr(final String strArg, final FORMAT actualFmt,
        final boolean addSymbols, final boolean inclZeroes, final LATLON latOrLon) {
    if (StringUtils.isNotEmpty(strArg)) {
        String str = strArg;

        boolean redoSplit = false;
        String[] tokens = breakStringAPart(str);
        boolean startsWithMinus = str.startsWith("-");
        if (startsWithMinus) {
            str = str.substring(1);
            redoSplit = true;
        }

        if (tokens.length == 1) {
            if (latOrLon == LATLON.Latitude) {
                str += " " + northSouth[startsWithMinus ? 1 : 0];
            } else {
                str += " " + eastWest[startsWithMinus ? 1 : 0];
            }
            redoSplit = true;
        }

        if (redoSplit) {
            tokens = breakStringAPart(str);
        }

        String zero = inclZeroes ? "0" : "";
        //System.err.println("tokens[1] ["+tokens[1]+"]["+str+"]");
        boolean hasDegreesTxt = tokens[1].length() == 3 && tokens[1].equals("deg");

        LatLonValueInfo latLonInfo = new LatLonValueInfo(hasDegreesTxt);
        latLonInfo.addPart(tokens[0]);

        int toksLen = tokens.length;
        String dirStr = null;
        FORMAT fmt = null;

        if (actualFmt != null && actualFmt != FORMAT.None) {
            switch (actualFmt) {
            case DDDDDD:
                dirStr = tokens[toksLen - 1];
                break;

            case DDMMMM:

                if (toksLen == 3) {
                    latLonInfo.addPart(tokens[1]);
                    dirStr = tokens[2];
                } else {
                    latLonInfo.addPart(zero);
                    dirStr = tokens[1];
                }

                break;

            case DDMMSS:
                if (toksLen == 4) {
                    latLonInfo.addPart(tokens[1]);
                    latLonInfo.addPart(tokens[2]);
                    dirStr = tokens[3];

                } else if (toksLen == 3) {
                    String tok1 = tokens[1];
                    if (StringUtils.contains(tok1, formatSymbols.getDecimalSeparator())) {
                        String[] tks = StringUtils.split(tok1, formatSymbols.getDecimalSeparator());
                        latLonInfo.addPart(tks[0]);
                        latLonInfo.addPart(tks[1]);

                    } else {
                        latLonInfo.addPart(tok1);
                        latLonInfo.addPart(zero);
                    }
                    dirStr = tokens[2];

                } else if (toksLen == 2) {
                    latLonInfo.addPart(zero);
                    latLonInfo.addPart(zero);
                    dirStr = tokens[1];
                }
                break;

            default:
                break;
            } // switch 
            fmt = actualFmt;

        } else {
            switch (toksLen) {
            case 2: {
                dirStr = tokens[1];
                fmt = FORMAT.DDDDDD;
                break;
            }

            case 3: {
                if (hasDegreesTxt) {
                    fmt = FORMAT.DDDDDD;
                } else {
                    latLonInfo.addPart(tokens[1]);
                    fmt = FORMAT.DDMMMM;
                }
                dirStr = tokens[2];
                break;
            }

            case 4: {
                if (hasDegreesTxt) {
                    fmt = FORMAT.DDMMMM;
                } else {
                    latLonInfo.addPart(tokens[1]);
                    fmt = FORMAT.DDMMSS;
                }
                latLonInfo.addPart(tokens[2]);
                dirStr = tokens[3];

                break;
            }

            case 5:
                latLonInfo.addPart(tokens[2]);
                latLonInfo.addPart(tokens[3]);
                dirStr = tokens[4];
                fmt = FORMAT.DDMMSS;
                break;

            default:
                break;

            } // switch
        } // if
        latLonInfo.addPart(dirStr);
        latLonInfo.setFormat(fmt);
        latLonInfo.setDirStr(dirStr);
        return latLonInfo;

    }
    return null;
}

From source file:com.groupon.jenkins.dynamic.build.DynamicProject.java

private boolean useNewUi(final String token, final StaplerRequest req) {
    return isNewUi() && (StringUtils.startsWith(token, "dotCI") || //job pages
            (NumberUtils.isNumber(token) && (StringUtils.isEmpty(req.getRestOfPath())
                    || StringUtils.contains(req.getRestOfPath(), "dotCI")))); // buildpages
}

From source file:info.magnolia.module.admininterface.SaveHandlerImpl.java

/**
 * This method cears about one mgnlSaveInfo. It adds the value to the node
 * @param node node to add data/*from ww w .j av a 2s .  c  o m*/
 * @param saveInfo <code>name, type, valueType, isRichEditValue, encoding</code>
 * @throws PathNotFoundException exception
 * @throws RepositoryException exception
 * @throws AccessDeniedException no access
 */
protected void processSaveInfo(Content node, String saveInfo)
        throws PathNotFoundException, RepositoryException, AccessDeniedException {

    String name;
    int type = PropertyType.STRING;
    int valueType = ControlImpl.VALUETYPE_SINGLE;
    int isRichEditValue = 0;
    int encoding = ControlImpl.ENCODING_NO;
    String[] values = { StringUtils.EMPTY };
    if (StringUtils.contains(saveInfo, ',')) {
        String[] info = StringUtils.split(saveInfo, ',');
        name = info[0];
        if (info.length >= 2) {
            type = PropertyType.valueFromName(info[1]);
        }
        if (info.length >= 3) {
            valueType = Integer.valueOf(info[2]).intValue();
        }
        if (info.length >= 4) {
            isRichEditValue = Integer.valueOf(info[3]).intValue();
        }
        if (info.length >= 5) {
            encoding = Integer.valueOf(info[4]).intValue();
        }
    } else {
        name = saveInfo;
    }

    if (type == PropertyType.BINARY) {
        processBinary(node, name);
    } else {
        values = getForm().getParameterValues(name);
        if (valueType == ControlImpl.VALUETYPE_MULTIPLE) {
            processMultiple(node, name, type, values);
        } else if (isRichEditValue != ControlImpl.RICHEDIT_NONE) {
            processRichEdit(node, name, type, isRichEditValue, encoding, values);
        } else if (type == PropertyType.DATE) {
            processDate(node, name, type, valueType, encoding, values);
        } else {
            processCommon(node, name, type, valueType, encoding, values);
        }
    }
}

From source file:edu.ku.brc.specify.config.LatLonConverter.java

/**
 * @param str//from w w  w  .  j  a  va 2s .  c  o  m
 * @param actualFmt
 * @param addSymbols
 * @param inclZeroes
 * @return
 */
public static LatLonValueInfo adjustLatLonStr(final String strArg, final FORMAT actualFmt,
        final boolean addSymbols, final boolean inclZeroes, final LATLON latOrLon) {
    if (StringUtils.isNotEmpty(strArg)) {
        String str = strArg;

        boolean redoSplit = false;
        String[] tokens = breakStringAPart(str);
        boolean startsWithMinus = str.startsWith("-");
        if (startsWithMinus) {
            str = str.substring(1);
            redoSplit = true;
        }

        if (tokens.length == 1) {
            if (latOrLon == LATLON.Latitude) {
                str += " " + northSouth[startsWithMinus ? 1 : 0];
            } else {
                str += " " + eastWest[startsWithMinus ? 1 : 0];
            }
            redoSplit = true;
        }

        if (redoSplit) {
            tokens = breakStringAPart(str);
        }

        String zero = inclZeroes ? "0" : "";
        //System.err.println("tokens[1] ["+tokens[1]+"]["+str+"]");
        boolean hasDegreesTxt = tokens[1].length() == 3 && tokens[1].equals("deg");

        LatLonValueInfo latLonInfo = new LatLonValueInfo(hasDegreesTxt);
        latLonInfo.addPart(tokens[0]);

        int toksLen = tokens.length;
        String dirStr = null;
        FORMAT fmt = null;

        if (actualFmt != null && actualFmt != FORMAT.None) {
            switch (actualFmt) {
            case DDDDDD:
                dirStr = tokens[toksLen - 1];
                break;

            case DDMMMM:

                if (toksLen == 3) {
                    latLonInfo.addPart(tokens[1]);
                    dirStr = tokens[2];
                } else {
                    latLonInfo.addPart(zero);
                    dirStr = tokens[1];
                }

                break;

            case DDMMSS:
                if (toksLen == 4) {
                    latLonInfo.addPart(tokens[1]);
                    latLonInfo.addPart(tokens[2]);
                    dirStr = tokens[3];

                } else if (toksLen == 3) {
                    String tok1 = tokens[1];
                    if (StringUtils.contains(tok1, formatSymbols.getDecimalSeparator())) {
                        String[] tks = StringUtils.split(tok1, formatSymbols.getDecimalSeparator());
                        latLonInfo.addPart(tks[0]);
                        latLonInfo.addPart(tks[1]);

                    } else {
                        latLonInfo.addPart(tok1);
                        latLonInfo.addPart(zero);
                    }
                    dirStr = tokens[2];

                } else if (toksLen == 2) {
                    latLonInfo.addPart(zero);
                    latLonInfo.addPart(zero);
                    dirStr = tokens[1];
                }
                break;

            default:
                break;
            } // switch
            fmt = actualFmt;

        } else {
            switch (toksLen) {
            case 2: {
                dirStr = tokens[1];
                fmt = FORMAT.DDDDDD;
                break;
            }

            case 3: {
                if (hasDegreesTxt) {
                    fmt = FORMAT.DDDDDD;
                } else {
                    latLonInfo.addPart(tokens[1]);
                    fmt = FORMAT.DDMMMM;
                }
                dirStr = tokens[2];
                break;
            }

            case 4: {
                if (hasDegreesTxt) {
                    fmt = FORMAT.DDMMMM;
                } else {
                    latLonInfo.addPart(tokens[1]);
                    fmt = FORMAT.DDMMSS;
                }
                latLonInfo.addPart(tokens[2]);
                dirStr = tokens[3];

                break;
            }

            case 5:
                latLonInfo.addPart(tokens[2]);
                latLonInfo.addPart(tokens[3]);
                dirStr = tokens[4];
                fmt = FORMAT.DDMMSS;
                break;

            default:
                break;

            } // switch
        } // if
        latLonInfo.addPart(dirStr);
        latLonInfo.setFormat(fmt);
        latLonInfo.setDirStr(dirStr);
        return latLonInfo;

    }
    return null;
}