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.npower.unicom.sync.AbstractExportDaemonPlugIn.java

/**
 * ./*  w  w  w.  ja  v a2 s .com*/
 * : "2004-09-06 15:4*:*"
 * @param date
 * @param patternStr
 * @return
 */
public static boolean onTime(Date date, String patternStr) {
    if (patternStr == null) {
        return false;
    }
    String[] patterns = StringUtils.split(patternStr, ",");
    if (patterns == null || patterns.length == 0) {
        return false;
    }

    SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
    String dateString = formatter.format(date);
    for (int i = 0; patterns != null && i < patterns.length; i++) {
        String tmp = patterns[i].replaceAll("\\*", ".*").trim();
        Pattern pattern = Pattern.compile(tmp);
        Matcher matcher = pattern.matcher(dateString);
        if (matcher.matches()) {
            return true;
        }
    }
    return false;
}

From source file:com.adobe.acs.commons.util.impl.QueryHelperImpl.java

/**
 * Find all the resources needed for the package definition.
 *
 * @param resourceResolver the resource resolver to find the resources
 * @param language         the Query language
 * @param statement        the Query statement
 * @param relPath          the relative path to resolve against query result nodes for package resources
 * @return a unique set of paths to include in the package
 * @throws RepositoryException/* w ww. j  a va2 s .  c o  m*/
 */
public List<Resource> findResources(final ResourceResolver resourceResolver, final String language,
        final String statement, final String relPath) throws RepositoryException {
    if (StringUtils.isEmpty(statement)) {
        return Collections.emptyList();
    }

    final String[] lines = StringUtils.split(statement, '\n');

    if (QUERY_BUILDER.equalsIgnoreCase(language)) {
        return getResourcesFromQueryBuilder(resourceResolver, lines);
    } else if (LIST.equalsIgnoreCase(language)) {
        return getResourcesFromList(resourceResolver, lines, relPath);
    } else {
        return getResourcesFromQuery(resourceResolver, language, statement, relPath);
    }
}

From source file:com.baidu.cc.FilterableConfigItemChangedCallable.java

/**
 * default constructor//from w w w. j a v a 2s.  co m
 * 
 * @param method target method
 * @param target target bean
 * @param filerKeyStr filter keys set from annotation
 */
public FilterableConfigItemChangedCallable(Method method, Object target, String filerKeyStr) {
    super();
    Assert.notNull(method, "property 'method' should not be null");
    this.method = method;
    //check method
    Class<?>[] parameterTypes = method.getParameterTypes();
    if (parameterTypes == null || parameterTypes.length != 1 || !List.class.equals(parameterTypes[0])) {
        throw new RuntimeException("Invalid method. @ConfigChangeNotifer method only "
                + "has one parameter and type is List<'" + ChangedConfigItem.class.getName() + ">'");
    }

    this.target = target;
    filerKeys = new HashSet<String>();
    if (StringUtils.isNotBlank(filerKeyStr)) {
        String[] split = StringUtils.split(filerKeyStr, ",");
        for (String string : split) {
            filerKeys.add(StringUtils.trim(string));
        }
    }

}

From source file:com.pureinfo.srm.config.workflow.function.ProjectGuarder.java

/**
 * @see com.pureinfo.ark.interaction.view.ViewGuarderImplBase#checkPass(com.pureinfo.ark.content.model.ArkContent,
 *      com.pureinfo.ark.auth.model.IUser, java.lang.Object[])
 *///from w  w w .  j  a v  a 2  s  . co  m
protected boolean checkPass(ArkContent _content, IUser _user, Object[] _args) throws PureException {
    //1. to validate the arguments number
    FunctionHandlerUtil.validateArgsNum(_args, MIN_ARGS_NUM);

    //2. to find the resource
    ArkContent resource = _content;
    String sObject = (String) _args[ARG_OBJECT];
    if (sObject != null && (sObject = sObject.trim()).length() > 0) {
        sObject = sObject.toLowerCase();
        if ("outlayunit".equals(sObject)) {
            resource = new OutlayUnit();
            ((OutlayUnit) resource).setProjectId(_content.getId());
        } else if ("contract".equals(sObject)) {
            resource = new Contract();
            ((Contract) resource).setProjectId(_content.getId());
        }
    }
    if (logger.isDebugEnabled()) {
        logger.debug("resource:" + resource.toString() + ", actions=" + _args[ARG_ACTION]);
    }

    //3. to validate the authorization for user
    IAuth2Mgr authMgr = Auth2Helper.getManager();
    String[] actions = StringUtils.split((String) _args[ARG_ACTION], "|");
    for (int i = 0; i < actions.length; i++) {
        int nActionIndex = authMgr.indexOfAction(actions[i], true);
        if (authMgr.hasRight(_user, resource, nActionIndex, false))
            return true;
    }

    //else
    return false;
}

From source file:edu.jhu.pha.vospace.node.NodePath.java

public NodePath(String path, boolean enableAppContainer) {
    if (null == path)
        path = "";
    this.pathTokens = StringUtils.split(path, SEPARATOR);
    this.enableAppContainer = enableAppContainer;
}

From source file:de.doncarnage.minecraft.common.commandhandler.tree.impl.CommandTree.java

@Override
public void addContent(T pathDescriptor) {
    String fullCommand = pathDescriptor.getPathString();
    String[] path = StringUtils.split(fullCommand, " ");
    validate(path);//  w w w . j a  v  a2 s  .  c om

    Node<T> current = createNodePath(path);
    if (current != null) {
        while (current.isOptional()) {
            current = current.getParent();
        }
        if (current.getContent() != null) {
            throw new ConflictingContentException(
                    String.format("There is already a node at this position: %s", fullCommand));
        }
        current.setContent(pathDescriptor);
    } else {
        throw new NodeException(String.format("Could not create path for command: %s", fullCommand));
    }
}

From source file:filterviewplugin.FilterViewSettings.java

String[] getActiveFilterNames() {
    return StringUtils.split(get(KEY_FILTER_NAMES, ""), SEPARATOR);
}

From source file:com.npower.dm.util.MToneDeviceDataReader.java

public DeviceData read() throws IOException {
    String line = readLine();/*from  w  ww. j a va2 s.com*/
    while (StringUtils.isNotEmpty(line) && line.startsWith("#")) {
        line = this.readLine();
    }
    if (StringUtils.isEmpty(line)) {
        return null;
    }

    line = line.trim();
    String[] items = StringUtils.split(line, ',');
    if (items == null || items.length < 2) {
        return null;
    }
    String phone = items[0];
    String model = items[1];
    if (items.length > 2) {
        int iiii = 0;
    }
    String brand = (items.length < 3) ? "NOKIA" : items[2];

    DeviceData data = new DeviceData();
    data.setManufacturer(brand.trim());
    data.setModel(model.trim());
    data.setPhoneNumber(phone.trim());
    data.setLineNumber(this.currentLineNumber);
    return data;
}

From source file:com.intuit.tank.util.RestSecurityFilter.java

public User getUser(HttpServletRequest req) {
    User user = null;//ww w  . j a  va 2 s . co m
    // firsttry the session
    if (identity != null) {
        org.picketlink.idm.api.User picketLinkUser = identity.getUser();
        if (picketLinkUser != null && picketLinkUser instanceof TankUser) {
            user = ((TankUser) picketLinkUser).getUserEntity();
        }
    }
    if (user == null) {
        String authHeader = req.getHeader("authorization");
        try {
            if (authHeader != null) {
                String[] split = StringUtils.split(authHeader, ' ');
                if (split.length == 2) {
                    String s = new String(Base64.decodeBase64(split[1]), "UTF-8");
                    String[] upass = StringUtils.split(s, ":", 2);
                    if (upass.length == 2) {
                        String name = upass[0];
                        String token = upass[1];
                        UserDao userDao = new UserDao();
                        user = userDao.findByApiToken(token);
                        if (user == null || user.getName().equals(name)) {
                            user = userDao.authenticate(name, token);
                        }
                    }
                }
            }
        } catch (Exception e) {
            LOG.error("Error getting user: " + e, e);
        }
    }
    return user;
}

From source file:com.migratebird.structure.model.DbItemIdentifier.java

public static DbItemIdentifier parseItemIdentifier(DbItemType type, String identifierAsString,
        Databases databases) {//  w ww . j  a va  2s. co m
    String[] identifierParts = StringUtils.split(identifierAsString, '.');
    String schemaName, itemName;
    Database database;
    if (identifierParts.length == 3) {
        String databaseName = identifierParts[0];
        database = databases.getDatabase(databaseName);
        if (database == null) {
            // database is disabled
            return null;
        }
        schemaName = identifierParts[1];
        itemName = identifierParts[2];
    } else if (identifierParts.length == 2) {
        database = databases.getDefaultDatabase();
        schemaName = identifierParts[0];
        itemName = identifierParts[1];
    } else if (identifierParts.length == 1) {
        database = databases.getDefaultDatabase();
        schemaName = database.getDefaultSchemaName();
        itemName = identifierParts[0];
    } else {
        throw new MigrateBirdException("Incorrectly formatted db item identifier " + identifierAsString);
    }

    String correctCaseSchemaName = database.toCorrectCaseIdentifier(schemaName);
    String correctCaseItemName = database.toCorrectCaseIdentifier(itemName);
    return getItemIdentifier(type, correctCaseSchemaName, correctCaseItemName, database);
}