Example usage for java.util Vector get

List of usage examples for java.util Vector get

Introduction

In this page you can find the example usage for java.util Vector get.

Prototype

public synchronized E get(int index) 

Source Link

Document

Returns the element at the specified position in this Vector.

Usage

From source file:edu.duke.cabig.c3pr.web.security.SecureWebServiceHandler.java

/**
 * @param message//from  www . j  av  a 2s. c om
 * @return
 * @throws RuntimeException
 */
private SAMLAssertion extractSAMLAssertion(SoapMessage message) throws RuntimeException {
    List<Object> results = CastUtils.cast((List) message.get(WSHandlerConstants.RECV_RESULTS));
    if (CollectionUtils.isEmpty(results)) {
        throw new RuntimeException(SAML_TOKEN_HAS_NOT_BEEN_PRODUCED_BY_WSS4J_INTERCEPTOR);
    }
    WSHandlerResult wsHandlerResult = (WSHandlerResult) results.get(0);

    // Note: when the outbound action is ST_SIGNED
    // (SamlTokenSigned), the
    // results list is a ST_UNSIGNED because the SAML processor and
    // signature processors don't indicate if the assertion was used
    // to
    // sign the message or not so you get signature results and
    // ST_UNSIGNED
    // results even if the assertion was used to sign the message.
    final Vector<WSSecurityEngineResult> samlResults = new Vector<WSSecurityEngineResult>();
    WSSecurityUtil.fetchAllActionResults(wsHandlerResult.getResults(), WSConstants.ST_UNSIGNED, samlResults);
    if (CollectionUtils.isEmpty(samlResults)) {
        throw new RuntimeException(SAML_TOKEN_HAS_NOT_BEEN_PRODUCED_BY_WSS4J_INTERCEPTOR);
    }

    final WSSecurityEngineResult result = samlResults.get(0);
    SAMLAssertion samlAssertion = (SAMLAssertion) result.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
    if (samlAssertion == null) {
        throw new RuntimeException(SAML_TOKEN_HAS_NOT_BEEN_PRODUCED_BY_WSS4J_INTERCEPTOR);
    }
    return samlAssertion;
}

From source file:com.pandoroid.pandora.PandoraRadio.java

/**
 * Description: Gets a list of songs to be played. This function should not
 *    be called more frequently than MIN_TIME_BETWEEN_PLAYLIST_CALLS allows
 *    or an error will result.//from   w w w  .  j av  a2 s  .  c  o  m
 * @param station_token -A string representing the station's unique 
 *    identification token.
 * @throws RPCException when a Pandora RPC error has occurred.
 * @throws IOException when Pandora's remote servers could not be reached.
 * @throws HttpResponseException when an unexpected HTTP response occurs.
 * @throws Exception when an improper call has been made, or an unexpected 
 *    error occurs.
 */
@SuppressWarnings("unchecked")
public Vector<Song> getPlaylist(String station_token)
        throws RPCException, IOException, HttpResponseException, Exception {

    //This protects against a temporary account suspension from too many 
    //playlist requests.
    if (!isGetPlaylistCallValid(station_token)) {
        throw new Exception("Playlist calls are too frequent");
    }

    if (!this.isUserAuthorized()) {
        throw new Exception("Improper call to getPlaylist(), " + "the user has not been logged in yet.");
    }

    Vector<Song> songs = new Vector<Song>();

    Map<String, Object> request_args = new HashMap<String, Object>();
    request_args.put("stationToken", station_token);

    //Order matters in this URL request. The same order given here is 
    //the order received.
    request_args.put("additionalAudioUrl", MP3_128 + "," + AAC_32);

    JSONObject response = this.doCall("station.getPlaylist", request_args, true, true, null);

    JSONArray songs_returned = response.getJSONArray("items");
    for (int i = 0; i < songs_returned.length(); ++i) {
        Map<String, Object> song_data = JSONHelper.toMap(songs_returned.getJSONObject(i));
        ArrayList<PandoraAudioUrl> audio_url_mappings = new ArrayList<PandoraAudioUrl>();
        if (song_data.get("additionalAudioUrl") instanceof Vector<?>) {
            Vector<String> audio_urls = (Vector<String>) song_data.get("additionalAudioUrl");

            //This has to be in the same order as the request.
            audio_url_mappings.add(new PandoraAudioUrl(MP3_128, 128, audio_urls.get(0)));
            audio_url_mappings.add(new PandoraAudioUrl(AAC_32, 32, audio_urls.get(1)));
        }
        //MP3_192 data
        if (isPandoraOneCredentials()) {
            audio_url_mappings.add(new PandoraAudioUrl(
                    (Map<String, Object>) ((Map<String, Object>) song_data.get("audioUrlMap"))
                            .get("highQuality")));
        }
        //AAC_64 data
        audio_url_mappings.add(
                new PandoraAudioUrl((Map<String, Object>) ((Map<String, Object>) song_data.get("audioUrlMap"))
                        .get("mediumQuality")));
        songs.add(new Song(song_data, audio_url_mappings));
    }

    this.last_acquired_playlist_time = System.currentTimeMillis() / 1000L;
    this.last_acquired_playlist_station = station_token;

    return songs;
}

From source file:net.sf.javaml.clustering.AQBC.java

/**
 * Return a vector with all instances that have their index in the indices
 * vector./*  www  .j a  v  a2  s  .co  m*/
 * 
 * @param instances
 * @param indices
 * @return
 */
private Vector<TaggedInstance> select(Vector<TaggedInstance> instances, Vector<Integer> indices) {
    Vector<TaggedInstance> out = new Vector<TaggedInstance>();
    for (Integer index : indices) {
        out.add(instances.get(index));
    }
    return out;
}

From source file:com.livinglogic.ul4.Color.java

public Color abslum(double f) {
    Vector<Double> v = hlsa();
    return fromhls(v.get(0), v.get(1) + f, v.get(2), v.get(3));
}

From source file:com.livinglogic.ul4.Color.java

public Color rellum(double f) {
    Vector<Double> v = hlsa();
    double newlum = v.get(1);
    if (f > 0)
        newlum += (1 - newlum) * f;/*from ww w .  java  2  s . co m*/
    else if (f < 0)
        newlum += newlum * f;
    return fromhls(v.get(0), newlum, v.get(2), v.get(3));
}

From source file:de.mogwai.common.web.component.renderkit.html.common.TableRenderer.java

protected void renderFooter(FacesContext aContext, ResponseWriter aWriter, TableComponent aComponent,
        Vector<UIColumn> aColumns) throws IOException {

    if (!aComponent.isShowFooter()) {
        return;//from  w  ww .j  a  v  a  2s .  c  o m
    }

    GridbagLayoutSizeDefinitionVector theCols = aComponent.getCols();

    aWriter.startElement("tr", aComponent);

    if (aComponent.isUseStyles()) {
        aWriter.writeAttribute("class", "mogwaiTableFooterRow", null);
    }

    for (int i = 0; i < aColumns.size(); i++) {

        UIComponent theColumn = aColumns.get(i);

        aWriter.startElement("th", aComponent);

        if (aComponent.isUseStyles()) {
            aWriter.writeAttribute("class",
                    (i == aColumns.size() - 1) ? "mogwaiTableFooterCellLast" : "mogwaiTableFooterCell", null);
        }
        aWriter.writeAttribute("align", theCols.get(i).getAlign(), null);

        renderChildAndCheckEmptyness(aContext, theColumn.getFacet("footer"));

        aWriter.endElement("th");
    }

    aWriter.endElement("tr");

}

From source file:imapi.IMAPIClass.java

public int performComparison(Hashtable<Float, Vector<ResultSourceTargetPair>> resultInstances) {

    //Utilities//from ww  w  .  j  av  a  2 s.co m
    DataRetrievalOperations retrieveData = new DataRetrievalOperations(this);
    BaseComparisonClass compClass = new BaseComparisonClass(this);

    //Internal structures used        
    SourceDataHolder inputSourceInfo = new SourceDataHolder();
    Hashtable<SourceTargetPair, SequenceSimilarityResultVector> pairSimilaritiesInSequences = new Hashtable<SourceTargetPair, SequenceSimilarityResultVector>();

    //If Comaprison with online database is selected check if it is avaliable
    if (this.userConfig.getComparisonMode() != ApiConstants.TargetSourceChoice.FILE_COMPARISON) {

        OnlineDatabase db = this.conf.getOnlineDb(this.userConfig.getComparisonMode());

        if (db == null) {
            this.setErrorMessage(ApiConstants.IMAPIFailCode, "Not supported Database");
            return ApiConstants.IMAPIFailCode;
        }

        OnlineDatabaseActions qSource = new OnlineDatabaseActions(this, db);
        int ret = qSource.checkIfDBisAvailable();
        if (ret != ApiConstants.IMAPISuccessCode) {
            return ret;
        }
    }

    //retrieve all needed namespaces from internet
    Hashtable<String, Model> allRetrievedModels = retrieveData.retrieveAllDeclaredNamespacesModels();

    //read Source Files info
    Vector<CidocCrmCompatibleFile> inputFiles = this.userConfig.getSourceInputFiles();
    for (int inputFileIndex = 0; inputFileIndex < inputFiles.size(); inputFileIndex++) {

        CidocCrmCompatibleFile inputFile = inputFiles.get(inputFileIndex);
        try {
            int ret = retrieveData.retrieveDataFrom_SourceFile(inputFile, allRetrievedModels, inputSourceInfo);

            if (ret != ApiConstants.IMAPISuccessCode) {
                return ret;
            }
        } catch (FileNotFoundException ex) {
            Utilities.handleException(ex);
            return ApiConstants.IMAPIFailCode;
        }
        if (inputFileIndex < (inputFiles.size() - 1))
            ;
        System.out.println("=======================================");
    }

    int totalNumberOfSourceInstanceValuesFound = 0;
    Enumeration<String> fileEnum = inputSourceInfo.keys();
    while (fileEnum.hasMoreElements()) {
        String fpath = fileEnum.nextElement();
        totalNumberOfSourceInstanceValuesFound += inputSourceInfo.get(fpath).keySet().size();
    }

    //print what data was found in source files
    System.out.println("\n\n============================================================");
    System.out.println("============================================================");
    System.out.println("============================================================");
    System.out.println("Found " + totalNumberOfSourceInstanceValuesFound
            + " instances in all \"\"SOURCE\"\" input files.");
    printSourceInfo(inputSourceInfo);

    /*
    if(IMAPIClass.DEBUG){
            
    if(inputSourceInfo!=null){
        System.out.println("Found: " + inputSourceInfo.size() +" instances.");
        return ApiConstants.IMAPISuccessCode;
    }
    }
            
    */
    //make an analysis if quick method can be followed
    Utilities u = new Utilities(this);
    Vector<Boolean> canQuickFilteringMethodBeFollowedForeachSequence = new Vector<Boolean>();
    u.canAllSequencesFollowFastApproach(this.userConfig.getUserQueriesCopy(), inputSourceInfo,
            canQuickFilteringMethodBeFollowedForeachSequence);

    //Read Info from Target Files or Online Database
    System.out.println("\n=======================================");
    System.out.println("=======================================");
    System.out.println("=======================================\n\n");

    ApiConstants.TargetSourceChoice comparisonChoice = this.userConfig.getComparisonMode();
    System.out.println("Starting queries on TARGET source: " + comparisonChoice.toString() + "\n\n");
    boolean targetDataCollectedCorrectly = false;
    switch (comparisonChoice) {
    case FILE_COMPARISON: {
        Vector<CidocCrmCompatibleFile> targetFiles = this.userConfig.getTargetInputFiles();
        for (int targetFileIndex = 0; targetFileIndex < targetFiles.size(); targetFileIndex++) {

            CidocCrmCompatibleFile targetFile = targetFiles.get(targetFileIndex);
            try {
                int ret = retrieveData.retrieveDataFrom_TargetFileAndCollectSimilarities(targetFile,
                        allRetrievedModels, inputSourceInfo, canQuickFilteringMethodBeFollowedForeachSequence,
                        pairSimilaritiesInSequences);
                if (ret == ApiConstants.IMAPISuccessCode) {
                    targetDataCollectedCorrectly = true;
                } else {
                    return ret;
                }
            } catch (FileNotFoundException ex) {
                Utilities.handleException(ex);
                return ApiConstants.IMAPIFailCode;
            }

        }
        break;
    }
    // a target online db is selected
    default: {
        OnlineDatabase db = this.conf.getOnlineDb(comparisonChoice);
        if (db == null) {
            this.setErrorMessage(ApiConstants.IMAPIFailCode,
                    "TargetSourceChoice not set correctly check user configuration xml file again.");
            return ApiConstants.IMAPIFailCode;
        } else {

            /*
            if(db.getDbType().equals("owlim")){
                int ret = retrieveData.retrieveDataFrom_OWLIM_DB(db,allRetrievedModels, inputSourceInfo, pairSimilaritiesInSequences);
                if(ret==ApiConstants.IMAPISuccessCode){
                    targetDataCollectedCorrectly = true;
                }
            }
            else{
                */
            int ret = retrieveData.retrieveDataFrom_OnlineDatabaseAndCollectSimilarities(db, allRetrievedModels,
                    inputSourceInfo, canQuickFilteringMethodBeFollowedForeachSequence,
                    pairSimilaritiesInSequences);
            if (ret == ApiConstants.IMAPISuccessCode) {
                targetDataCollectedCorrectly = true;
            }
            //}

        }
        break;

    }
    }

    inputSourceInfo = null;

    //start comparing
    //find out the denominator in order to normalize results
    double similarityDenominator = 0;

    int maxNumberOfQueriesIndex = this.userConfig.getNumberOfSequences();
    for (int i = 0; i < maxNumberOfQueriesIndex; i++) {
        similarityDenominator += this.userConfig.getWeightAtUserQueryIndex(i);
    }

    //PRINT OUT
    //System.out.println("Total Number of results with similarity > 0:\r\n#################  " + allSimilaritiesHash.keySet().size() + "  ##################");
    System.out.println("\n\n============================================================");
    System.out.println("============================================================");
    System.out.println("============================================================");

    //for each sequence save the parameter name - type compared values and the similarity
    Enumeration<SourceTargetPair> similarityIterator = pairSimilaritiesInSequences.keys();
    while (similarityIterator.hasMoreElements()) {

        SourceTargetPair pair = similarityIterator.nextElement();

        SequenceSimilarityResultVector similarities = pairSimilaritiesInSequences.get(pair);

        //Vector<SequenceSimilarityResult> similarityResults = new Vector<SequenceSimilarityResult>();

        int calculatedSimilarity = 0;
        if (pair.getSourceInstance().getInstanceUri().equals(pair.getTargetInstance().getInstanceUri())) {
            calculatedSimilarity = 100;
        } else {
            calculatedSimilarity = compClass.calculateFinalSimilarity(similarities, similarityDenominator);
        }
        if (calculatedSimilarity >= (userConfig.getResultsThreshold() * 100)) {

            float floatVal = (float) ((float) calculatedSimilarity / 100f);
            SequenceSimilarityResultVector tripVec = pairSimilaritiesInSequences.get(pair);

            if (resultInstances.containsKey(floatVal)) {
                ResultSourceTargetPair newVal = new ResultSourceTargetPair(pair, tripVec);
                resultInstances.get(floatVal).add(newVal);
            } else {
                Vector<ResultSourceTargetPair> newVal = new Vector<ResultSourceTargetPair>();
                newVal.add(new ResultSourceTargetPair(pair, tripVec));
                resultInstances.put(floatVal, newVal);
            }

        }
    }

    if (targetDataCollectedCorrectly == false) {
        System.out.println("Note that while collected data from target Error Occurred");
    }

    return ApiConstants.IMAPISuccessCode;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.SpeedometerMultiValue.java

/**
 * Creates a chart of type speedometer.//from w w w .  j  a v  a2  s  .co m
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart speedometer.
 */

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    JFreeChart chart = null;
    try {
        MyDialPlot plot = new MyDialPlot();

        HashMap hmDataset = datasets.getDatasets();
        Set keyDataset = hmDataset.keySet();
        int i = 0;

        Iterator itDataset = keyDataset.iterator();
        while (itDataset.hasNext()) {
            String key = (String) itDataset.next();
            Dataset dataset = (Dataset) hmDataset.get(key);
            plot.setDataset(i, (ValueDataset) dataset);
            if (key.indexOf("__") > 0)
                setName(key.substring(0, key.indexOf("__")));
            else
                setName(key);
            i++;
        }

        plot.setDialFrame(new StandardDialFrame());

        plot.setBackground(new DialBackground());

        if (dialtextuse) {
            DialTextAnnotation annotation1 = new DialTextAnnotation(dialtext);
            annotation1.setFont(styleTitle.getFont());
            annotation1.setRadius(0.7);

            plot.addLayer(annotation1);
        }

        StandardDialScale scale = new StandardDialScale(lower, upper, -120, -300, 10.0, 4);

        if (!(increment > 0)) {
            logger.warn("increment cannot be less than 0, put default to 0.1 ");
            increment = 0.1;
        }

        scale.setMajorTickIncrement(increment);
        scale.setMinorTickCount(minorTickCount);
        scale.setTickRadius(0.88);
        scale.setTickLabelOffset(0.15);
        //set tick label style
        scale.setTickLabelsVisible(true);
        Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
        scale.setTickLabelFont(tickLabelsFont);
        scale.setTickLabelPaint(labelsTickStyle.getColor());

        plot.addScale(0, scale);

        DialCap cap = new DialCap();
        plot.setCap(cap);

        // sets intervals
        for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
            KpiInterval interval = (KpiInterval) iterator.next();
            StandardDialRange range = new StandardDialRange(interval.getMin(), interval.getMax(),
                    interval.getColor());
            range.setInnerRadius(0.50);
            range.setOuterRadius(0.85);

            range.setPaint(interval.getColor());

            plot.addLayer(range);

        }

        plot.setBackground(new DialBackground());

        logger.debug("Set values color");
        Vector arValuesName = getValuesNames();
        legendItems = new LegendItemCollection();
        for (int j = 0; j < arValuesName.size(); j++) {
            DialPointer.Pin p = new DialPointer.Pin(j);
            if (colorMap != null) {
                String valueName = (String) arValuesName.get(j);
                Color color = (Color) colorMap.get(valueName);
                if (color != null)
                    p.setPaint(color);

                if (serieLegend.equalsIgnoreCase(name)) {
                    if (j < arValuesName.size()) {
                        LegendItem item = new LegendItem(valueName, "", "", "",
                                new Ellipse2D.Double(-3, -5, 8, 8), color);
                        if (item != null) {
                            legendItems.add(item);
                        }
                    }
                    if (legend)
                        super.height = super.height + (super.height * 12 / 100);
                }
            }
            plot.addLayer(p);
        }

        plot.setLegendItems(legendItems);
        chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

        TextTitle title = setStyleTitle(name, styleTitle);
        chart.setTitle(title);
        if (subName != null && !subName.equals("")) {
            TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
            chart.addSubtitle(subTitle);
        }

        chart.setBackgroundPaint(color);
        if (legend == true)
            drawLegend(chart);

    } catch (Exception ex) {
        logger.debug("Error while creating speedometer multivalue: " + ex);
    }
    logger.debug("OUT");
    return chart;
}

From source file:edu.ku.brc.web.ParsePaleo.java

/**
 * @throws SQLException //  ww  w.j  a  v a 2  s. co m
 * 
 */
private int recurseForAttachments(final PreparedStatement pStmtTaxonAttach, final TreeNode node)
        throws SQLException {
    if (node.rankId == 220) {
        Vector<Integer> ids = BasicSQLUtils.queryForInts(dbS3Conn,
                String.format("SELECT attachId FROM taxon_attach WHERE taxonId = %d", node.recId));
        if (ids.size() > 0) {
            return ids.get(0);
        }
        throw new RuntimeException("No image for taxonId: " + node.recId);
    }

    int firstId = -1;
    for (TreeNode kidNode : node.kids) {
        int attachId = recurseForAttachments(pStmtTaxonAttach, kidNode);
        if (firstId == -1) {
            firstId = attachId;
        }
        if (kidNode.rankId > 0) {
            pStmtTaxonAttach.setInt(1, kidNode.recId);
            pStmtTaxonAttach.setInt(2, attachId);
            if (pStmtTaxonAttach.executeUpdate() == 0) {
                System.err.println("Error inserting record.");
            }
        }
    }
    return firstId;
}

From source file:edu.ku.brc.specify.tasks.subpane.wb.ConfigureXLS.java

public void showBadHeadingsMsg(final Vector<Integer> badHeadingIdxs, final Vector<Integer> emptyCols,
        final String title) {
    String colStr = "";
    for (int c = 0; c < badHeadingIdxs.size(); c++) {
        if (c > 0) {
            colStr += c == badHeadingIdxs.size() - 1 ? " and " : ", ";
        }//from  ww w. j a  v  a 2  s. c  om
        int adjust = 1;
        if (emptyCols != null) {
            for (Integer ec : emptyCols) {
                if (ec <= badHeadingIdxs.get(c)) {
                    adjust--;
                }
            }
            colStr += badHeadingIdxs.get(c) + adjust;
        }
    }
    JOptionPane.showMessageDialog(UIRegistry.getTopWindow(), String.format(getResourceString(
            (badHeadingIdxs.size() == 1 ? "WB_IMPORT_INVALID_COL_HEADER" : "WB_IMPORT_INVALID_COL_HEADERS")),
            colStr), title, JOptionPane.ERROR_MESSAGE);

}