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:org.apache.hadoopts.chart.statistic.HistogramChart.java

public void store(String folder, String filename) {
    store(chart, new File(folder), filename);

    MeasurementTable tab = new MeasurementTable();
    File f = new File(folder + "/" + "TAB_" + filename + ".dat");
    Vector<TimeSeriesObject> mrs = new Vector<TimeSeriesObject>();
    mrs.add(mr);
    tab.setMessReihen(mrs);//from  w  w w .  j a v a  2  s. c om
    tab.writeToFile(f);
}

From source file:net.sf.jdmf.util.MathCalculator.java

/**
 * Calculates the centroid of all given points in a nD space (assumes that
 * all points have n coordinates). Each coordinate of the centroid is a mean
 * of all values of the same coordinate of each point.
 * /* w ww.  j  a  va  2s . co m*/
 * @param points all points
 * @return the centroid of all given points
 */
public Vector<Double> calculateCentroid(List<Vector<Double>> points) {
    List<Mean> coordinateMeans = new ArrayList<Mean>();

    for (int i = 0; i < points.get(0).size(); ++i) {
        coordinateMeans.add(new Mean());
    }

    for (Vector<Double> point : points) {
        for (int i = 0; i < point.size(); ++i) {
            coordinateMeans.get(i).increment(point.get(i));
        }
    }

    Vector<Double> centroid = new Vector<Double>();

    for (Mean mean : coordinateMeans) {
        centroid.add(mean.getResult());
    }

    return centroid;
}

From source file:be.fedict.hsm.jca.HSMProxyKeyStore.java

@Override
public Enumeration<String> engineAliases() {
    Set<String> aliases = this.keyStoreParameter.getHSMProxyClient().getAliases();
    Vector<String> aliasesVector = new Vector<String>();
    for (String alias : aliases) {
        aliasesVector.add(alias);
    }/*from   ww  w.  j  a  v  a2  s .c o  m*/
    return aliasesVector.elements();
}

From source file:edu.ku.brc.af.core.SpecialMsgNotifier.java

/**
 * @param item/*  w  ww  .  j a  v  a  2  s  . c om*/
 * @throws Exception
 */
protected String send(final String url, final String id) throws Exception {
    // check the website for the info about the latest version
    HttpClient httpClient = new HttpClient();
    httpClient.getParams().setParameter("http.useragent", getClass().getName()); //$NON-NLS-1$
    httpClient.getHttpConnectionManager().getParams().setConnectionTimeout(15000);

    PostMethod postMethod = new PostMethod(url);

    Vector<NameValuePair> postParams = new Vector<NameValuePair>();

    postParams.add(new NameValuePair("id", id)); //$NON-NLS-1$

    String resAppVersion = UIRegistry.getAppVersion();
    resAppVersion = StringUtils.isEmpty(resAppVersion) ? "Unknown" : resAppVersion;

    // get the OS name and version
    postParams.add(new NameValuePair("os_name", System.getProperty("os.name"))); //$NON-NLS-1$
    postParams.add(new NameValuePair("os_version", System.getProperty("os.version"))); //$NON-NLS-1$
    postParams.add(new NameValuePair("java_version", System.getProperty("java.version"))); //$NON-NLS-1$
    postParams.add(new NameValuePair("java_vendor", System.getProperty("java.vendor"))); //$NON-NLS-1$
    postParams.add(new NameValuePair("app_version", UIRegistry.getAppVersion())); //$NON-NLS-1$

    // create an array from the params
    NameValuePair[] paramArray = new NameValuePair[postParams.size()];
    for (int i = 0; i < paramArray.length; ++i) {
        paramArray[i] = postParams.get(i);
    }

    postMethod.setRequestBody(paramArray);

    // connect to the server
    try {
        httpClient.executeMethod(postMethod);

        int status = postMethod.getStatusCode();
        if (status == 200) {
            // get the server response
            String responseString = postMethod.getResponseBodyAsString();

            if (StringUtils.isNotEmpty(responseString)) {
                return responseString;
            }
        }
    } catch (java.net.UnknownHostException ex) {
        log.debug("Couldn't reach host.");

    } catch (Exception e) {
        e.printStackTrace();
        // die silently
    }
    return null;
}

From source file:com.greenpepper.repository.FileSystemRepository.java

private Vector<Object> generateDocumentNode(File file, Hashtable<String, Vector<?>> pageBranch)
        throws IOException {
    Vector<Object> page = new Vector<Object>();
    page.add(file.equals(root) ? root.getName() : relativePath(file));
    page.add(file.isFile());/*from  www .j ava2s  .  c  o  m*/
    page.add(Boolean.FALSE);
    Hashtable<String, Vector<?>> subPageBranch = new Hashtable<String, Vector<?>>();
    page.add(subPageBranch);
    // Add source path
    page.add(file.getAbsolutePath());
    if (pageBranch != null) {
        pageBranch.put(relativePath(file), page);
    }
    if (file.isDirectory()) {
        navigateInto(file, subPageBranch);
    }
    return page;
}

From source file:de.onyxbits.raccoon.appmgr.ExtractWorker.java

@Override
protected File doInBackground() throws Exception {
    ZipFile zip = new ZipFile(source);
    parseResourceTable();/*w w  w  . j  a  v a 2 s. co  m*/
    if (filenames == null) {
        Enumeration<? extends ZipEntry> e = zip.entries();
        Vector<String> tmp = new Vector<String>();
        while (e.hasMoreElements()) {
            tmp.add(e.nextElement().getName());
        }
        filenames = tmp;
    }

    for (String filename : filenames) {
        ZipEntry entry = zip.getEntry(filename);
        InputStream in = zip.getInputStream(entry);
        OutputStream out = openDestination(filename);

        if (isBinaryXml(filename)) {
            XmlTranslator xmlTranslator = new XmlTranslator();
            ByteBuffer buffer = ByteBuffer.wrap(Utils.toByteArray(in));
            BinaryXmlParser binaryXmlParser = new BinaryXmlParser(buffer, resourceTable);
            binaryXmlParser.setLocale(Locale.getDefault());
            binaryXmlParser.setXmlStreamer(xmlTranslator);
            binaryXmlParser.parse();
            IOUtils.write(xmlTranslator.getXml(), out);
        } else {
            // Simply extract
            IOUtils.copy(in, out);
        }
        in.close();
        out.close();
    }

    zip.close();
    return dest;
}

From source file:com.monarchapis.driver.servlet.ApiRequestTest.java

@Before
public void setup() throws IOException {
    when(serviceResolver.required(AuthenticationSettings.class)).thenReturn(authenticationSettings);
    authenticationSettings.setDelegateAuthorization(false);
    authenticationSettings.setBypassRateLimiting(false);
    ServiceResolver.setInstance(serviceResolver);

    when(request.getInputStream()).thenAnswer(new Answer<ServletInputStream>() {
        @Override//from ww  w .jav  a2  s .  c om
        public ServletInputStream answer(InvocationOnMock invocation) throws Throwable {
            return new ServletInputStreamWrapper("This is a test".getBytes());
        }
    });
    when(request.getProtocol()).thenReturn("http");
    when(request.getServerName()).thenReturn("localhost");
    when(request.getServerPort()).thenReturn(8080);
    when(request.getRequestURI()).thenReturn("/test");
    when(request.getQueryString()).thenReturn("a=1&b=2");
    when(request.getRemoteAddr()).thenReturn("127.0.0.1");
    when(request.getMethod()).thenReturn("POST");
    when(request.getRequestURL()).thenAnswer(new Answer<StringBuffer>() {
        @Override
        public StringBuffer answer(InvocationOnMock invocation) throws Throwable {
            return new StringBuffer("/test");
        }
    });

    final Vector<String> headerNames = new Vector<String>();
    headerNames.add("name1");
    headerNames.add("name2");
    when(request.getHeaderNames()).thenAnswer(new Answer<Enumeration<String>>() {
        @Override
        public Enumeration<String> answer(InvocationOnMock invocation) throws Throwable {
            return headerNames.elements();
        }
    });
    when(request.getHeaders(anyString())).thenAnswer(new Answer<Enumeration<String>>() {
        @Override
        public Enumeration<String> answer(InvocationOnMock invocation) throws Throwable {
            String name = invocation.getArgumentAt(0, String.class);
            Vector<String> headerValues = new Vector<String>();
            headerValues.add(name + "-value1");
            headerValues.add(name + "-value2");
            return headerValues.elements();
        }
    });

    apiRequest = new ApiRequest(request);
}

From source file:com.adito.jdbc.JDBCConnectionImpl.java

synchronized void releasePreparedStatement(String key, PreparedStatement ps) throws SQLException {
    ps.clearParameters();/*from w  w w .java 2s. c o  m*/
    Vector avail = (Vector) preparedStatements.get(key);
    avail.add(ps);
}

From source file:com.redhat.rhn.frontend.servlets.RhnHttpServletRequest.java

/**
 * {@inheritDoc}/* w w w  . j av a  2s  . co m*/
 */
public Enumeration<String> getAttributeNames() {
    Vector<String> tmp = new Vector<String>();
    tmp.add(ACTIVE_LANG_ATTR);
    for (Enumeration<String> e = super.getAttributeNames(); e.hasMoreElements();) {
        tmp.add(e.nextElement());
    }
    return tmp.elements();
}

From source file:com.github.hdl.tensorflow.yarn.app.TFAmContainer.java

public StringBuilder makeCommands(long amMemory, String appMasterMainClass, int containerMemory,
        int containerVirtualCores, int workerNumContainers, int psNumContainers, String jarDfsPath,
        Vector<CharSequence> containerRetryOptions, String jniSoDfsPath) {
    // Set the necessary command to execute the application master
    Vector<CharSequence> vargs = new Vector<CharSequence>(30);

    // Set java executable command
    LOG.info("Setting up app master command");
    vargs.add(ApplicationConstants.Environment.JAVA_HOME.$$() + "/bin/java");
    // Set Xmx based on am memory size
    vargs.add("-Xmx" + amMemory + "m");
    // Set class name
    vargs.add(appMasterMainClass);//from  w ww  . j a  v  a2  s  .c  o m
    // Set params for Application Master
    vargs.add("--container_memory " + String.valueOf(containerMemory));
    vargs.add("--container_vcores " + String.valueOf(containerVirtualCores));
    vargs.add(TFApplication.makeOption(TFApplication.OPT_TF_WORKER_NUM, String.valueOf(workerNumContainers)));
    vargs.add(TFApplication.makeOption(TFApplication.OPT_TF_PS_NUM, String.valueOf(psNumContainers)));
    vargs.add("--" + TFApplication.OPT_TF_SERVER_JAR + " " + String.valueOf(jarDfsPath));
    if (jniSoDfsPath != null && !jniSoDfsPath.equals("")) {
        vargs.add(TFApplication.makeOption(TFApplication.OPT_TF_JNI_SO, jniSoDfsPath));
    }

    vargs.addAll(containerRetryOptions);

    vargs.add("1>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stdout");
    vargs.add("2>" + ApplicationConstants.LOG_DIR_EXPANSION_VAR + "/AppMaster.stderr");

    // Get final commmand
    StringBuilder command = new StringBuilder();
    for (CharSequence str : vargs) {
        command.append(str).append(" ");
    }
    return command;
}