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.granita.icloudcalsync.webdav.TlsSniSocketFactoryTest.java

public void testProtocolVersions() throws IOException {
    String enabledProtocols[] = factory.protocols;
    // SSL (all versions) should be disabled
    for (String protocol : enabledProtocols)
        assertFalse(protocol.contains("SSL"));
    // TLS v1+ should be enabled
    assertTrue(ArrayUtils.contains(enabledProtocols, "TLSv1"));
    assertTrue(ArrayUtils.contains(enabledProtocols, "TLSv1.1"));
    assertTrue(ArrayUtils.contains(enabledProtocols, "TLSv1.2"));
}

From source file:io.horizondb.model.core.util.TimeUtils.java

/**
 * Truncate this date, leaving the field specified as the most significant field.
 * /*from ww  w .j  a  va2s . co m*/
 * @param calendar the calendar to truncate
 * @param field the most significant field
 */
public static void truncate(Calendar calendar, int field) {

    Validate.isTrue(ArrayUtils.contains(TRUNCATING_FIELDS, field),
            "the specified field cannot be used to truncate the specified calendar");

    for (int calendarField : TRUNCATING_FIELDS) {

        if (field == calendarField) {

            return;
        }

        calendar.set(calendarField, calendar.getActualMinimum(calendarField));
    }
}

From source file:edu.illinois.cs.cogcomp.edison.features.lrec.TestPosWordConjunctionSizeTwoWindowSizeTwo.java

@Test
public final void test() throws EdisonException {
    // / Using the 3rd constituent as a test
    List<Constituent> testList = ta.getView("TOKENS").getConstituents();
    Constituent test = testList.get(3);//from  ww  w. ja  v  a 2 s  . c  o m

    PosWordConjunctionSizeTwoWindowSizeTwo fex = new PosWordConjunctionSizeTwoWindowSizeTwo("PosWordConj2Win2");

    Set<Feature> feats = fex.getFeatures(test);
    String[] expected_outputs = { "PosWordConjunctionSizeTwoWindowSizeTwo:-2_1(NN-construction)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:-1_1(IN-of)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:0_1(DT-the)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:1_1(NNP-John)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:2_1(NNP-Smith)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:-2_2(NN-construction_IN-of)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:-1_2(IN-of_DT-the)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:0_2(DT-the_NNP-John)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:1_2(NNP-John_NNP-Smith)",
            "PosWordConjunctionSizeTwoWindowSizeTwo:2_2(NNP-Smith)" };

    if (feats == null)
        fail("Feats are returning NULL.");

    for (Feature f : feats) {
        assertTrue(ArrayUtils.contains(expected_outputs, f.getName()));
    }
}

From source file:de.tudarmstadt.lt.n2n.utilities.PatternGenerator.java

public static int[][] comb(int k, int n, int[] fixed, boolean sort) {
    int[][] s = new int[0][];
    for (int u = 0; u < 1 << n; u++)
        if (bitcount(u) == k) {
            int[] c = bitadd(u, k);
            boolean add = true;
            for (int f : fixed)
                add &= !ArrayUtils.contains(c, f);
            if (add)
                s = (int[][]) ArrayUtils.add(s, c);
        }//from www.j ava 2  s .  c  o m
    if (sort)
        Arrays.sort(s, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                for (int i = 0; i < o1.length; i++) {
                    int r = o2[i] - o1[i];
                    if (r != 0)
                        return r;
                }
                return 0;
            }
        });
    return s;
}

From source file:info.magnolia.cms.util.Rule.java

/**
 * is allowed/* ww  w. j  a  va 2  s .c o m*/
 * @param nodeType
 * @return true if given nodeType is allowed
 */
public boolean isAllowed(String nodeType) {
    boolean allowed = ArrayUtils.contains(allowedTypes, nodeType);
    if (this.reverse) {
        return !allowed;
    }

    return allowed;

}

From source file:com.dp2345.interceptor.LogInterceptor.java

@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    List<LogConfig> logConfigs = logConfigService.getAll();
    if (logConfigs != null) {
        String path = request.getServletPath();
        for (LogConfig logConfig : logConfigs) {
            if (antPathMatcher.match(logConfig.getUrlPattern(), path)) {
                String username = adminService.getCurrentUsername();
                String operation = logConfig.getOperation();
                String operator = username;
                String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                String ip = request.getRemoteAddr();
                request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                StringBuffer parameter = 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) {
                                    parameter.append(parameterName + " = " + parameterValue + "\n");
                                }//from www .ja  v a2s  .  c  o m
                            }
                        }
                    }
                }
                Log log = new Log();
                log.setOperation(operation);
                log.setOperator(operator);
                log.setContent(content);
                log.setParameter(parameter.toString());
                log.setIp(ip);
                logService.save(log);
                break;
            }
        }
    }
}

From source file:com.sammyun.interceptor.LogInterceptor.java

@SuppressWarnings("unchecked")
@Override//  w ww  .java2  s  .co  m
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
        ModelAndView modelAndView) throws Exception {
    List<LogConfig> logConfigs = logConfigService.getAll();
    if (logConfigs != null) {
        String path = request.getServletPath();
        for (LogConfig logConfig : logConfigs) {
            if (antPathMatcher.match(logConfig.getUrlPattern(), path)) {
                String username = adminService.getCurrentUsername();
                String operation = logConfig.getOperation();
                String operator = username;
                String content = (String) request.getAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                String ip = EduUtil.getAddr(request);
                request.removeAttribute(Log.LOG_CONTENT_ATTRIBUTE_NAME);
                StringBuffer parameter = 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) {
                                    parameter.append(parameterName + " = " + parameterValue + "\n");
                                }
                            }
                        }
                    }
                }
                Log log = new Log();
                log.setOperation(operation);
                log.setOperator(operator);
                log.setContent(content);
                log.setParameter(parameter.toString());
                log.setIp(ip);
                logService.save(log);
                break;
            }
        }
    }
}

From source file:eu.dime.ps.semantic.rdf.TripleStoreImplTest.java

@Test
public void testRDFSReasoning() {
    URI ontGraph = new URIImpl("http://example.org#");
    URI person = new URIImpl("http://example.org#Person");
    URI director = new URIImpl("http://example.org#Director");
    URI actor = new URIImpl("http://example.org#Actor");
    tripleStore.addStatement(ontGraph, person, RDF.type, RDFS.Class);
    tripleStore.addStatement(ontGraph, director, RDF.type, RDFS.Class);
    tripleStore.addStatement(ontGraph, director, RDFS.subClassOf, person);
    tripleStore.addStatement(ontGraph, actor, RDF.type, RDFS.Class);
    tripleStore.addStatement(ontGraph, actor, RDFS.subClassOf, person);

    URI[] instances = new URI[] { new URIImpl("urn:actor:a"), new URIImpl("urn:director:a") };
    tripleStore.addStatement(new URIImpl("urn:data-graph"), instances[0], RDF.type, actor);
    tripleStore.addStatement(new URIImpl("urn:data-graph"), instances[1], RDF.type, director);

    ClosableIterator<QueryRow> it = null;

    // urn:actor:a & urn:director:a are returned by the query, both are a instances of 
    // subclasses of 'person'
    it = tripleStore/*from   w  ww.j a  v  a  2s.c  o m*/
            .sparqlSelect("SELECT ?who WHERE { ?who " + RDF.type.toSPARQL() + " " + person.toSPARQL() + ". }")
            .iterator();
    assertTrue(it.hasNext());
    while (it.hasNext()) {
        URI who = it.next().getValue("who").asURI();
        assertTrue(ArrayUtils.contains(instances, who));
    }
    it.close();
}

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

public static boolean equalsAny(String string, String... strings) {
    return string != null && strings != null && ArrayUtils.contains(strings, string);
}

From source file:com.kbotpro.scriptsystem.intelliwalk.data.MapNodeList.java

/**
 * Populates the invalid tile array/*from  w  ww. ja  va 2s .  c om*/
 * @author PwnZ
 * @param p invalid tile array
 */
public void populateInvalidTiles(Tile... p) {
    Tile[] invalidArray = invalidTiles.toArray(new Tile[invalidTiles.size()]);

    if (p == null)
        return;

    for (Tile a : p) {
        if (!ArrayUtils.contains(invalidArray, a))
            invalidTiles.add(a);

    }
}