Example usage for java.util Vector add

List of usage examples for java.util Vector add

Introduction

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

Prototype

public synchronized boolean add(E e) 

Source Link

Document

Appends the specified element to the end of this Vector.

Usage

From source file:com.alfaariss.oa.profile.aselect.binding.protocol.cgi.CGIRequest.java

/**
 * Creates the CGI request object./*  w  ww  . j  av a  2  s  . c  om*/
 * 
 * Reads the request parameters and puts them in a <code>Hashtable</code>
 * @param oRequest the servlet request 
 * @throws BindingException if the request object can't be created
 */
public CGIRequest(HttpServletRequest oRequest) throws BindingException {
    try {
        _logger = LogFactory.getLog(CGIRequest.class);
        _htRequest = new Hashtable<String, Object>();
        _sRequestedURL = oRequest.getRequestURL().toString();

        if (_logger.isDebugEnabled()) {
            String sQueryString = oRequest.getQueryString();
            if (sQueryString == null)
                sQueryString = "";
            _logger.debug("QueryString: " + sQueryString);
        }

        Hashtable<String, Vector<String>> htVectorItems = new Hashtable<String, Vector<String>>();
        Enumeration enumNames = oRequest.getParameterNames();
        while (enumNames.hasMoreElements()) {
            String sName = (String) enumNames.nextElement();
            String sValue = oRequest.getParameter(sName);
            if (sName.endsWith(CGIBinding.ENCODED_BRACES)
                    || sName.endsWith(CGIBinding.ENCODED_BRACES.toLowerCase()) || sName.endsWith("[]")) {
                Vector<String> vValues = htVectorItems.get(sName);
                if (vValues == null)
                    vValues = new Vector<String>();
                vValues.add(sValue);
                htVectorItems.put(sName, vValues);
            } else
                _htRequest.put(sName, sValue);
        }

        _htRequest.putAll(htVectorItems);
    } catch (Exception e) {
        _logger.fatal("Internal error during CGI Request creation", e);
        throw new BindingException(SystemErrors.ERROR_INTERNAL);
    }
}

From source file:techtonic.PlotLogGraphListener.java

@Override
public void actionPerformed(ActionEvent e) {

    List<WitsmlLogCurve> curves = log.getCurves();

    Vector<String> curveDescription = new Vector<>();
    for (WitsmlLogCurve c : curves) {
        // System.out.println(c.getDescription());
        curveDescription.add(c.getDescription());
    }/*from ww  w.  j  a  v  a  2  s.com*/
    Techtonic.setjcbX_Axis(curveDescription);

    Techtonic.setEnablejcbX_Axis(true);
    Techtonic.setEnablejcbY_Axis(false);
    Techtonic.setEnableRenderBtn(true);
    Techtonic.setPropertyBtn(true);

    //Techtonic.setjcbX_Axis();
    Vector<String> v = new Vector<String>(Arrays.asList(new String[] { "Depth" }));
    Techtonic.setjcbY_Axis(v);
    //plot the graph using values of the second entry
    WitsmlLogCurve ydata = curves.get(0);
    WitsmlLogCurve xdata = curves.get(1);
    List<Object> yvalues = ydata.getValues();
    List<Object> xvalues = xdata.getValues();
    String title = "Depth against " + xdata.getDescription();
    XYSeries series = new XYSeries(title);

    for (int i = 0; i < yvalues.size(); i++) {
        Object vx = xvalues.get(i);
        Object vy = yvalues.get(i);
        double dx = Double.parseDouble(vx.toString());
        double dy = Double.parseDouble(vy.toString());
        series.add(dx, dy);
    }
    XYSeriesCollection data = new XYSeriesCollection();
    data.addSeries(series);

    // create a chart using the createYLineChart method...
    JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title
            xdata.getDescription(), "Depth", // x and y axis labels
            data); // data

    ChartPanel cp = new ChartPanel(chart);
    //            JFrame fr = new JFrame();
    //            fr.add(cp);
    //            fr.pack();
    //            fr.setVisible(true);
    //cp.setMouseZoomable(true, true);  
    Techtonic.setFreeChart(chart);
    Techtonic.setCurrentCurves(curves);
    Techtonic.setDisplayArea(cp);
    //            chartPanel.setLayout(new java.awt.BorderLayout());
    //            chartPanel.add(cp,BorderLayout.CENTER);
    //            chartPanel.validate();
    //            chartPanel.repaint();
}

From source file:com.kynetx.api.java

public void onDirective(String directive, onEventListener toRun) {
    if (callbacks != null) {
        if (callbacks.containsKey(directive)) {
            Vector<onEventListener> toRunVector = callbacks.get(directive);
            toRunVector.add(toRun);
        } else {/*  w  w w.  ja va2  s  .c o  m*/
            Vector<onEventListener> toRunVector = new Vector<onEventListener>();
            toRunVector.add(toRun);
            callbacks.put(directive, toRunVector);
        }
    }
}

From source file:edu.umn.cs.spatialHadoop.nasa.MultiHDFPlot.java

public static boolean multiplot(Path[] input, Path output, OperationsParams params)
        throws IOException, InterruptedException, ClassNotFoundException, ParseException {
    String timeRange = params.get("time");
    final Date dateFrom, dateTo;
    final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd");
    try {/*from   w ww. j  a  va  2  s  .  c o m*/
        String[] parts = timeRange.split("\\.\\.");
        dateFrom = dateFormat.parse(parts[0]);
        dateTo = dateFormat.parse(parts[1]);
    } catch (ArrayIndexOutOfBoundsException e) {
        System.err.println("Use the seperator two periods '..' to seperate from and to dates");
        return false; // To avoid an error that causes dateFrom to be uninitialized
    } catch (ParseException e) {
        System.err.println("Illegal date format in " + timeRange);
        return false;
    }
    // Number of frames to combine in each image
    int combine = params.getInt("combine", 1);
    // Retrieve all matching input directories based on date range
    Vector<Path> matchingPathsV = new Vector<Path>();
    for (Path inputFile : input) {
        FileSystem inFs = inputFile.getFileSystem(params);
        FileStatus[] matchingDirs = inFs.listStatus(input, new PathFilter() {
            @Override
            public boolean accept(Path p) {
                String dirName = p.getName();
                try {
                    Date date = dateFormat.parse(dirName);
                    return date.compareTo(dateFrom) >= 0 && date.compareTo(dateTo) <= 0;
                } catch (ParseException e) {
                    LOG.warn("Cannot parse directory name: " + dirName);
                    return false;
                }
            }
        });
        for (FileStatus matchingDir : matchingDirs)
            matchingPathsV.add(new Path(matchingDir.getPath(), "*.hdf"));
    }
    if (matchingPathsV.isEmpty()) {
        LOG.warn("No matching directories to given input");
        return false;
    }

    Path[] matchingPaths = matchingPathsV.toArray(new Path[matchingPathsV.size()]);
    Arrays.sort(matchingPaths);

    // Clear all paths to ensure we set our own paths for each job
    params.clearAllPaths();

    // Create a water mask if we need to recover holes on write
    if (params.get("recover", "none").equals("write")) {
        // Recover images on write requires a water mask image to be generated first
        OperationsParams wmParams = new OperationsParams(params);
        wmParams.setBoolean("background", false);
        Path wmImage = new Path(output, new Path("water_mask"));
        HDFPlot.generateWaterMask(wmImage, wmParams);
        params.set(HDFPlot.PREPROCESSED_WATERMARK, wmImage.toString());
    }
    // Start a job for each path
    int imageWidth = -1;
    int imageHeight = -1;
    boolean overwrite = params.getBoolean("overwrite", false);
    boolean pyramid = params.getBoolean("pyramid", false);
    FileSystem outFs = output.getFileSystem(params);
    Vector<Job> jobs = new Vector<Job>();
    boolean background = params.getBoolean("background", false);
    Rectangle mbr = new Rectangle(-180, -90, 180, 90);
    for (int i = 0; i < matchingPaths.length; i += combine) {
        Path[] inputPaths = new Path[Math.min(combine, matchingPaths.length - i)];
        System.arraycopy(matchingPaths, i, inputPaths, 0, inputPaths.length);
        Path outputPath = new Path(output, inputPaths[0].getParent().getName() + (pyramid ? "" : ".png"));
        if (overwrite || !outFs.exists(outputPath)) {
            // Need to plot
            Job rj = HDFPlot.plotHeatMap(inputPaths, outputPath, params);
            if (imageHeight == -1 || imageWidth == -1) {
                if (rj != null) {
                    imageHeight = rj.getConfiguration().getInt("height", 1000);
                    imageWidth = rj.getConfiguration().getInt("width", 1000);
                    mbr = (Rectangle) OperationsParams.getShape(rj.getConfiguration(), "mbr");
                } else {
                    imageHeight = params.getInt("height", 1000);
                    imageWidth = params.getInt("width", 1000);
                    mbr = (Rectangle) OperationsParams.getShape(params, "mbr");
                }
            }
            if (background && rj != null)
                jobs.add(rj);
        }
    }
    // Wait until all jobs are done
    while (!jobs.isEmpty()) {
        Job firstJob = jobs.firstElement();
        firstJob.waitForCompletion(false);
        if (!firstJob.isSuccessful()) {
            System.err.println("Error running job " + firstJob.getJobID());
            System.err.println("Killing all remaining jobs");
            for (int j = 1; j < jobs.size(); j++)
                jobs.get(j).killJob();
            throw new RuntimeException("Error running job " + firstJob.getJobID());
        }
        jobs.remove(0);
    }

    // Draw the scale in the output path if needed
    String scalerange = params.get("scalerange");
    if (scalerange != null) {
        String[] parts = scalerange.split("\\.\\.");
        double min = Double.parseDouble(parts[0]);
        double max = Double.parseDouble(parts[1]);
        String scale = params.get("scale", "none").toLowerCase();
        if (scale.equals("vertical")) {
            MultiHDFPlot.drawVerticalScale(new Path(output, "scale.png"), min, max, 64, imageHeight, params);
        } else if (scale.equals("horizontal")) {
            MultiHDFPlot.drawHorizontalScale(new Path(output, "scale.png"), min, max, imageWidth, 64, params);
        }
    }
    // Add the KML file
    createKML(outFs, output, mbr, params);
    return true;
}

From source file:biblivre3.z3950.BiblivrePrefixString.java

@Override
public InternalModelRootNode toInternalQueryModel(ApplicationContext ctx) throws InvalidQueryException {
    if (StringUtils.isBlank(queryAttr) || StringUtils.isBlank(queryTerms)) {
        throw new InvalidQueryException("Null prefix string");
    }/*www  .j a va 2s.c om*/
    try {
        if (internalModel == null) {
            internalModel = new InternalModelRootNode();
            InternalModelNamespaceNode node = new InternalModelNamespaceNode();
            node.setAttrset(DEFAULT_ATTRSET);
            internalModel.setChild(node);
            AttrPlusTermNode attrNode = new AttrPlusTermNode();
            final String attrValue = "1." + queryAttr;
            attrNode.setAttr(DEFAULT_ATTRTYPE, new AttrValue(null, attrValue));
            Vector terms = new Vector();
            StringTokenizer tokenizer = new StringTokenizer(queryTerms);
            while (tokenizer.hasMoreElements()) {
                terms.add(tokenizer.nextElement());
            }
            if (terms.size() > 1) {
                attrNode.setTerm(terms);
            } else if (terms.size() == 1) {
                attrNode.setTerm(terms.get(0));
            } else {
                throw new PrefixQueryException("No Terms");
            }
            node.setChild(attrNode);
        }
    } catch (Exception e) {
        throw new InvalidQueryException(e.getMessage());
    }
    return internalModel;
}

From source file:com.jaspersoft.jasperserver.api.engine.jasperreports.util.JarsClassLoader.java

protected Enumeration findResources(String name) throws IOException {
    Vector urls = new Vector();
    for (int i = 0; i < jars.length; i++) {
        JarFileEntry entry = getJarEntry(jars[i], name);
        if (entry != null) {
            urls.add(urlStreamHandler.createURL(entry));
        }/*from w  w  w . jav  a  2  s .  c o  m*/
    }
    return urls.elements();
}

From source file:no.met.jtimeseries.netcdf.NetcdfChartProvider.java

Vector<NumberPhenomenon> getWantedPhenomena(Iterable<String> variables) throws ParseException {
    if (variables == null)
        variables = getVariables();/*from w  w w.j  a v  a 2  s  .  co m*/

    Vector<NumberPhenomenon> data = new Vector<NumberPhenomenon>();
    for (String variable : variables)
        data.add(getWantedPhenomenon(variable));

    if (data.isEmpty())
        throw new ParseException("Unable to find requested parameters", 0);

    return data;
}

From source file:edu.ku.brc.specify.conversion.CollectionInfo.java

/**
 * @return/*from  w w w . j  a v a 2 s .com*/
 */
public static Vector<CollectionInfo> getFilteredCollectionInfoList() {
    if (DOING_ACCESSSION) {
        return new Vector<CollectionInfo>(collectionInfoList);
    }

    Vector<CollectionInfo> colList = new Vector<CollectionInfo>();
    for (CollectionInfo ci : collectionInfoList) {
        if (ci.getColObjCnt() > 0 || ci.getSrcHostTaxonCnt() > 0) {
            colList.add(ci);
        }
    }
    return colList;
}

From source file:hermes.browser.model.PropertySetTableModel.java

public PropertySetTableModel(Object bean, PropertySetConfig propertySet, Set filter)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    this.propertySet = propertySet;

    Set iterSet = null;/*from  w  ww .  j a  v  a 2s. c o  m*/
    SortedMap sortMap = new TreeMap();

    if (propertySet.getProperty() != null) {

        for (Iterator iter = propertySet.getProperty().iterator(); iter.hasNext();) {
            PropertyConfig property = (PropertyConfig) iter.next();

            if (!ignore.contains(property.getName())) {
                Object propertyValue = property.getValue();

                if (propertyValue == null) {
                    propertyValue = "null";
                }

                sortMap.put(property.getName(), propertyValue);
            }
        }

        for (Iterator iter2 = sortMap.entrySet().iterator(); iter2.hasNext();) {
            Map.Entry entry = (Map.Entry) iter2.next();

            Vector row = new Vector();

            row.add(entry.getKey());
            row.add(entry.getValue());

            rows.add(row);
        }
    }

    setBean(bean);
}

From source file:net.sf.jabref.sql.importer.DbImportAction.java

private void performImport() {
    if (!connectedToDB) {
        return;//  w w w .j a  v  a2s .com
    }

    frame.output(Localization.lang("Attempting SQL import..."));
    DBExporterAndImporterFactory factory = new DBExporterAndImporterFactory();
    DatabaseImporter importer = factory.getImporter(dbs.getDbPreferences().getServerType());
    try {
        try (Connection conn = importer.connectToDB(dbs);
                Statement statement = conn.createStatement();
                ResultSet rs = statement.executeQuery(SQLUtil.queryAllFromTable("jabref_database"))) {

            Vector<Vector<String>> matrix = new Vector<>();

            while (rs.next()) {
                Vector<String> v = new Vector<>();
                v.add(rs.getString("database_name"));
                matrix.add(v);
            }

            if (matrix.isEmpty()) {
                JOptionPane.showMessageDialog(frame,
                        Localization.lang("There are no available databases to be imported"),
                        Localization.lang("Import from SQL database"), JOptionPane.INFORMATION_MESSAGE);
            } else {
                DBImportExportDialog dialogo = new DBImportExportDialog(frame, matrix,
                        DBImportExportDialog.DialogType.IMPORTER);
                if (dialogo.removeAction) {
                    String dbName = dialogo.selectedDB;
                    DatabaseUtil.removeDB(dialogo, dbName, conn, databaseContext);
                    performImport();
                } else if (dialogo.moreThanOne) {
                    // use default DB mode for import
                    databases = importer.performImport(dbs, dialogo.listOfDBs,
                            Globals.prefs.getDefaultBibDatabaseMode());
                    for (DBImporterResult res : databases) {
                        databaseContext = res.getDatabaseContext();
                        dbs.isConfigValid(true);
                    }
                    frame.output(Localization.lang("%0 databases will be imported",
                            Integer.toString(databases.size())));
                } else {
                    frame.output(Localization.lang("Importing canceled"));
                }
            }
        }
    } catch (Exception ex) {
        String preamble = Localization.lang("Could not import from SQL database for the following reason:");
        String errorMessage = SQLUtil.getExceptionMessage(ex);
        dbs.isConfigValid(false);
        JOptionPane.showMessageDialog(frame, preamble + '\n' + errorMessage,
                Localization.lang("Import from SQL database"), JOptionPane.ERROR_MESSAGE);
        frame.output(Localization.lang("Error importing from database"));
        LOGGER.error("Error importing from database", ex);
    }
}