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:de.knowwe.kdom.renderer.StyleRenderer.java

/**
 * Renders the content that will automatically be styled in the correct way.
 * You may overwrite it for special purposes.
 *
 * @param section the section to be rendered
 * @param user    the user to render for
 * @param string  the buffer to render into
 * @created 06.10.2010/*from w ww.j a v a 2 s. c  om*/
 */
protected void renderContent(Section<?> section, UserContext user, RenderResult string) {
    RenderResult builder = new RenderResult(user);
    DelegateRenderer.getInstance().render(section, user, builder);
    if (ArrayUtils.contains(maskMode, MaskMode.jspwikiMarkup)
            && ArrayUtils.contains(maskMode, MaskMode.htmlEntities)) {
        string.appendJSPWikiMarkup(Strings.encodeHtml(builder.toStringRaw()));
    } else if (ArrayUtils.contains(maskMode, MaskMode.jspwikiMarkup)) {
        string.appendJSPWikiMarkup(builder);
    } else if (ArrayUtils.contains(maskMode, MaskMode.htmlEntities)) {
        string.append(Strings.encodeHtml(builder.toStringRaw()));
    } else {
        string.append(builder);
    }
}

From source file:io.swagger.codegen.languages.SwiftCodegen.java

@Override
public void processOpts() {
    super.processOpts();

    // Setup project name
    if (additionalProperties.containsKey(PROJECT_NAME)) {
        setProjectName((String) additionalProperties.get(PROJECT_NAME));
    } else {/*from   www.j  a  va  2 s  . c  om*/
        additionalProperties.put(PROJECT_NAME, projectName);
    }
    sourceFolder = projectName + File.separator + sourceFolder;

    // Setup unwrapRequired option, which makes all the properties with "required" non-optional
    if (additionalProperties.containsKey(UNWRAP_REQUIRED)) {
        setUnwrapRequired(Boolean.parseBoolean(String.valueOf(additionalProperties.get(UNWRAP_REQUIRED))));
    }
    additionalProperties.put(UNWRAP_REQUIRED, unwrapRequired);

    // Setup unwrapRequired option, which makes all the properties with "required" non-optional
    if (additionalProperties.containsKey(RESPONSE_AS)) {
        Object responseAsObject = additionalProperties.get(RESPONSE_AS);
        if (responseAsObject instanceof String) {
            setResponseAs(((String) responseAsObject).split(","));
        } else {
            setResponseAs((String[]) responseAsObject);
        }
    }
    additionalProperties.put(RESPONSE_AS, responseAs);
    if (ArrayUtils.contains(responseAs, LIBRARY_PROMISE_KIT)) {
        additionalProperties.put("usePromiseKit", true);
    }

    supportingFiles.add(new SupportingFile("Podspec.mustache", "", projectName + ".podspec"));
    supportingFiles.add(new SupportingFile("Cartfile.mustache", "", "Cartfile"));
    supportingFiles.add(new SupportingFile("APIHelper.mustache", sourceFolder, "APIHelper.swift"));
    supportingFiles.add(new SupportingFile("AlamofireImplementations.mustache", sourceFolder,
            "AlamofireImplementations.swift"));
    supportingFiles.add(new SupportingFile("Extensions.mustache", sourceFolder, "Extensions.swift"));
    supportingFiles.add(new SupportingFile("Models.mustache", sourceFolder, "Models.swift"));
    supportingFiles.add(new SupportingFile("APIs.mustache", sourceFolder, "APIs.swift"));
}

From source file:com.flexive.core.security.UserTicketImpl.java

/**
 * {@inheritDoc}
 */
@Override
public boolean isInGroup(long group) {
    return ArrayUtils.contains(groups, group);
}

From source file:net.mojodna.sprout.Sprout.java

public final void setBeanFactory(final BeanFactory factory) throws BeansException {
    if (!factory.isSingleton(beanName)) {
        log.warn(getClass().getName() + " must be defined with singleton=\"true\" in order to self-register.");
        return;//w w  w .  ja v a 2s.  com
    }

    final String pkgName = getClass().getPackage().getName();
    final String path = pkgName.substring(pkgName.indexOf(PACKAGE_DELIMITER) + PACKAGE_DELIMITER.length())
            .replace('.', '/') + "/";

    if (factory instanceof AbstractBeanFactory) {
        final AbstractBeanFactory dlbf = (AbstractBeanFactory) factory;

        final Collection<Method> methods = SproutUtils.getDeclaredMethods(getClass(), Sprout.class);

        // register beans for each url
        log.debug("Registering paths...");
        for (final Iterator<Method> i = methods.iterator(); i.hasNext();) {
            final Method method = i.next();
            String name = method.getName();
            if (Modifier.isPublic(method.getModifiers())
                    && method.getReturnType().equals(ActionForward.class)) {
                if (name.equals("publick"))
                    name = "public";
                final String url = path + name.replaceAll("([A-Z])", "_$1").toLowerCase();
                log.debug(url);
                if (!ArrayUtils.contains(dlbf.getAliases(beanName), url))
                    dlbf.registerAlias(beanName, url);
            }
        }
    } else {
        log.warn("Unable to self-register; factory bean was of an unsupported type.");
        throw new BeanNotOfRequiredTypeException(beanName, AbstractBeanFactory.class, factory.getClass());
    }
}

From source file:com.sammyun.controller.shop.LoginController.java

/**
 * ??//w w w. j a va2s.co  m
 */
@RequestMapping(value = "/loginSubmit", method = RequestMethod.POST)
public @ResponseBody Message loginSubmit(String username, HttpServletRequest request,
        HttpServletResponse response, HttpSession session) {
    String password = rsaService.decryptParameter("enPassword", request);
    rsaService.removePrivateKey(request);

    if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
        return Message.error("shop.common.invalid");
    }
    Member member;
    Setting setting = SettingUtils.get();
    if (setting.getIsEmailLogin() && username.contains("@")) {
        List<Member> members = memberService.findListByEmail(username);
        if (members.isEmpty()) {
            member = null;
        } else if (members.size() == 1) {
            member = members.get(0);
        } else {
            return Message.error("shop.login.unsupportedAccount");
        }
    } else {
        member = memberService.findByUsername(username);
    }
    if (member == null) {
        return Message.error("shop.login.unknownAccount");
    }
    if (!member.getIsEnabled()) {
        return Message.error("shop.login.disabledAccount");
    }
    boolean locked = checkLockedStatus(member, setting);
    if (locked) {
        return Message.error("shop.login.lockedAccount", setting.getAccountLockTime());
    }

    if (!DigestUtils.md5Hex(password).equals(member.getPassword())) {
        int loginFailureCount = member.getLoginFailureCount() + 1;
        if (loginFailureCount >= setting.getAccountLockCount()) {
            member.setIsLocked(true);
            member.setLockedDate(new Date());
        }
        member.setLoginFailureCount(loginFailureCount);
        memberService.update(member);
        if (ArrayUtils.contains(setting.getAccountLockTypes(), AccountLockType.member)) {
            return Message.error("shop.login.accountLockCount", setting.getAccountLockCount());
        } else {
            return Message.error("shop.login.incorrectCredentials");
        }
    }
    updateLoginStatus(request, member);

    syncCart(request, response, session, member);
    return SUCCESS_MESSAGE;
}

From source file:gda.jython.accesscontrol.ProtectedMethodComponent.java

/**
 * Analyse the given class and add any methods annotated to be protected to the protectedMethods array.
 * // ww  w . ja v  a2 s.c  om
 * @param clazz
 */
@SuppressWarnings("rawtypes")
private void analyseClass(Class clazz) {
    // loop over this classes methods
    Method[] newMethods = clazz.getMethods();
    for (Method thisMethod : newMethods) {
        if (thisMethod.isAnnotationPresent(gda.jython.accesscontrol.MethodAccessProtected.class)
                && thisMethod.getAnnotation(MethodAccessProtected.class).isProtected()) {
            addMethod(thisMethod);
        }
    }

    // loop over the interfaces the class implements
    Class[] newInterfaces = clazz.getInterfaces();
    for (Class thisInterface : newInterfaces) {
        // if its a new interface (for performance, ensure each interface only looked at once)
        if (!ArrayUtils.contains(analysedInterfaces, thisInterface)) {
            analysedInterfaces = (Class[]) ArrayUtils.add(analysedInterfaces, thisInterface);

            // check if any method in that interface is annotated that it should be protected
            for (Method method : thisInterface.getMethods()) {
                if (method.isAnnotationPresent(gda.jython.accesscontrol.MethodAccessProtected.class)
                        && method.getAnnotation(MethodAccessProtected.class).isProtected()) {
                    addMethod(method);
                }
            }
        }
    }
}

From source file:eu.dime.ps.dto.ProfileCard.java

private void addToModel(Model model, URI rUri, URI property, Object value) {
    if (ArrayUtils.contains(DATETIME_PROPERTIES, property)) {
        Calendar calendar = Calendar.getInstance();

        if (value instanceof Long) {
            calendar.setTimeInMillis((Long) value);
            value = calendar;//from w ww  .  ja va 2  s.c  om
        }
        if (value instanceof Integer) {

            if (GenericValidator.isLong(value.toString())) {
                calendar.setTimeInMillis(((Integer) value).longValue());
                value = calendar;
            }
        }

    }

    if (value instanceof String) {
        Node object = null;
        try {
            object = new URIImpl(expand((String) value));
            model.addStatement(rUri, property, object);
        } catch (IllegalArgumentException e) {
            object = model.createPlainLiteral((String) value);
            model.addStatement(rUri, property, object);
        }
    } else if (CONVERTERS.containsKey(property)) {
        model.addStatement(rUri, property, CONVERTERS.get(property).toNode(model, value));
    } else {
        model.addStatement(rUri, property, RDFReactorRuntime.java2node(model, value));
    }
}

From source file:de.themoep.clancontrol.Region.java

public List<Region> getSurroundingRegions(RegionStatus... status) {
    List<Region> regions = new ArrayList<Region>();
    for (Region r : getSurroundingRegions()) {
        if (ArrayUtils.contains(status, r.getStatus())) {
            regions.add(r);//from w w  w.j  a  v a2 s.c  om
        }
    }
    return regions;
}

From source file:gov.nih.nci.caarray.security.SecurityPolicy.java

private static boolean policiesMatch(String[] policyNames, Set<SecurityPolicy> policies) {
    for (SecurityPolicy policy : policies) {
        if (ArrayUtils.contains(policyNames, policy.getName())) {
            return true;
        }// w  w  w . java2 s.c  om
    }
    return false;
}

From source file:com.adobe.acs.commons.forms.helpers.impl.AbstractFormHelperImpl.java

/**
 * Removes unused Map entries from the provided map.
 *
 * @param form//from www . j  av a2  s  .  c  om
 * @return
 */
protected final Form clean(final Form form) {
    final Map<String, String> map = form.getData();
    final Map<String, String> cleanedMap = new HashMap<String, String>();

    for (final Map.Entry<String, String> entry : map.entrySet()) {
        if (!ArrayUtils.contains(FORM_INPUTS, entry.getKey()) && StringUtils.isNotBlank(entry.getValue())) {
            cleanedMap.put(entry.getKey(), entry.getValue());
        }
    }

    return new FormImpl(form.getName(), form.getResourcePath(), cleanedMap, form.getErrors());
}