Example usage for java.util List contains

List of usage examples for java.util List contains

Introduction

In this page you can find the example usage for java.util List contains.

Prototype

boolean contains(Object o);

Source Link

Document

Returns true if this list contains the specified element.

Usage

From source file:com.alfresco.orm.ORMUtil.java

/**
 * //  w w  w  .  ja va  2s.com
 * @param alfrescoContent
 * @param properties
 * @param nodeService
 * @param restrictedPropertiesForUpdate
 * @throws NoSuchMethodException
 * @throws IllegalAccessException
 * @throws InvocationTargetException
 * @throws ORMException
 */
public static void saveProperties(final AlfrescoContent alfrescoContent,
        final Map<QName, Serializable> properties, final NodeService nodeService,
        final List<String> restrictedPropertiesForUpdate)
        throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ORMException {
    NodeRef nodeRef = getNodeRef(alfrescoContent);
    Map<QName, Serializable> propertiesFinal = new HashMap<QName, Serializable>(properties.size());
    for (Entry<QName, Serializable> prop : properties.entrySet()) {
        if (!restrictedPropertiesForUpdate.contains(prop.getKey().getLocalName())) {
            propertiesFinal.put(prop.getKey(), prop.getValue());
        }
    }

    nodeService.setProperties(nodeRef, properties);
}

From source file:es.bsc.vmm.ascetic.rest.rest.GenericVmManagerRestV1Test.java

@AfterClass
public static void tearDownAfterClass() {
    // Make sure that all the VMs that existed before the tests are still there
    List<String> idsVmsDeployedAfterTests = getIdsExistingVms();
    for (String idVmDeployedBeforeTests : idsVmsDeployedBeforeTests) {
        assertTrue(idsVmsDeployedAfterTests.contains(idVmDeployedBeforeTests));
    }/*from  w  w w  . j ava2 s  .  c  o  m*/

    // Make sure that all the VMs created during the tests have been deleted
    assertTrue(idsVmsDeployedAfterTests.size() == idsVmsDeployedBeforeTests.size());
}

From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java

/**
 * Add "" to the list in the first spot if it's not already there. Removes
 * it and put's it in the first spot if it is.
 *//*ww  w  . ja v  a  2 s .co  m*/
private static void addBlankOption(List inList) {

    DropdownOption theDropdownOption = new DropdownOption("", "");

    if (!inList.contains(theDropdownOption)) {
        inList.add(0, theDropdownOption);
    } else {
        inList.remove(theDropdownOption);
        inList.add(0, theDropdownOption);
    }
}

From source file:at.gv.egovernment.moa.id.auth.builder.LoginFormBuilder.java

public static String buildLoginForm(String modul, String action, OAAuthParameter oaParam, String contextpath,
        String moaSessionID) {//from w  ww. j  a  v a2  s . c o m

    String value = null;

    byte[] oatemplate = oaParam.getBKUSelectionTemplate();
    // OA specific template requires a size of 8 bits minimum
    if (oatemplate != null && oatemplate.length > 7) {
        InputStream is = new ByteArrayInputStream(oatemplate);
        value = getTemplate(is);

    } else {
        //load default BKU-selection template
        value = getTemplate();

    }

    if (value != null) {
        if (modul == null) {
            modul = SAML1Protocol.PATH;
        }
        if (action == null) {
            action = SAML1Protocol.GETARTIFACT;
        }
        value = value.replace(MODUL, modul);
        value = value.replace(ACTION, action);
        value = value.replace(OANAME, oaParam.getFriendlyName());
        value = value.replace(CONTEXTPATH, contextpath);
        value = value.replace(MOASESSIONID, moaSessionID);

        if (oaParam.isShowStorkLogin()) {
            String pepslist = "";
            List<CPEPS> cpepsList = null;
            try {
                cpepsList = ConfigurationDBRead.getMOAIDConfiguration().getAuthComponentGeneral()
                        .getForeignIdentities().getSTORK().getCPEPS();

                for (CPEPS current : oaParam.getPepsList())
                    // check if master config has changed...
                    if (cpepsList != null && cpepsList.contains(current)) {
                        String countryName = null;
                        if (MiscUtil.isNotEmpty(MOAIDAuthConstants.COUNTRYCODE_XX_TO_NAME
                                .get(current.getCountryCode().toUpperCase())))
                            countryName = MOAIDAuthConstants.COUNTRYCODE_XX_TO_NAME
                                    .get(current.getCountryCode().toUpperCase());
                        else
                            countryName = current.getCountryCode().toUpperCase();

                        pepslist += "<option value=" + current.getCountryCode() + ">" + countryName
                                + "</option>\n";

                    }

                value = value.replace(PEPSLIST, pepslist);

            } catch (NullPointerException e) {

            }
        }

        value = FormBuildUtils.customiceLayoutBKUSelection(value, oaParam.isShowMandateCheckBox(),
                oaParam.isOnlyMandateAllowed(), oaParam.getFormCustomizaten(), oaParam.isShowStorkLogin());

    }
    return value;
}

From source file:com.edgenius.core.dao.hibernate.UserDAOHibernate.java

/**
 * Utility method to set INSTANCE permission into <code>wikiPermissions</code>.
 * @param wikiPermissions//from   w  ww.  j av  a  2s . c  o m
 * @param perms
 */
public static void getInstancePermission(List<OPERATIONS> wikiPermissions, Set<Permission> perms) {
    if (perms == null) {
        AuditLogger.warn("The role/user instance permission is null");
        return;
    }
    for (Permission permission : perms) {
        if (RESOURCE_TYPES.INSTANCE.equals(permission.getResource().getType())) {
            //don't contain duplicated operations
            if (!wikiPermissions.contains(permission.getOperation()))
                wikiPermissions.add(permission.getOperation());
        }
    }
}

From source file:main.java.spatialrelex.Evaluator.java

/**
 * //www.j  a va 2  s  . co m
 * @param test
 * @param result
 * @param fileTriggerMoverRoleOtherElement
 * @param roleName
 * @return 
 */
public static Map<String, Map<String, List<String>>> getMovelinkSubpart(String[] test, String[] result,
        Map<String, Map<String, List<String>>> fileTriggerMoverRoleOtherElement, String roleName) {

    for (int i = 0; i < test.length; i++) {
        double r = Double.parseDouble(result[i].trim());
        String[] testTokens = test[i].trim().split("\\s");

        String key = testTokens[testTokens.length - 1];
        String element = key.substring(0, key.lastIndexOf("-"));
        String roleElement = key.substring(key.lastIndexOf("-") + 1);

        if (r >= 0.0 && fileTriggerMoverRoleOtherElement.containsKey(element)) {
            Map<String, List<String>> roleOtherElement = fileTriggerMoverRoleOtherElement.get(element);

            if (roleOtherElement == null)
                fileTriggerMoverRoleOtherElement.put(element, roleOtherElement = new HashMap<>());

            List<String> elements = roleOtherElement.get(roleName);
            if (elements == null)
                roleOtherElement.put(roleName, elements = new ArrayList<>());
            if (!elements.contains(roleElement))
                elements.add(roleElement);
        }
    }

    return fileTriggerMoverRoleOtherElement;
}

From source file:org.jdal.vaadin.ui.FormUtils.java

/**
 * Fill combo with a list of objeces./*from  www.  ja v  a  2s.c o  m*/
 * @param data list to fill with.
 * @param clear true if clear all items before adding new ones.
 */
public static void fillCombo(ComboBox combo, List<?> data, boolean clear) {
    Object selected = combo.getValue();

    if (clear) {
        combo.removeAllItems();
    }

    for (Object o : data) {
        combo.addItem(o);
    }

    if (data.contains(selected))
        combo.setValue(selected);
}

From source file:de.alpharogroup.collections.ListExtensions.java

/**
 * The Method looks at both List and if they have same objects they are added to one List and
 * will returns the result.//w w  w.j av  a 2 s  .  com
 *
 * @param <T>
 *            the generic type
 * @param toSearch
 *            The List to search.
 * @param search
 *            The List to inspect.
 * @return The List with the same objects.
 */
public static <T> List<T> getSameElementsFromLists(final List<T> toSearch, final List<T> search) {
    List<T> foundElements = null;
    final int size = toSearch.size();
    for (int i = 0; i < size; i++) {
        final T element = toSearch.get(i);
        if (search.contains(element)) {
            if (foundElements == null) {
                foundElements = new ArrayList<>();
            }
            foundElements.add(element);
        }
    }
    return foundElements;
}

From source file:tsapalos.bill.play4share.UrlUtils.java

public static List<String> exportVideoUrl(String pageSource) throws NullPointerException {
    final String youtube = "YouTube", dailymotion = "Dailymotion", liveleak = "LiveLeak", vimeo = "Vimeo",
            gag9 = "9gag.tv";
    Map<String, List<String>> indices = new HashMap<String, List<String>>(3);
    final String[] start = new String[] { "data-videoid=\"", ".youtube.com/embed/", ".youtube.com/watch?v=",
            ".youtube.com/v/", ".dailymotion.com/video/", //4
            "liveleak.com/ll_embed?f=", //5
            "player.vimeo.com/video/", //6
            "data-first-video=\"", //7
            "img.youtube.com/vi/", //8
            "data-external-id=\"" //9

    };/*w ww. j  a v a2  s. c  o  m*/
    final int[] start_advance = new int[] { 14, 19, 21, 15, 23, //4
            24, //5
            23, //6
            18, //7
            19, //8
            18 //9
    };
    final String[] end = new String[] { "\"", "\'", "/" //8

    };
    String videoUrl = null, videoId = null, server = null;
    boolean found = false;

    for (int i = 0; i < start.length; i++) {
        for (int j = 0; j < end.length; j++) {
            if (pageSource.contains(start[i])) {
                // find all occurrences of the specific string
                int index = pageSource.indexOf(start[i]);
                while (index >= 0) {
                    // sniff the possible start of the url of the
                    // video
                    videoUrl = pageSource.substring(index + start_advance[i]);
                    // use this check to avoid StringIndexOutOfBoundsException if string does not exist
                    // then sniff the possible end of the url of the video
                    if (videoUrl.contains(end[j])) {
                        videoUrl = videoUrl.substring(0, videoUrl.indexOf(end[j]));
                    } else {
                        break;
                    }
                    videoId = retrieveVideoId(videoUrl);
                    // store every video id found
                    if (videoId != null) {
                        switch (i) {
                        case 4:
                            server = dailymotion;
                            break;
                        case 5:
                            server = liveleak;
                            break;
                        case 6:
                            server = vimeo;
                            break;
                        default:
                            server = youtube;
                            break;
                        }
                        List<String> currentValue = indices.get(server);
                        if (currentValue == null) {
                            currentValue = new ArrayList<String>();
                            indices.put(server, currentValue);
                        }
                        if (!currentValue.contains(videoId)) {
                            currentValue.add(videoId);
                        }
                    }
                    index = pageSource.indexOf(start[i], index + 1);
                }
            }
        }
    }
    // create the list with all videos' urls
    List<String> videosUrls = new ArrayList<String>(3);
    // convert every video id to appropriate url
    for (Map.Entry<String, List<String>> entry : indices.entrySet()) {
        if (entry != null) {
            List<String> videosIds = entry.getValue();
            found = true;
            // create the video URL according to the server
            if (entry.getKey().equals(dailymotion)) {
                for (int j = 0; j < videosIds.size(); j++) {
                    videoId = videosIds.get(j);
                    videosIds.set(j, "http://www.dailymotion.com/video/" + videoId);
                    // Log.e("DAILYMOTION-" + j, videosIds.get(j));
                    // add the url to the total list
                    videosUrls.add(videosIds.get(j));
                }
            } else if (entry.getKey().equals(liveleak)) {
                for (int j = 0; j < videosIds.size(); j++) {
                    videoId = videosIds.get(j);
                    videosIds.set(j, "http://www.liveleak.com/ll_embed?f=" + videoId);
                    // Log.e("LIVELEAK-" + j, videosIds.get(j));
                    // add the url to the total list
                    videosUrls.add(videosIds.get(j));
                }
            } else if (entry.getKey().equals(vimeo)) {
                for (int j = 0; j < videosIds.size(); j++) {
                    videoId = videosIds.get(j);
                    videosIds.set(j, "http://player.vimeo.com/video/" + videoId);
                    // Log.e("VIMEO-" + j, videosIds.get(j));
                    // add the url to the total list
                    videosUrls.add(videosIds.get(j));
                }
            } else {
                for (int j = 0; j < videosIds.size(); j++) {
                    videoId = videosIds.get(j);
                    videosIds.set(j, "http://www.youtube.com/watch?v=" + videoId);
                    // Log.e("YOUTUBE-" + j, videosIds.get(j));
                    // add the url to the total list
                    videosUrls.add(videosIds.get(j));
                }
            }
        }
    }
    // throw exception if no video found
    if (!found)

    {
        throw new NullPointerException("No videos found");
    }

    return videosUrls;
}

From source file:be.fedict.eid.applet.service.signer.odf.ODFUtil.java

public static boolean checkNodes(NodeList nodes, List zipEntries) {
    for (int i = 0; i < nodes.getLength(); i++) {
        String url = nodes.item(i).getNodeValue();
        if ("".equals(url)) {
            LOG.debug("Skip empty xlink:href");
            continue;
        }/*from w ww .jav a  2  s  . com*/
        if (url.startsWith("./")) {
            url = url.substring(2);
        }
        /* check if inside package or not */
        if (!zipEntries.contains(url)) {
            LOG.debug("Not self-contained: " + url + " outside package");
            return false;
        }
    }
    return true;
}