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

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

Introduction

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

Prototype

public static String[] split(String str, String separatorChars) 

Source Link

Document

Splits the provided text into an array, separators specified.

Usage

From source file:com.croer.javaaccess.Structure.java

public Structure(Object object) {
    Properties properties = new Properties();
    try {//from  www .  j a v a2s . c  o m
        String fileProps = System.getProperty("user.dir") + "\\target\\classes\\entityStruc.properties";
        FileInputStream input = new FileInputStream(fileProps);
        properties.load(input);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(Structure.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(Structure.class.getName()).log(Level.SEVERE, null, ex);
    }

    String type = object.getClass().getName();
    String key = properties.getProperty(type + ".key");
    String context = properties.getProperty(type + ".context");

    if (key == null || context == null) {
        throw new IllegalArgumentException(
                "Properties missing for type: " + type + " key " + key + " context " + context);
    }

    keyList = Arrays.asList(StringUtils.split(key, "|"));
    contextList = Arrays.asList(StringUtils.split(context, "|"));
}

From source file:name.richardson.james.bukkit.utilities.command.argument.AbstractArgument.java

protected final String[] getSeparatedValues(final String argument) {
    return StringUtils.split(argument, ",");
}

From source file:com.parasoft.xtest.reports.jenkins.ParasoftDetailBuilder.java

@Override
public Object createDetails(String link, AbstractBuild<?, ?> owner, AnnotationContainer container,
        String defaultEncoding, String displayName) {
    if (link.startsWith("link.")) { //$NON-NLS-1$
        String suffix = StringUtils.substringAfter(link, "link."); //$NON-NLS-1$
        String[] fromToStrings = StringUtils.split(suffix, "."); //$NON-NLS-1$
        if (fromToStrings.length == 2) {
            return createParasoftSourceDetail(owner, container, defaultEncoding, fromToStrings[0],
                    fromToStrings[1]);/*from  w  ww  .  j a  v  a2 s  . co m*/
        }
        return null;
    }
    if (link.startsWith("doc.")) { //$NON-NLS-1$
        String sAnalzerRuleId = StringUtils.substringAfter(link, "doc."); //$NON-NLS-1$
        String[] splitted = sAnalzerRuleId.split("\\|"); //$NON-NLS-1$
        if (splitted.length != 2) {
            Logger.getLogger().warn("Wrong url with analyzer and ruleId, cannot parse: " + sAnalzerRuleId); //$NON-NLS-1$
            return null;
        }
        return new RuleDocumentation(owner, splitted[0], splitted[1]);
    }
    return super.createDetails(link, owner, container, defaultEncoding, displayName);
}

From source file:com.netflix.lipstick.adaptors.LOStoreJsonAdaptor.java

/**
 * Initializes a new LOStoreJsonAdaptor and additionally sets the storage
 * function and location on the P2jLOStore object being created.
 *
 * @param node the LOStore object to convert to P2jLOStore
 * @param lp the logical plan containing node
 * @throws FrontendException// ww  w .  j a  va  2s. c  o  m
 */
public LOStoreJsonAdaptor(LOStore node, LogicalPlan lp) throws FrontendException {
    super(node, new P2jLOStore(), lp);
    P2jLOStore store = (P2jLOStore) p2j;
    store.setStorageLocation(node.getFileSpec().getFileName());
    String[] funcList = StringUtils.split(node.getFileSpec().getFuncName(), ".");
    store.setStorageFunction(funcList[funcList.length - 1]);
}

From source file:com.tesora.dve.sql.schema.QualifiedName.java

public QualifiedName(String name) {
    this(StringUtils.split(name, PART_SEPARATOR));
}

From source file:com.twitter.distributedlog.metadata.ZkMetadataResolver.java

@Override
public DLMetadata resolve(URI uri) throws IOException {
    String dlPath = uri.getPath();
    PathUtils.validatePath(dlPath);/* www.j ava2s.  c  o m*/
    // Normal case the dl metadata is stored in the last segment
    // so lookup last segment first.
    String[] parts = StringUtils.split(dlPath, '/');
    if (null == parts || 0 == parts.length) {
        throw new IOException("Invalid dlPath to resolve dl metadata : " + dlPath);
    }
    for (int i = parts.length; i >= 0; i--) {
        String pathToResolve = String.format("/%s", StringUtils.join(parts, '/', 0, i));
        byte[] data;
        try {
            data = zkc.get().getData(pathToResolve, false, new Stat());
        } catch (KeeperException.NoNodeException nne) {
            continue;
        } catch (KeeperException ke) {
            throw new IOException("Fail to resolve dl path : " + pathToResolve);
        } catch (InterruptedException ie) {
            throw new IOException("Interrupted when resolving dl path : " + pathToResolve);
        }
        if (null == data || data.length == 0) {
            continue;
        }
        try {
            return DLMetadata.deserialize(uri, data);
        } catch (IOException ie) {
        }
    }
    throw new IOException("No bkdl config bound under dl path : " + dlPath);
}

From source file:net.rim.ejde.internal.ui.preferences.PreprocessDefineInputValidator.java

public String isValid(String newText) {
    if (newText == null || newText.length() == 0) {
        return Messages.BuildPrefsPage_PreprocessValidationMsg1;
    }//from   www .j a va  2  s . c  om
    String[] tagStrings = StringUtils.split(newText, IConstants.SEMICOLON_MARK);
    List<String> validtag = new ArrayList<String>();
    for (String tagString : tagStrings) {
        if (StringUtils.isEmpty(tagString)) {
            return Messages.BuildPrefsPage_PreprocessValidationMsg1;
        } else if (!(validPPTagPattern.matcher(tagString).matches())) {
            if (tagString.contains(IConstants.SEMICOLON_MARK) && !isEdit) {// for add ; is a valid character
                for (String tag : StringUtils.split(tagString, IConstants.SEMICOLON_MARK)) {
                    if (!(validPPTagPattern.matcher(tag).matches())) {
                        return Messages.BuildPrefsPage_PreprocessValidationMsg2 + tag;
                    }
                }
            } else {
                return Messages.BuildPrefsPage_PreprocessValidationMsg2 + newText;
            }
        } else if (validtag.contains(tagString)) {
            return NLS.bind(Messages.BuildPrefsPage_PreprocessValidationMsg4, tagString);
        } else if (isExistsInTable(UI.getDefineList(), tagString)) {
            if (!(initialText.equals(tagString)) && isEdit) {
                return NLS.bind(Messages.BuildPrefsPage_PreprocessValidationMsg3, tagString);
            } else if (!isEdit) {// eliminate duplication during add
                return NLS.bind(Messages.BuildPrefsPage_PreprocessValidationMsg3, tagString);
            }
        }
        validtag.add(tagString);
    }
    return null;
}

From source file:com.pureinfo.srm.config.workflow.action.WorkflowConfigAction.java

/**
 * @see com.pureinfo.ark.interaction.ActionBase#executeAction()
 *//* ww w .  j  a va  2s  .  c o m*/
public ActionForward executeAction() throws PureException {
    String sAction = request.getParameter("action");
    String procStr = request.getParameter("processes");
    if (logger.isInfoEnabled()) {
        logger.info(procStr);
    }
    if (procStr == null) {
        procStr = "";
        logger.warn("parameter processes is null");
    }
    String[] processes = StringUtils.split(procStr, ',');

    if (sAction == null || sAction.equals("")) {
        logger.info("set work select!");
        for (int i = 0; i < processes.length; i++) {
            String sName = processes[i];
            WfProcess process = WorkflowHelper.getProcess(sName);
            if (process == null) {
                request.setAttribute(sName, "0");
                request.setAttribute(sName + "$edit", "");
                request.setAttribute(sName + "$directAdd", "");
                request.setAttribute(sName + "$firstCheck", "");
                request.setAttribute(sName + "$lastCheck", "");
            } else {
                request.setAttribute(sName, process.getType());
                setRoles(process, sName, "edit");
                setRoles(process, sName, "directAdd");
                setRoles(process, sName, "firstCheck");
                setRoles(process, sName, "lastCheck");
            }
        }
    } else if (sAction.equals("set")) {
        logger.info("set work flow!");
        for (int i = 0; i < processes.length; i++) {
            String sName = processes[i];
            WfProcess process = new WfProcess(sName);
            Map acts = new HashMap();
            String sType = request.getParameter(sName);
            process.setType(sType);
            int nType = Integer.parseInt(sType);
            request.setAttribute(sName, sType);
            switch (nType) {
            case 2:
                addAct(acts, sName, "lastCheck");
            case 1:
                addAct(acts, sName, "edit");
                addAct(acts, sName, "firstCheck");
            case 0:
                addAct(acts, sName, "directAdd");
            }
            process.setActities(acts);
            WorkflowHelper.updateProcess(process);
        }
        WorkflowHelper.store();
        request.setAttribute("success", "true");
    }

    String sForward = request.getParameter("forward");
    return mapping.findForward(sForward);
}

From source file:com.stehno.cola.Pop3ServerHandler.java

@Override
public void messageReceived(final IoSession session, final Object message) throws Exception {
    final String[] line = StringUtils.split(message.toString(), ' ');
    final Pop3Command command = commandFactory.findCommand(line[0]);
    if (command != null) {
        command.execute(session, (String[]) ArrayUtils.subarray(line, 1, line.length));
    } else {//from  ww  w.jav  a 2  s  .  c om
        session.write("-ERR\r");
        log.info("Nowhere: {}", line);
    }
}

From source file:com.apexxs.neonblack.solr.Searcher.java

public List<DetectedLocation> search(List<DetectedLocation> locs) {
    Queries queries = new Queries();

    for (DetectedLocation loc : locs) {
        if (loc.detectedBy.equals("NER")) {
            List<GeoNamesEntry> geonames = new ArrayList<>();
            String queryString = getQueryString(loc);

            String[] tokens = StringUtils.split(loc.name, " ");

            if (tokens.length == 1) {
                geonames = queries.doSelectQuery(queryString);
            } else if (tokens.length > 1) {
                geonames = queries.doNameQuery(queryString);
            }/*w  ww.ja  v a2s .c om*/

            if (geonames.size() == 0 && loc.hints != null) {
                loc.hints = null;
                queryString = getQueryString(loc);
                if (tokens.length == 1) {
                    geonames = queries.doSelectQuery(queryString);
                } else if (tokens.length > 1) {
                    geonames = queries.doNameQuery(queryString);
                }
            }
            if (geonames.size() > 0) {
                loc.geoNamesEntries.addAll(geonames);
            }
        } else if (loc.detectedBy.equals("RGX")) {
            double lat = loc.geocoordMatch.getLatitude();
            double lon = loc.geocoordMatch.getLongitude();
            String lonLat = lon + " " + lat;
            List<BorderData> results = queries.doBorderQuery(lonLat);

            GeoNamesEntry entry = new GeoNamesEntry();
            for (BorderData bd : results) {
                if (StringUtils.equals(bd.shapeType, "adm0")) {
                    entry.countryCode = bd.iso2;
                } else if (StringUtils.equals(bd.shapeType, "adm1")) {
                    entry.admin1 = bd.name;
                } else if (StringUtils.equals(bd.shapeType, "adm2")) {
                    entry.admin2 = bd.name;
                }
            }
            entry.name = loc.name;
            entry.score = 1.0f;
            entry.setLevenshteinScore(1.0f);
            loc.geoNamesEntries.add(entry);
        }
    }
    return locs;
}