Example usage for java.util LinkedList add

List of usage examples for java.util LinkedList add

Introduction

In this page you can find the example usage for java.util LinkedList add.

Prototype

public boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this list.

Usage

From source file:it.geosolutions.geobatch.opensdi.ndvi.NDVIIngestAction.java

/**
 * //from   w  w  w  .j a v  a2  s. c  o m
 */
public Queue<EventObject> execute(Queue<EventObject> events) throws ActionException {

    listenerForwarder.progressing(1f, "Check config");

    listenerForwarder.started();

    NDVIIngestConfiguration configuration = getConfiguration();
    if (configuration == null) {
        throw new IllegalStateException("ActionConfig is null.");
    }

    //        List<File> ndviFiles = new ArrayList<File>();
    Map<File, Calendar[]> inputFiles = new TreeMap<File, Calendar[]>();

    while (!events.isEmpty()) {
        EventObject event = events.poll();
        if (event instanceof FileSystemEvent) {
            FileSystemEvent fse = (FileSystemEvent) event;
            File source = fse.getSource();
            if (!source.exists()) {
                LOGGER.error("File does not exist: " + source);
                continue;
            }
            Calendar interval[];
            try {
                interval = parseDekDate(source.getName());
            } catch (ActionException e) {
                LOGGER.error("Error parsing source name: " + e.getMessage());
                continue;
            }

            inputFiles.put(source, interval);
        } else {
            throw new ActionException(this, "EventObject not handled " + event);
        }
    }
    listenerForwarder.progressing(10f, "Process file");
    ImageMosaicCommand imc = processFiles(inputFiles);

    LinkedList<EventObject> ret = new LinkedList<EventObject>();
    ret.add(new EventObject(imc));
    return ret;
}

From source file:com.ryan.ryanreader.cache.PersistentCookieStore.java

public synchronized boolean clearExpired(final Date date) {

    boolean purged = false;
    final LinkedList<Cookie> newSet = new LinkedList<Cookie>();

    for (final Cookie cookie : cookies) {

        if (!cookie.isExpired(date)) {
            newSet.add(cookie);
        } else {// w  w  w.  j  av a2  s .  c o  m
            purged = true;
        }
    }

    cookies = newSet;
    return purged;
}

From source file:com.rapidminer.operator.preprocessing.filter.attributes.NumericValueAttributeFilter.java

@Override
public List<ParameterType> getParameterTypes(ParameterHandler operator, InputPort inPort, int... valueTypes) {
    LinkedList<ParameterType> types = new LinkedList<ParameterType>();
    types.add(new ParameterTypeString(PARAMETER_NUMERIC_CONDITION,
            "Parameter string for the condition, e.g. '>= 5'", true, false));
    return types;
}

From source file:ltsa.jung.TreeLikeGraphLayout.java

/**
 * Computes the depths of every node by a BFS on the graph.  Stores 
 * the depth in {depths} and the maximal depth in {maxDepth}.
 *//*from w w  w  . j  a v a2 s.  c  o  m*/
protected void computeDepth() {
    if (root == null || graph == null)
        return;
    LinkedList<V> queue = new LinkedList<V>();
    queue.add(root);
    depths.put(root, 0);

    while (!queue.isEmpty()) {
        V v = queue.removeFirst(); // FIFO for BFS order

        for (V successor : graph.getSuccessors(v)) {
            if (!depths.containsKey(successor)) {
                int depth = depths.get(v) + 1;
                depths.put(successor, depth);
                if (depth > maxDepth)
                    maxDepth = depth;
                queue.add(successor);
            }
        }
    }
}

From source file:net.datapipe.CloudStack.CloudStackAPI.java

protected HttpMethod makeHttpGet(LinkedList<NameValuePair> queryValues) throws Exception {
    String query_signature = sign_request(queryValues);
    queryValues.add(new NameValuePair("signature", query_signature));

    HttpMethod method = new GetMethod(apiURL);
    method.setFollowRedirects(true);//from  w  w  w  .j  a  va  2s.c om
    method.setQueryString(queryValues.toArray(new NameValuePair[0]));

    return method;
}

From source file:de.tudarmstadt.ukp.lmf.transform.wordnet.WNConverter.java

/**
 * Converts the informations provided by the initialized WordNet-{@link Dictionary} instance to LMF-format. <br>
 * The result of the conversion can be obtained by calling {@link WNConverter#getLexicalResource()}
 *//*from ww  w .ja  va  2s. com*/
public void toLMF() {
    try {
        LOG.info("Started converting WordNet to LMF...");
        SubcategorizationFrameExtractor subcategorizationFrameExtractor = new SubcategorizationFrameExtractor(
                subcatStream);

        // Setting attributes of LexicalResource
        lexicalResource.setName("WordNet");
        lexicalResource.setDtdVersion(dtd_version);

        // *** Setting GlobalInformation *** //
        GlobalInformation globalInformation = new GlobalInformation();
        globalInformation.setLabel("LMF representation of WordNet 3.0");
        lexicalResource.setGlobalInformation(globalInformation);

        //*** Setting Lexicon (only one since WordNet is monolingual)***//
        Lexicon lexicon = new Lexicon();
        lexicon.setLanguageIdentifier(ELanguageIdentifier.ENGLISH);
        lexicon.setId("WN_Lexicon_0");
        lexicon.setName("WordNet");
        LinkedList<Lexicon> lexicons = new LinkedList<Lexicon>();
        lexicons.add(lexicon);
        lexicalResource.setLexicons(lexicons);

        // *** Creating Synsets *** //
        LOG.info("Generating Synsets...");
        SynsetGenerator synsetGenerator = new SynsetGenerator(extWordnet, resourceVersion);
        synsetGenerator.initialize();
        // Setting Synsets
        lexicon.setSynsets(synsetGenerator.getSynsets());
        LOG.info("Generating Synsets done");

        // *** Creating LexicalEntries *** //
        LOG.info("Generating LexicalEntries...");
        LexicalEntryGenerator lexicalEntryGenerator = new LexicalEntryGenerator(dictionaryPath, extWordnet,
                synsetGenerator, subcategorizationFrameExtractor, resourceVersion);
        lexicon.setLexicalEntries(lexicalEntryGenerator.getLexicalEntries());
        LOG.info("Generating LexicalEntries done");

        // *** Creating SynsetRelations *** //
        LOG.info("Generating SynsetRelations...");
        SynsetRelationGenerator synsetRelationGenerator = new SynsetRelationGenerator(synsetGenerator,
                lexicalEntryGenerator);
        // Update the relatios of previously extracted (and generated) Synsets
        synsetRelationGenerator.updateSynsetRelations();
        LOG.info("Generating SynsetRelations done");

        // *** Creating RelatedForms of LexicalEntries *** //
        LOG.info("Generating RelatedForms...");
        RelatedFormGenerator relatedFormGenerator = new RelatedFormGenerator(lexicalEntryGenerator);
        relatedFormGenerator.updateRelatedForms();
        LOG.info("Generating RelatedForms done");

        // *** Creating SenseRelations *** //
        LOG.info("Generating SenseRelations...");
        SenseRelationGenerator senseRelationGenerator = new SenseRelationGenerator(lexicalEntryGenerator);
        senseRelationGenerator.updateSenseRelations();
        LOG.info("Generating SenseRelations done");

        // *** Setting SubcategorizationFrames ***//
        lexicon.setSubcategorizationFrames(subcategorizationFrameExtractor.getSubcategorizationFrames());
        // setting SemanticPredicates
        lexicon.setSemanticPredicates(subcategorizationFrameExtractor.getSemanticPredicates());
        // setting SynSemCorrespondences
        lexicon.setSynSemCorrespondences(subcategorizationFrameExtractor.getSynSemCorrespondences());
    } catch (JWNLException e) {
        throw new RuntimeException("UBY-LMF creation failed", e);
    }
}

From source file:it.geosolutions.geobatch.nrl.ndvi.NDVIIngestAction.java

/**
 * /*from  w w w.  j  a  v a 2s  .c  om*/
 */
public Queue<EventObject> execute(Queue<EventObject> events) throws ActionException {

    listenerForwarder.setTask("Check config");

    listenerForwarder.started();

    NDVIIngestConfiguration configuration = getConfiguration();
    if (configuration == null) {
        throw new IllegalStateException("ActionConfig is null.");
    }

    //        List<File> ndviFiles = new ArrayList<File>();
    Map<File, Calendar[]> inputFiles = new TreeMap<File, Calendar[]>();

    while (!events.isEmpty()) {
        EventObject event = events.poll();
        if (event instanceof FileSystemEvent) {
            FileSystemEvent fse = (FileSystemEvent) event;
            File source = fse.getSource();
            if (!source.exists()) {
                LOGGER.error("File does not exist: " + source);
                continue;
            }
            Calendar interval[];
            try {
                interval = parseDekDate(source.getName());
            } catch (ActionException e) {
                LOGGER.error("Error parsing source name: " + e.getMessage());
                continue;
            }

            inputFiles.put(source, interval);
        } else {
            throw new ActionException(this, "EventObject not handled " + event);
        }
    }

    ImageMosaicCommand imc = processFiles(inputFiles);

    LinkedList<EventObject> ret = new LinkedList<EventObject>();
    ret.add(new EventObject(imc));
    return ret;
}

From source file:cn.vlabs.duckling.vwb.service.login.UMT2LoginAction.java

/**
 * request??xml?post?//ww w .  jav  a 2  s . c o  m
 * 
 * @throws UnkownCredentialException
 * 
 */
@Override
protected Collection<Principal> parseCredential() throws UnkownCredentialException {
    String signedCredential = request.getParameter("signedCredential");
    if (umtKey == null) {
        downloadUMTKey(request);
        loadUMTKeyFromLocal(request);
    }
    if (umtKey != null) {
        if (StringUtils.isNotEmpty(signedCredential)) {
            try {
                signedCredential = Base64Util.decodeBase64(signedCredential);
                SignedEnvelope signedData = SignedEnvelope.valueOf(signedCredential);
                if (signedData.verify(umtKey)) {
                    UserPrincipal user = UserCredentialEnvelope.valueOf(signedData.getContent()).getUser();
                    String name = user.getName();
                    String voName = getVwbcontext().getProperty("duckling.umt.vo");
                    List<Principal> principals = VWBContainerImpl.findContainer().getUserService()
                            .getUserPrincipal(name, voName);
                    addUserToSiteByCheckFlag(principals, name, user.getDisplayName());
                    if (principals != null && principals.size() > 0) {
                        replaceUserPrincipal(principals, user);
                        return principals;
                    } else {
                        LinkedList<Principal> result = new LinkedList<Principal>();
                        result.add(user);
                        return result;
                    }
                }
            } catch (Throwable e) {
                e.printStackTrace();
                throw new UnkownCredentialException("Error:signedCredential is incorrect");
            }

        } else {
            throw new UnkownCredentialException("Error:signedCredential is empty");
        }
    }
    return null;
}

From source file:voldemort.ServerTestUtils.java

/**
 * Given zone ids, this method returns a list of zones with their proximity
 * list/*from  ww w  . ja  v a2 s. com*/
 * 
 * @param list of zone ids
 * @return List of zones
 */
public static List<Zone> getZones(int numberOfZones) {
    List<Zone> zones = Lists.newArrayList();
    for (int i = 0; i < numberOfZones; i++) {
        LinkedList<Integer> proximityList = Lists.newLinkedList();
        int zoneId = i + 1;
        for (int j = 0; j < numberOfZones; j++) {
            if (zoneId % numberOfZones != i) {
                proximityList.add(zoneId % numberOfZones);
            }
            zoneId++;
        }
        zones.add(new Zone(i, proximityList));
    }
    return zones;
}

From source file:org.matsim.contrib.parking.parkingchoice.lib.GeneralLib.java

public static LinkedList<String> readFileRows(String fileName) {
    LinkedList<String> list = new LinkedList<String>();

    try {/*  w w w  .  j a  va2s . com*/

        FileInputStream fis = new FileInputStream(fileName);
        InputStreamReader isr = new InputStreamReader(fis, "ISO-8859-1");

        BufferedReader br = new BufferedReader(isr);
        String line;
        line = br.readLine();
        while (line != null) {
            list.add(line);
            line = br.readLine();
        }
    } catch (Exception e) {
        e.printStackTrace();
        DebugLib.stopSystemAndReportInconsistency();
    }

    return list;
}