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.surfs.nas.sql.ErrorCodeSupport.java

/**
 *
 * @param code_map/* w  ww. j ava  2 s.co m*/
 * @param code
 * @return int
 */
private static int getExceptionType(HashMap<Integer, Integer[]> code_map, int code) {
    for (Map.Entry<Integer, Integer[]> entry : code_map.entrySet()) {
        Integer[] codes = entry.getValue();
        if (ArrayUtils.contains(codes, code)) {
            return entry.getKey();
        }
    }
    return SortedSQLException.UncategorizedException;
}

From source file:co.propack.sample.payment.service.gateway.NullPaymentGatewayWebResponseServiceImpl.java

@Override
public PaymentResponseDTO translateWebResponse(HttpServletRequest request) throws PaymentException {
    PaymentResponseDTO responseDTO = new PaymentResponseDTO(PaymentType.CREDIT_CARD,
            NullPaymentGatewayType.NULL_GATEWAY).rawResponse(webResponsePrintService.printRequest(request));

    Map<String, String[]> paramMap = request.getParameterMap();

    Money amount = Money.ZERO;/*from  w w w . java 2s  . c om*/
    if (paramMap.containsKey(NullPaymentGatewayConstants.TRANSACTION_AMT)) {
        String amt = paramMap.get(NullPaymentGatewayConstants.TRANSACTION_AMT)[0];
        amount = new Money(amt);
    }

    boolean approved = false;
    if (paramMap.containsKey(NullPaymentGatewayConstants.RESULT_SUCCESS)) {
        String[] msg = paramMap.get(NullPaymentGatewayConstants.RESULT_SUCCESS);
        if (ArrayUtils.contains(msg, "true")) {
            approved = true;
        }
    }

    PaymentTransactionType type = PaymentTransactionType.AUTHORIZE_AND_CAPTURE;
    if (!configuration.isPerformAuthorizeAndCapture()) {
        type = PaymentTransactionType.AUTHORIZE;
    }

    responseDTO.successful(approved).amount(amount).paymentTransactionType(type)
            .orderId(paramMap.get(NullPaymentGatewayConstants.ORDER_ID)[0])
            .responseMap(NullPaymentGatewayConstants.GATEWAY_TRANSACTION_ID,
                    paramMap.get(NullPaymentGatewayConstants.GATEWAY_TRANSACTION_ID)[0])
            .responseMap(NullPaymentGatewayConstants.RESULT_MESSAGE,
                    paramMap.get(NullPaymentGatewayConstants.RESULT_MESSAGE)[0])
            .billTo().addressFirstName(paramMap.get(NullPaymentGatewayConstants.BILLING_FIRST_NAME)[0])
            .addressLastName(paramMap.get(NullPaymentGatewayConstants.BILLING_LAST_NAME)[0])
            .addressLine1(paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE1)[0])
            .addressLine2(paramMap.get(NullPaymentGatewayConstants.BILLING_ADDRESS_LINE2)[0])
            .addressCityLocality(paramMap.get(NullPaymentGatewayConstants.BILLING_CITY)[0])
            .addressStateRegion(paramMap.get(NullPaymentGatewayConstants.BILLING_STATE)[0])
            .addressPostalCode(paramMap.get(NullPaymentGatewayConstants.BILLING_ZIP)[0])
            .addressCountryCode(paramMap.get(NullPaymentGatewayConstants.BILLING_COUNTRY)[0]).done()
            .creditCard().creditCardHolderName(paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_NAME)[0])
            .creditCardLastFour(paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_LAST_FOUR)[0])
            .creditCardType(paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_TYPE)[0])
            .creditCardExpDate(paramMap.get(NullPaymentGatewayConstants.CREDIT_CARD_EXP_DATE)[0]).done();

    return responseDTO;

}

From source file:com.adobe.acs.commons.contentfinder.querybuilder.impl.viewhandler.QueryBuilderViewHandler.java

/**
 * Assume query should be treated as a QueryBuilder query, rather than a GQL query
 * <p>//from  w  w w. ja v  a 2s  .c om
 * This intelligently converts default Fulltext and Limit parameters to QueryBuilder equivalents
 *
 * @param request
 * @param queryString
 * @return
 */
@SuppressWarnings("unchecked")
private Map<String, String> getQueryBuilderParams(final SlingHttpServletRequest request,
        final String queryString) {
    Map<String, String> map = new LinkedHashMap<String, String>();

    for (final String key : (Set<String>) request.getParameterMap().keySet()) {
        // Skip known content finder parameters that are unused for QueryBuilder
        if (!ArrayUtils.contains(ContentFinderConstants.QUERYBUILDER_BLACKLIST, key)) {
            final String val = request.getParameter(key);
            if (StringUtils.isNotBlank(val)) {
                map.put(key, val);
            }
        } else {
            log.debug("Rejecting property [ {} ] due to blacklist match", key);
        }
    }

    map = GQLToQueryBuilderConverter.addFulltext(request, map, queryString);
    map = GQLToQueryBuilderConverter.addLimitAndOffset(request, map);

    return map;
}

From source file:com.kbotpro.randoms.GraveDigger.java

/**
 * Gets the index from the coffin interface
 *
 * @return The index for the arrays/*from ww  w . j  a  v a2  s  .c o m*/
 */
private int getCoffinIndex() {
    Interface groupIface = interfaces.getInterface(COFFIN_INTERFACE_ID);
    if (groupIface == null || !groupIface.isValid())
        return -1;
    for (IComponent childIface : groupIface.getComponents())
        for (int i = 0; i < COFFIN_CONTAINED_ITEM_IDS.length; i++)
            if (ArrayUtils.contains(COFFIN_CONTAINED_ITEM_IDS[i], childIface.getElementID()))
                return i;
    return -1;
}

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

public final void test() throws EdisonException {

    log.debug("SOPREVIOUS");
    // Using the first TA and a constituent between span of 0-20 as a test
    TextAnnotation ta = tas.get(3);//from   w  w  w  . ja v a  2s.  c om
    View TOKENS = ta.getView("TOKENS");

    log.debug("GOT TOKENS FROM TEXTAnn");

    List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20);

    for (Constituent c : testlist) {
        log.debug(c.getSurfaceForm());
    }

    log.debug("Testlist size is " + testlist.size());

    Constituent test = testlist.get(5);

    log.debug("The constituent we are extracting features from in this test is: " + test.getSurfaceForm());

    MixedChunkWindowTwoBeforePOSWindowThreeBefore SOP = new MixedChunkWindowTwoBeforePOSWindowThreeBefore(
            "MixedChunkWindowTwoBeforePOSWindowThreeBefore");

    Set<Feature> feats = SOP.getFeatures(test);
    String[] expected_outputs = { "MixedChunkWindowTwoBeforePOSWindowThreeBefore:ll(NP_VP)",
            "MixedChunkWindowTwoBeforePOSWindowThreeBefore:lt1(NP_RB)",
            "MixedChunkWindowTwoBeforePOSWindowThreeBefore:lt2VP_VBN" };

    if (feats == null) {
        log.debug("Feats are returning NULL.");
    }

    log.debug("Printing Set of Features");
    for (Feature f : feats) {
        log.debug(f.getName());
        assert (ArrayUtils.contains(expected_outputs, f.getName()));
    }

    // System.exit(0);
}

From source file:com.manydesigns.elements.forms.AbstractFormBuilder.java

protected boolean skippableProperty(PropertyAccessor propertyAccessor) {
    // static field?
    if (Modifier.isStatic(propertyAccessor.getModifiers())) {
        return true;
    }//from  w w w . j av  a2 s . c  o  m
    // blacklisted?
    if (ArrayUtils.contains(PROPERTY_NAME_BLACKLIST, propertyAccessor.getName())) {
        return true;
    }
    return false;
}

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

/**
 * @param dest               Destination
 * @param invalidTilesGlobal Invalid Tiles Global Array
 * @return The least costing tile from the surrounding 8 tiles (A* Algo)
 * @author PwnZ//from   w w w . ja v  a2 s .  co m
 */
protected Tile calculateLeastCost(final Tile dest, final Tile... invalidTilesGlobal) {
    Tile p = tile;
    double lowestCost = 9999.0;
    double cost;
    ArrayList<Tile> invalid = new ArrayList<Tile>();
    int i = -1;

    for (Tile o : orthogonalArray) {
        i++;
        if (ArrayUtils.contains(invalidTilesGlobal, o))
            continue;

        if (tileData != 0) {
            if ((IWCalculations.getTileData(o, botEnv.client)
                    & (IWCalculations.FULL_BLOCK | IWCalculations.BLOCKED_0)) != 0) {
                invalid.add(o);
                continue;
            }

            if (IWCalculations.calculateUnwalkable(IWCalculations.movementOrder[i], getTileData())) {
                invalid.add(o);
                continue;
            }
        }

        cost = IWCalculations.ORTHOGONAL_COST
                + (Math.abs((dest.getX() - o.getX())) + Math.abs((dest.getY() - o.getY())));
        if (cost < lowestCost) {
            invalid.add(p);
            lowestCost = cost;
            p = o;
        } else {
            invalid.add(o);
        }
    }

    for (Tile d : diagonalArray) {
        i++;

        if (ArrayUtils.contains(invalidTilesGlobal, d))
            continue;

        if (tileData != 0) {
            if ((IWCalculations.getTileData(d, botEnv.client)
                    & (IWCalculations.FULL_BLOCK | IWCalculations.BLOCKED_0)) != 0) {
                invalid.add(d);
                continue;
            }

            if (IWCalculations.calculateUnwalkable(IWCalculations.movementOrder[i], getTileData())) {
                invalid.add(d);
                continue;
            }
        }

        cost = IWCalculations.DIAGONAL_COST
                + (Math.abs((dest.getX() - d.getX())) + Math.abs((dest.getY() - d.getY())));
        if (cost < lowestCost) {
            invalid.add(p);
            lowestCost = cost;
            p = d;
        } else {
            invalid.add(d);
        }
    }

    invalidTiles = invalid.toArray(new Tile[invalidTiles.length]);
    return p;
}

From source file:info.magnolia.importexport.filters.VersionFilter.java

/**
 * @see org.xml.sax.helpers.XMLFilterImpl#startElement(String, String, String, Attributes)
 *///from www  .jav a  2 s .c o m
@Override
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {

    if (inVersionElement > 0) {
        inVersionElement++;
        return;
    }
    if ("sv:node".equals(qName)) {
        String attName = atts.getValue("sv:name");
        if (attName != null && ArrayUtils.contains(FILTERED_NODES, attName)) {
            inVersionElement++;
            return;
        }
    } else if ("sv:property".equals(qName)) {
        String attName = atts.getValue("sv:name");
        if (attName != null && ArrayUtils.contains(FILTERED_PROPERTIES, attName)) {
            inVersionElement++;
            return;
        }
    }

    super.startElement(uri, localName, qName, atts);
}

From source file:com.adobe.acs.commons.rewriter.impl.ResourceResolverMapTransformerFactory.java

protected Attributes rebuildAttributes(final SlingHttpServletRequest slingRequest, final String elementName,
        final Attributes attrs) {
    if (slingRequest == null || !attributes.containsKey(elementName)) {
        // element is not defined as a candidate to rewrite
        return attrs;
    }/*from   w  w  w .j a  v  a 2s .c  o  m*/
    final String[] modifiableAttributes = attributes.get(elementName);

    // clone the attributes
    final AttributesImpl newAttrs = new AttributesImpl(attrs);
    final int len = newAttrs.getLength();

    for (int i = 0; i < len; i++) {
        final String attrName = newAttrs.getLocalName(i);
        if (ArrayUtils.contains(modifiableAttributes, attrName)) {
            final String attrValue = newAttrs.getValue(i);
            if (StringUtils.startsWith(attrValue, "/") && !StringUtils.startsWith(attrValue, "//")) {
                // Only map absolute paths (starting w /), avoid relative-scheme URLs starting w //
                newAttrs.setValue(i, slingRequest.getResourceResolver().map(slingRequest, attrValue));
            }
        }
    }
    return newAttrs;
}

From source file:com.benfante.minimark.blo.UserProfileBo.java

public boolean canUserMonitorAssessment(UserProfile userProfile, Assessment assessment) {
    boolean result = false;
    if (canCurrentUserEditAssessment(assessment) || ArrayUtils.contains(assessment.getMonitoringUsersAsArray(),
            userProfile.getUser().getUsername())) {
        result = true;/*from  ww w. j  a va  2s .  c  o m*/
    }
    return result;
}