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

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

Introduction

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

Prototype

public static boolean contains(boolean[] array, boolean valueToFind) 

Source Link

Document

Checks if the value is in the given array.

Usage

From source file:com.adobe.acs.commons.workflow.bulk.execution.impl.ConfigResourceVisitor.java

@Override
public final void accept(final Resource resource) {
    // Only accept the Root folder and cq:Page and cq:PageContent nodes; All other structures are uninteresting
    // to this functionality and may be very large
    if (StringUtils.startsWith(resource.getPath(), BULK_WORKFLOW_MANAGER_PAGE_FOLDER_PATH)) {
        final ValueMap properties = resource.adaptTo(ValueMap.class);
        final String primaryType = properties.get(JcrConstants.JCR_PRIMARYTYPE, String.class);

        if (BULK_WORKFLOW_MANAGER_PAGE_FOLDER_PATH.equals(resource.getPath())
                || ArrayUtils.contains(ACCEPTED_PRIMARY_TYPES, primaryType)) {
            super.accept(resource);
        }/*from www .j ava 2  s. c o m*/
    }
}

From source file:com.adobe.acs.commons.util.visitors.ContentVisitor.java

@Override
public void accept(Resource resource) {
    if (resource != null) {
        final String primaryType = resource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class);

        if (ArrayUtils.contains(containerTypes, primaryType)
                || ArrayUtils.contains(contentTypes, primaryType)) {
            super.accept(resource);
        }// w w  w  . ja  va  2s .  c o m
    }
}

From source file:com.adobe.acs.samples.replication.impl.SampleReplicationContentFilter.java

@Override
public boolean accepts(final Property property) {
    try {//from  w w  w  . jav  a 2  s  .  com
        // Example: Reject properties whose names are "secretData" or "privateData"
        if (!ArrayUtils.contains(new String[] { "secretData", "privateData" }, property.getName())) {
            // Maintain the filteredPaths list whenever accepts returns false
            filteredPaths.add(property.getPath());
            return false;
        }
    } catch (RepositoryException e) {
        log.error("Repository exception occurred. Do not accept this Property. {}", e);
    }

    // Default behavior is to return true
    return true;
}

From source file:com.google.cloud.bigtable.hbase.TestListTables.java

/**
 * @throws IOException// w  w  w  .j  a  v a 2s . com
 */
@Test
public void testTableNames() throws IOException {
    try (Admin admin = getConnection().getAdmin()) {
        TableName tableName1 = TableName.valueOf("list_table1-" + UUID.randomUUID().toString());
        TableName tableName2 = TableName.valueOf("list_table2-" + UUID.randomUUID().toString());

        Assert.assertFalse(admin.tableExists(tableName1));
        Assert.assertFalse(ArrayUtils.contains(admin.listTableNames(), tableName1));

        createTable(admin, tableName1);
        checkColumnFamilies(admin, tableName1);

        {
            Assert.assertTrue(admin.tableExists(tableName1));
            Assert.assertFalse(admin.tableExists(tableName2));
            TableName[] tableList = admin.listTableNames();
            Assert.assertTrue(ArrayUtils.contains(tableList, tableName1));
            Assert.assertFalse(ArrayUtils.contains(tableList, tableName2));
        }

        createTable(admin, tableName2);
        checkColumnFamilies(admin, tableName2);

        {
            Assert.assertTrue(admin.tableExists(tableName1));
            Assert.assertTrue(admin.tableExists(tableName2));
            TableName[] tableList = admin.listTableNames();
            Assert.assertTrue(ArrayUtils.contains(tableList, tableName1));
            Assert.assertTrue(ArrayUtils.contains(tableList, tableName2));
        }

        {
            TableName[] tableList = admin.listTableNames(Pattern.compile("list_table1-.*"));
            Assert.assertTrue(ArrayUtils.contains(tableList, tableName1));
            Assert.assertFalse(ArrayUtils.contains(tableList, tableName2));
        }

        {
            HTableDescriptor[] descriptors = admin.listTables(Pattern.compile("list_table1-.*"));
            Assert.assertTrue(contains(descriptors, tableName1));
            Assert.assertFalse(contains(descriptors, tableName2));
        }

        {
            HTableDescriptor[] descriptors = admin
                    .getTableDescriptorsByTableName(Collections.singletonList(tableName2));
            Assert.assertFalse(contains(descriptors, tableName1));
            Assert.assertTrue(contains(descriptors, tableName2));
        }
    }
}

From source file:com.zjzcn.web.LogInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    Map<String, LogNode> logConfigs = ConfigHelper.getLogConfigs();
    String username = userService.getUsername();
    if (logConfigs != null && StringUtils.isNotBlank(username)) {
        HttpServletRequest req = (HttpServletRequest) request;
        String uri = req.getRequestURI().split("[?]")[0];
        String[] strs = uri.split("[\\/\\.]");
        if (strs.length < 2) {
            return;
        }/*from w  w w  .  j a va 2  s.c  o  m*/
        String perm = strs[strs.length - 2];

        if (logConfigs.containsKey(perm)) {
            StringBuffer param = new StringBuffer();
            Map<String, String[]> parameterMap = request.getParameterMap();
            if (parameterMap != null) {
                for (Entry<String, String[]> entry : parameterMap.entrySet()) {
                    String parameterName = entry.getKey();
                    if (!ArrayUtils.contains(ignoreParameters, parameterName)) {
                        String[] parameterValues = entry.getValue();
                        if (parameterValues != null) {
                            for (String parameterValue : parameterValues) {
                                param.append(parameterName + " = " + parameterValue + "\n");
                            }
                        }
                    }
                }
            }
            LogNode logConfig = logConfigs.get(perm);
            Log log = new Log();
            log.setLogType(0);
            log.setName(logConfig.getName());
            log.setUsername(username);
            log.setCreateTime(DateUtils.getCurrentTime(null));
            log.setContent(param.toString());
            log.setIp(request.getRemoteAddr());
            //logService.save(log);
        }
    }
}

From source file:com.pureinfo.srm.view.function.MakeSelectOptions.java

/**
 * @see com.pureinfo.dolphin.script.function.handler.IFunctionHandler#perform(java.lang.Object[],
 *      com.pureinfo.dolphin.script.execute.IContext)
 *//*from   w  ww.j a  va  2 s . c  o m*/
public Object perform(Object[] _args, IContext _context) throws PureException {
    FunctionHandlerUtil.validateArgsNum(_args, 1);

    String[] sDefault = new String[0];
    if (_args.length > IDX_DEFAULTS && _args[IDX_DEFAULTS] != null) {
        Object def = _args[IDX_DEFAULTS];
        if (def.getClass().isArray()) {
            Object[] objs = (Object[]) def;
            sDefault = new String[objs.length];
            for (int i = 0; i < objs.length; i++) {
                sDefault[i] = objs[i].toString();
            }
        } else {
            sDefault = new String[] { def.toString() };
        }

    }
    String[] sExcludes = new String[0];
    if (_args.length > IDX_EXCLUDES && _args[IDX_EXCLUDES] != null) {
        String str = (String) _args[IDX_EXCLUDES];
        if (str.length() > 0) {
            sExcludes = str.split(",");
        }
    }

    String[][] datas = (String[][]) _args[IDX_DATAS];
    StringBuffer sbuff = null;
    try {
        sbuff = new StringBuffer();
        for (int i = 0; i < datas.length; i++) {
            if (ArrayUtils.contains(sExcludes, datas[i][0])) {
                continue;
            }
            sbuff.append("<option value=\"").append(HtmlUtil.encode(datas[i][0])).append('"');
            sbuff.append(ArrayUtils.contains(sDefault, datas[i][0]) ? " selected" : "");
            sbuff.append('>');
            sbuff.append(HtmlUtil.encode(datas[i][1]));
        }
        return sbuff.toString();
    } finally {
        if (sbuff != null)
            sbuff.setLength(0);
    }
}

From source file:gda.data.metadata.icat.XMLIcat.java

@Override
protected String getValue(String visitIDFilter, String userNameFilter, String accessName) throws Exception {

    String filepath = "file:" + LocalProperties.get(URL_PROP);
    Resource xmlfile = new FileSystemResourceLoader().getResource(filepath);
    XmlBeanFactory bf = new XmlBeanFactory(xmlfile);

    long tolerance = LocalProperties.getAsInt(SHIFT_TOL_PROP, 1440);

    // if not filtering on visit ID
    if (visitIDFilter == null || visitIDFilter.isEmpty()) {

        //loop over all the beans
        String values = "";
        Map<String, XMLIcatEntry> beans = bf.getBeansOfType(XMLIcatEntry.class);
        for (XMLIcatEntry bean : beans.values()) {
            // filter on username
            String names[] = bean.getUsernames().split(",");
            if (ArrayUtils.contains(names, userNameFilter)) {

                // filter on date
                Date now;//from   w w w .ja  v a  2 s  .  com
                if (operatingDate != null) {
                    now = operatingDate;
                } else {
                    now = new Date();
                }

                Date start = formatter.parse(bean.getExperimentStart());
                Date end = formatter.parse(bean.getExperimentStart());
                start.setTime(start.getTime() - tolerance * 60000);// tolerance is in minutes but getTime returns in
                // ms
                end.setTime(end.getTime() + tolerance * 60000); // tolerance is in minutes but getTime returns in ms

                if (now.after(start) && now.before(end)) {

                    // add to return string
                    try {
                        if (values.isEmpty()) {
                            values = BeanUtils.getProperty(bean, accessName);
                        } else {
                            values += "," + BeanUtils.getProperty(bean, accessName);
                        }
                    } catch (Exception e) {
                        logger.warn("Exception trying to get property " + accessName + " from bean.", e);
                    }
                }
            }
        }

        // return the values string
        if (values.isEmpty()) {
            return null;
        }
        return values;
    }

    // else find the experiment for that visit and get its property
    XMLIcatEntry visit = bf.getBean(visitIDFilter, XMLIcatEntry.class);
    String names[] = visit.getUsernames().split(",");
    if (ArrayUtils.contains(names, userNameFilter)) {
        try {
            return BeanUtils.getProperty(visit, accessName);
        } catch (Exception e) {
            logger.warn("Exception trying to get property " + accessName + " from bean.", e);
        }
    }

    // else 
    return null;

}

From source file:com.jaspersoft.studio.property.section.widgets.SPReadCombo.java

public void setItems(String[] items) {
    setRefreshing(true);// w w  w .  java2  s .c  o m
    String currentSelection = combo.getText();
    if (ArrayUtils.contains(items, currentSelection)) {
        combo.setItems(items);
        combo.select(ArrayUtils.indexOf(items, currentSelection));
        setRefreshing(false);
    } else {
        setRefreshing(false);
        combo.setItems(items);
        combo.select(0);
    }
}

From source file:eu.sofia.adk.common.xsd.JavaDatatype.java

/**
 * Determines if the datatype is a float datatype 
 * @param datatype a string representation of the datatype
 * @return <code>true</code> if the datatype is a float type
 *//*from w ww  . j ava 2s . com*/
private static boolean isFloatDatatype(String datatype) {
    return ArrayUtils.contains(floatDatatype, datatype);
}

From source file:com.agiletec.plugins.jpavatar.aps.system.services.avatar.parse.AvatarConfigDOM.java

/**
 * Extract the service configuration from an xml.
 * @param xml The xml containing the configuration.
 * @return The service configuration./*from  ww w. j  a  va 2  s .c  om*/
 * @throws ApsSystemException In case of parsing errors.
 */
public AvatarConfig extractConfig(String xml) throws ApsSystemException {
    AvatarConfig config = new AvatarConfig();
    Element root = this.getRootElement(xml);
    Element styleElem = root.getChild(STYLE_ELEM);
    String style = null;
    if (styleElem != null) {
        style = styleElem.getText();
    }

    if (StringUtils.isBlank(style) || !ArrayUtils.contains(AvatarConfig.STYLES, style)) {
        style = AvatarConfig.STYLE_LOCAL;
    }

    config.setStyle(style);
    return config;
}