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:jp.go.nict.langrid.management.web.view.page.language.component.form.panel.RepeatingLanguagePathPanel.java

/**
 * //w w  w  . j  a  v a 2  s.c  o  m
 * 
 */
public void setValueModel(LanguagePathModel model, String metaKey) {
    initialize(metaKey);
    if (pathType.equals(LanguagePathType.UNKNOWN)) {
        Iterator it = repeater.iterator();
        while (it.hasNext()) {
            OtherLanguagePathPanel path = (OtherLanguagePathPanel) it.next();
            StringBuilder sb = new StringBuilder();
            for (String s : model.getOtherLanguages()) {
                sb.append(s);
                sb.append(" ");
            }
            path.setValue(sb.toString());
        }
        return;
    }
    if (pathType.equals(LanguagePathType.COMBINATION)) {
        LanguagePath lp = model.getCombinationPathArray()[0];
        repeater.removeAll();
        for (int i = 0; i < lp.getPath().length; i++) {
            setLanguagePathComponents(repeater, metaKey);
        }
        int i = 0;
        Iterator it = repeater.iterator();
        while (it.hasNext()) {
            SingleLanguagePathPanel panel = (SingleLanguagePathPanel) it.next();
            panel.setPathValue(new LanguagePath(lp.getPath()[i++]), false);
            if (1 < repeater.size()) {
                panel.setAllVisibled();
            }
        }
        return;
    }
    LanguagePath[] paths = model.getAllPath();
    Map<LanguagePath, Boolean> map = new LinkedHashMap<LanguagePath, Boolean>();
    for (LanguagePath path : paths) {
        boolean isBidirection = ArrayUtils.contains(paths, path.reverse());
        if (isBidirection && path.equals(path.reverse())) {
            isBidirection = false;
        }
        if (map.containsKey(path.reverse())) {
            continue;
        }
        map.put(path, isBidirection);
    }
    if (map.size() == 0) {
        map.put(new LanguagePath(InternalLanguageModel.getWildcard()), false);
    }
    int count = map.size();
    if (isCombinaitionLanguagePathType()) {
        count -= 1;
    }
    repeater.removeAll();
    for (int i = 0; i < count; i++) {
        setLanguagePathComponents(repeater, metaKey);
    }
    Iterator it = repeater.iterator();
    Iterator<LanguagePath> valueIt = map.keySet().iterator();
    while (it.hasNext()) {
        AbstractLanguagePathPanel panel = (AbstractLanguagePathPanel) it.next();
        LanguagePath path = valueIt.next();
        panel.setPathValue(path, map.get(path));
        if (1 < repeater.size()) {
            panel.setAllVisibled();
        }
    }
}

From source file:es.tena.foundation.util.POIUtil.java

/**
 * Devuelve si en el array de bytes se encuentra algn valor no permitido
 *
 * @param bs/*from   www  .  j  av a 2s. c  om*/
 * @return
 */
private static boolean contieneCaracteresNoPermitidos(byte[] bs) {
    for (byte b : bytesNotAllowed) {
        if (ArrayUtils.contains(bs, b)) {
            return true;
        }
    }
    return false;
}

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

/**
 * {@inheritDoc}/* w  w  w .  j  ava2  s. c  om*/
 */
@Override
public boolean isInGroups(int groups[]) {
    if (groups == null || groups.length == 0) {
        return true;
    }
    for (int group : groups) {
        if (!ArrayUtils.contains(this.groups, (long) group)) {
            return false;
        }
    }
    return true;
}

From source file:de.iteratec.iteraplan.businesslogic.reports.query.options.GraphicalReporting.InformationFlow.InformationFlowOptionsBean.java

public boolean isAttributeLineCaption() {
    return ArrayUtils.contains(selectionType, LINE_DESCR_ATTRIBUTES);
}

From source file:gda.gui.scriptcontroller.logging.ScriptControllerLogContentProvider.java

private void addToKnownScripts(String scriptName) {
    if (!ArrayUtils.contains(knownScripts, scriptName)) {
        knownScripts = (String[]) ArrayUtils.add(knownScripts, scriptName);
        view.updateFilter(knownScripts);
    }/*from   w  ww.  j a  v  a 2  s  . c  o m*/
}

From source file:net.firejack.platform.core.store.registry.resource.ResourceVersionStore.java

private void copyResourceVersionProperties(RV dest, RV orig) {
    PropertyUtilsBean propertyUtils = BeanUtilsBean.getInstance().getPropertyUtils();
    PropertyDescriptor[] propertyDescriptors = propertyUtils.getPropertyDescriptors(orig);
    for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
        String name = propertyDescriptor.getName();
        if (ArrayUtils.contains(new String[] { "class", "id", "version", "status", "updated", "created" },
                name)) {/*from   w  w  w .j  a v a  2  s  .  c  o  m*/
            continue;
        }
        if (propertyUtils.isReadable(orig, name) && propertyUtils.isWriteable(dest, name)) {
            try {
                Object value = propertyUtils.getSimpleProperty(orig, name);
                if (value instanceof Timestamp) {
                    value = ConvertUtils.convert(value, Date.class);
                }
                BeanUtils.copyProperty(dest, name, value);
            } catch (Exception e) {
                // Should not happen
            }
        }
    }
}

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

/**
 * <??>????????<??>/* ww w  .ja va  2 s .  c  om*/
 * 
 * @param member
 * @param setting
 * @see [?#?#?]
 */
protected boolean checkLockedStatus(Member member, Setting setting) {
    if (!member.getIsLocked()) {
        return false;
    }
    boolean needUpdate = false;
    if (ArrayUtils.contains(setting.getAccountLockTypes(), AccountLockType.member)) {
        int loginFailureLockTime = setting.getAccountLockTime();
        if (loginFailureLockTime == 0) {
            return false;
        }
        Date lockedDate = member.getLockedDate();
        Date unlockDate = DateUtils.addMinutes(lockedDate, loginFailureLockTime);
        if (new Date().after(unlockDate)) {
            needUpdate = true;
        }
    } else {
        needUpdate = true;
    }
    if (needUpdate) {
        member.setLoginFailureCount(0);
        member.setIsLocked(false);
        member.setLockedDate(null);
        memberService.update(member);
        return false;
    }
    return true;
}

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

/**
 * {@inheritDoc}/*from   ww  w . ja  v  a2 s  .  c  o m*/
 */
@Override
public boolean isInAtLeastOneGroup(long[] groups) {
    if (groups == null || groups.length == 0) {
        return false;
    }
    for (long group : groups) {
        if (ArrayUtils.contains(this.groups, group)) {
            return true;
        }
    }
    return false;
}

From source file:com.apporiented.hermesftp.server.impl.ServerRFC959Test.java

/**
 * Test case: Block transfer, record structures.
 *//*from w ww  .  j a va  2 s  .  c om*/
@Test
public void testBlockTransfer() {
    try {
        byte[] data = createBlockData();
        String str = getClient().sendAndReceive("MODE B");
        assertTrue(str.startsWith("200"));
        str = getClient().sendAndReceive("STRU R");
        assertTrue(str.startsWith("200"));
        str = getClient().sendAndReceive("TYPE E");
        assertTrue(str.startsWith("200"));
        str = getClient().storeRaw(testFile, data);
        assertTrue(str.startsWith("226"));

        getClient().sendAndReceive("MODE S");
        getClient().sendAndReceive("STRU F");
        getClient().retrieveText(testFile);
        str = getClient().getTextData();
        String br = System.getProperty("line.separator");
        assertTrue(str.startsWith("ABBB" + br + "CCCCCCCC"));

        getClient().sendAndReceive("MODE S");
        getClient().sendAndReceive("STRU R");
        getClient().retrieveRaw(testFile);
        byte[] raw = getClient().getRawData();
        assertTrue(ArrayUtils.contains(raw, (byte) 0xFF));

        getClient().sendAndReceive("MODE B");
        getClient().sendAndReceive("STRU R");
        getClient().sendAndReceive("TYPE E");
        getClient().retrieveRaw(testFile);
        raw = getClient().getRawData();
        assertTrue(Arrays.equals(ArrayUtils.subarray(raw, 0, 11), new byte[] { -128, 0, 4, (byte) 0xC1,
                (byte) 0xC2, (byte) 0xC2, (byte) 0xC2, -64, 1, 2, (byte) 0xC3 }));
        getClient().sendAndReceive("DELE " + testFile);
    } catch (IOException e) {
        log.error(e);
    }

}

From source file:com.blockwithme.longdb.tools.DBTool.java

/** Returns format of files to be imported by import command. If format
 * option is not specified and input source is a 'file' then format is read
 * from file extension. Formats should be one of the elements in
 * VALIDFORMATS array. *///ww  w . jav  a  2 s. c  o m
private static String getFormat(final String theFile) {
    String format = optionVal(DATA_FORMAT, true);
    if (format == null) {
        final File fl = new File(theFile); // $codepro.audit.disable
                                           // com.instantiations.assist.eclipse.analysis.pathManipulation
        if (fl.exists() && !fl.isFile()) {
            final int mid = theFile.lastIndexOf('.');
            format = theFile.substring(mid + 1, theFile.length());
        }
    }
    if (format == null)
        invalidCommand("File format not specified. Use -f option for file format");
    if (!ArrayUtils.contains(VALIDFORMATS, format))
        invalidCommand("Valid file formats are :" + Arrays.toString(VALIDFORMATS));
    return format;
}