Example usage for java.util Vector addElement

List of usage examples for java.util Vector addElement

Introduction

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

Prototype

public synchronized void addElement(E obj) 

Source Link

Document

Adds the specified component to the end of this vector, increasing its size by one.

Usage

From source file:edu.umd.cfar.lamp.viper.util.StringHelp.java

/**
 * Get the characters from a bracketed list that are not in brackets.
 * Returns a string if the input contains characters 
 * between brackets/*from   w  w  w .j  a va  2 s . c  o m*/
 * such as the ... in the following:
 * <pre>
 *   ... [ foo ] ... [1.2 1.2] ... [hi] ...
 * </pre>
 * If there isn't anything outside the brackets, it returns null.
 *
 * @param line The String to check.
 * @return The text outside brackets, or <code>null</code> if there
 *    is no such text.
 */
public static String getExtraTextOutsideBrackets(String line) {
    Vector stringList = new Vector();
    boolean justEntered = false;
    int startPos = 0;

    int bracketCount = 0;
    for (int i = 0; i < line.length(); i++) {
        char c = line.charAt(i);
        if (c == '[') {
            bracketCount++;
            if (bracketCount != 0) {
                String str = line.substring(startPos, i);
                str = str.trim();
                if (str.length() > 0)
                    stringList.addElement(str);
            }
        } else if (c == ']') {
            bracketCount--;
            if (bracketCount == 0)
                justEntered = true;
        } else if (bracketCount == 0) {
            if (justEntered) {
                justEntered = false;
                startPos = i;
            }
        }
    }
    if (!justEntered) {
        String str = line.substring(startPos);
        str = str.trim();
        if (str.length() > 0)
            stringList.addElement(str);
    }
    if (stringList.size() == 0)
        return (null);
    else {
        int size = stringList.size();
        String temp = (String) stringList.elementAt(0);
        for (int i = 1; i < size; i++) {
            String temp2 = (String) stringList.elementAt(i);
            temp += ", " + temp2;
        }
        return (temp);
    }
}

From source file:net.anidb.udp.UdpCharacterFactory.java

/**
 * Returns the anime list from the data field. 
 * @param dataField The data field./* ww  w  .j  a  va 2 s. c o  m*/
 * @return The anime list.
 * @throws UdpConnectionException If a connection problem occured.
 * @throws DataFieldException If the data field does not contain parsable
 * values.
 */
private List<AnimeCharacter> getAnimeList(final DataField dataField)
        throws UdpConnectionException, DataFieldException {

    Vector<AnimeCharacter> animeList;
    String value;
    AnimeCharacter animeChar;
    int count;

    value = dataField.getValue();
    if ((value == null) || (value.length() == 0)) {
        return null;
    }
    animeList = new Vector<AnimeCharacter>();
    count = dataField.getDataFieldCount();
    if (count > 0) {
        for (int index = 0; index < count; index++) {
            animeChar = this.getAnime(dataField.getDataFieldAt(index));
            animeList.addElement(animeChar);
        }
    } else {
        animeChar = this.getAnime(dataField);
        animeList.addElement(animeChar);
    }
    return animeList;
}

From source file:org.apache.jmeter.util.JMeterUtils.java

/**
 * Creates a vector of SampleController plugins.
 *
 * @param properties//from   www .  ja  v a  2s.  com
 *            The properties with information about the samplers
 * @return The Controllers value
 * @deprecated (3.0) not used + pre-java 1.2 collection
 */
// TODO - does not appear to be called directly
@Deprecated
public static Vector<Object> getControllers(Properties properties) {
    String name = "controller."; // $NON-NLS-1$
    Vector<Object> v = new Vector<>();
    Enumeration<?> names = properties.keys();
    while (names.hasMoreElements()) {
        String prop = (String) names.nextElement();
        if (prop.startsWith(name)) {
            Object o = instantiate(properties.getProperty(prop), "org.apache.jmeter.control.SamplerController"); // $NON-NLS-1$
            v.addElement(o);
        }
    }
    return v;
}

From source file:org.dita.dost.AbstractIntegrationTest.java

/**
 * Run test conversion//w  w w  .j a va  2s  . c o  m
 *
 * @param d          test source directory
 * @param transtypes list of transtypes to test
 * @return list of log messages
 * @throws Exception if conversion failed
 */
private List<TestListener.Message> run(final File d, final String[] transtypes, final File resDir)
        throws Exception {
    if (transtypes.length == 0) {
        return emptyList();
    }

    final File tempDir = new File(baseTempDir, d.getName() + File.separator + "temp");
    deleteDirectory(resDir);
    deleteDirectory(tempDir);

    final TestListener listener = new TestListener(System.out, System.err);
    final PrintStream savedErr = System.err;
    final PrintStream savedOut = System.out;
    try {
        final File buildFile = new File(d, "build.xml");
        final Project project = new Project();
        project.addBuildListener(listener);
        System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
        System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
        project.fireBuildStarted();
        project.init();
        for (final String transtype : transtypes) {
            if (canCompare.contains(transtype)) {
                project.setUserProperty("run." + transtype, "true");
                if (transtype.equals("pdf") || transtype.equals("pdf2")) {
                    project.setUserProperty("pdf.formatter", "fop");
                    project.setUserProperty("fop.formatter.output-format", "text/plain");
                }
            }
        }
        project.setUserProperty("generate-debug-attributes", "false");
        project.setUserProperty("preprocess.copy-generated-files.skip", "true");
        project.setUserProperty("ant.file", buildFile.getAbsolutePath());
        project.setUserProperty("ant.file.type", "file");
        project.setUserProperty("dita.dir", ditaDir.getAbsolutePath());
        project.setUserProperty("result.dir", resDir.getAbsolutePath());
        project.setUserProperty("temp.dir", tempDir.getAbsolutePath());
        project.setKeepGoingMode(false);
        ProjectHelper.configureProject(project, buildFile);
        final Vector<String> targets = new Vector<>();
        targets.addElement(project.getDefaultTarget());
        project.executeTargets(targets);

        assertEquals("Warn message count does not match expected", getMessageCount(project, "warn"),
                countMessages(listener.messages, Project.MSG_WARN));
        assertEquals("Error message count does not match expected", getMessageCount(project, "error"),
                countMessages(listener.messages, Project.MSG_ERR));
    } finally {
        System.setOut(savedOut);
        System.setErr(savedErr);
        return listener.messages;
    }
}

From source file:com.substanceofcode.twitter.model.Status.java

private Vector aboutVec(JSONObject user) {
    Vector accum = new Vector();
    for (int i = 0; i < userFields.length; i++) {
        String key = userFields[i];
        String value;//from   w  w  w .  ja  v a2  s .c  o m
        try {
            if (key.endsWith("_count")) {
                int v = user.getInt(key);
                value = String.valueOf(v);
            } else {
                value = user.getString(key);
            }
            String[] kv = { key, value };
            accum.addElement(kv);
        } catch (JSONException e) {
        }
    }
    return accum;
}

From source file:com.isecpartners.gizmo.FourthIdea.java

private static String[] translateCommandline(final String toProcess) {
    if (toProcess == null || toProcess.length() == 0) {
        // no command? no string
        return new String[0];
    }//from   w ww.j  a  v a2 s . c  o m

    // parse with a simple finite state machine

    final int normal = 0;
    final int inQuote = 1;
    final int inDoubleQuote = 2;
    int state = normal;
    StringTokenizer tok = new StringTokenizer(toProcess, "\"\' ", true);
    Vector v = new Vector();
    StringBuffer current = new StringBuffer();
    boolean lastTokenHasBeenQuoted = false;

    while (tok.hasMoreTokens()) {
        String nextTok = tok.nextToken();
        switch (state) {
        case inQuote:
            if ("\'".equals(nextTok)) {
                lastTokenHasBeenQuoted = true;
                state = normal;
            } else {
                current.append(nextTok);
            }
            break;
        case inDoubleQuote:
            if ("\"".equals(nextTok)) {
                lastTokenHasBeenQuoted = true;
                state = normal;
            } else {
                current.append(nextTok);
            }
            break;
        default:
            if ("\'".equals(nextTok)) {
                state = inQuote;
            } else if ("\"".equals(nextTok)) {
                state = inDoubleQuote;
            } else if (" ".equals(nextTok)) {
                if (lastTokenHasBeenQuoted || current.length() != 0) {
                    v.addElement(current.toString());
                    current = new StringBuffer();
                }
            } else {
                current.append(nextTok);
            }
            lastTokenHasBeenQuoted = false;
            break;
        }
    }

    if (lastTokenHasBeenQuoted || current.length() != 0) {
        v.addElement(current.toString());
    }

    if (state == inQuote || state == inDoubleQuote) {
        throw new IllegalArgumentException("Unbalanced quotes in " + toProcess);
    }

    String[] args = new String[v.size()];
    v.copyInto(args);
    return args;
}

From source file:nl.nn.adapterframework.util.StringTagger.java

/**
 * Handles and splits a tag in its component parts, and store the elemements in
 * the {@link #tokens} and {@link #multitokens} fields.
 * @param tag the string containing the tag
 *//*from  w  ww.  ja  v a2s.  c o m*/
void splitTag(String tag) {
    int tagPos = tag.indexOf(TagSeperator);
    String name = tag.substring(0, tagPos);
    String result = tag.substring(tagPos + 1);
    //        log.debug("SplitTag |"+name+"|"+result+"|");

    if (result.length() > 1 && result.charAt(0) == QuoteChar
            && result.charAt(result.length() - 1) == QuoteChar) {
        result = result.substring(1, result.length() - 1);
    }
    tokens.put(name, result);

    StringTokenizer toks = new StringTokenizer(result, "" + FieldSeperator + FunctionOpen + FunctionClose,
            true);
    // If quoted, strip the " " from beginning and end ?
    Vector Multi = new Vector();
    if (toks.hasMoreTokens()) {
        String tokvalue = "";
        int nesting = 0;
        while (toks.hasMoreTokens()) {
            String tok = toks.nextToken();
            if (tok.equals("" + FieldSeperator)) {
                if (nesting == 0) {
                    Multi.addElement(tokvalue.trim());
                    tokvalue = "";
                } else {
                    tokvalue += tok;
                }
            } else if (tok.equals("" + FunctionOpen)) {
                nesting++;
                tokvalue += tok;
            } else if (tok.equals("" + FunctionClose)) {
                nesting--;
                tokvalue += tok;
            } else {
                tokvalue += tok;
            }
        }
        Multi.addElement(tokvalue.trim());
    }
    multitokens.put(name, Multi);
}

From source file:com.sun.grizzly.http.jk.server.JkMain.java

private String[] split(String s, String delim) {
    Vector v = new Vector();
    StringTokenizer st = new StringTokenizer(s, delim);
    while (st.hasMoreTokens()) {
        v.addElement(st.nextToken());
    }/*  ww  w.  jav  a  2 s  . co m*/
    String res[] = new String[v.size()];
    for (int i = 0; i < res.length; i++) {
        res[i] = (String) v.elementAt(i);
    }
    return res;
}

From source file:org.apache.jk.config.WebXml2Jk.java

void generate(MappingGenerator gen) throws IOException {
    gen.generateStart();//from   ww  w . j a  v  a2s  . c o  m
    log.info("Generating mappings for servlets ");
    for (Node mapN = getChild(webN, "servlet-mapping"); mapN != null; mapN = getNext(mapN)) {

        String serv = getChildContent(mapN, "servlet-name");
        String url = getChildContent(mapN, "url-pattern");

        gen.generateServletMapping(serv, url);
    }

    log.info("Generating mappings for filters ");
    for (Node mapN = getChild(webN, "filter-mapping"); mapN != null; mapN = getNext(mapN)) {

        String filter = getChildContent(mapN, "filter-name");
        String url = getChildContent(mapN, "url-pattern");

        gen.generateFilterMapping(filter, url);
    }

    for (Node mapN = getChild(webN, "error-page"); mapN != null; mapN = getNext(mapN)) {
        String errorCode = getChildContent(mapN, "error-code");
        String location = getChildContent(mapN, "location");

        if (errorCode != null && !"".equals(errorCode)) {
            try {
                int err = new Integer(errorCode).intValue();
                gen.generateErrorPage(err, location);
            } catch (Exception ex) {
                log.error("Format error " + location, ex);
            }
        }
    }

    Node lcN = getChild(webN, "login-config");
    if (lcN != null) {
        log.info("Generating mapping for login-config ");

        String authMeth = getContent(getChild(lcN, "auth-method"));
        String realm = getContent(getChild(lcN, "realm-name"));
        if (authMeth == null)
            authMeth = "BASIC";

        Node n1 = getChild(lcN, "form-login-config");
        String loginPage = getChildContent(n1, "form-login-page");
        String errPage = getChildContent(n1, "form-error-page");

        if (loginPage != null) {
            int lpos = loginPage.lastIndexOf("/");
            String jscurl = loginPage.substring(0, lpos + 1) + "j_security_check";
            gen.generateLoginConfig(jscurl, errPage, authMeth);
        }
    }

    log.info("Generating mappings for security constraints ");
    for (Node mapN = getChild(webN, "security-constraint"); mapN != null; mapN = getNext(mapN)) {

        Vector methods = new Vector();
        Vector urls = new Vector();
        Vector roles = new Vector();
        boolean isSSL = false;

        Node wrcN = getChild(mapN, "web-resource-collection");
        for (Node uN = getChild(wrcN, "http-method"); uN != null; uN = getNext(uN)) {
            methods.addElement(getContent(uN));
        }
        for (Node uN = getChild(wrcN, "url-pattern"); uN != null; uN = getNext(uN)) {
            urls.addElement(getContent(uN));
        }

        // Not used at the moment
        Node acN = getChild(mapN, "auth-constraint");
        for (Node rN = getChild(acN, "role-name"); rN != null; rN = getNext(rN)) {
            roles.addElement(getContent(rN));
        }

        Node ucN = getChild(mapN, "user-data-constraint");
        String transp = getContent(getChild(ucN, "transport-guarantee"));
        if (transp != null) {
            if ("INTEGRAL".equalsIgnoreCase(transp) || "CONFIDENTIAL".equalsIgnoreCase(transp)) {
                isSSL = true;
            }
        }

        gen.generateConstraints(urls, methods, roles, isSSL);
    }
    gen.generateEnd();
}

From source file:maui.main.MauiTopicExtractor.java

/**
 * Returns an enumeration describing the available options.
 *
 * @return an enumeration of all the available options
 *//* ww  w  .j ava 2  s . c  om*/
public Enumeration<Option> listOptions() {

    Vector<Option> newVector = new Vector<Option>(15);

    newVector.addElement(new Option("\tSpecifies name of directory.", "l", 1, "-l <directory name>"));
    newVector.addElement(new Option("\tSpecifies name of model.", "m", 1, "-m <model name>"));
    newVector.addElement(new Option("\tSpecifies vocabulary name.", "v", 1, "-v <vocabulary name>"));
    newVector.addElement(new Option("\tSpecifies vocabulary format.", "f", 1, "-f <vocabulary format>"));
    newVector.addElement(new Option("\tSpecifies encoding.", "e", 1, "-e <encoding>"));
    newVector.addElement(new Option("\tSpecifies wikipedia database and server.", "w", 1,
            "-w <wikipediaDatabase@wikipediaServer>"));
    newVector.addElement(new Option("\tSpecifies document language (en (default), es, de, fr).", "i", 1,
            "-i <document language>"));
    newVector.addElement(new Option("\tSpecifies number of phrases to be output (default: 5).", "n", 1, "-n"));
    newVector.addElement(new Option("\tSet the stemmer to use (default: SremovalStemmer).", "t", 1,
            "-t <name of stemmer class>"));
    newVector.addElement(new Option("\tSet the stopwords class to use (default: EnglishStopwords).", "s", 1,
            "-s <name of stopwords class>"));
    newVector.addElement(new Option("\tTurns debugging mode on.", "d", 0, "-d"));
    newVector.addElement(new Option(
            "\tBuilds global dictionaries for computing TFIDF from the test collection.", "b", 0, "-b"));
    newVector.addElement(
            new Option("\tPrints graph description into a \".gv\" file, in GraphViz format.", "p", 0, "-p"));
    newVector.addElement(new Option("\tAlso write stemmed phrase and score into \".key\" file.", "a", 0, "-a"));

    return newVector.elements();
}