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:Main.java

/**
   Return a list of all the children of a given node
 *///from  ww  w.j av a 2 s.c  o  m
static public Vector<Node> findAllChildren(Node node) {
    if (node == null)
        return null;

    Vector<Node> found_children = new Vector<Node>();
    NodeList children = node.getChildNodes();
    for (int i = 0; i < children.getLength(); i++) {
        Node child = children.item(i);
        if (child.getNodeType() == Node.ELEMENT_NODE)
            found_children.add(child);
    }
    return found_children;
}

From source file:edu.ku.brc.af.ui.forms.validation.FormattedDateValidator.java

protected static List<UIFieldFormatter> getDateFormatters() {
    //DateWrapper dw = AppPrefsCache.getDateWrapper("ui", "formatting", "scrdateformat");

    Vector<UIFieldFormatter> formatters = new Vector<UIFieldFormatter>();

    Vector<UIFieldFormatterField> fields = new Vector<UIFieldFormatterField>();
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 2, "MM", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.separator, 1, "/", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 2, "dd", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.separator, 1, "/", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 4, "YYYY", false));
    UIFieldFormatter uif = new UIFieldFormatter("Date", true, "*", UIFieldFormatter.FormatterType.date,
            UIFieldFormatter.PartialDateEnum.Full, Date.class, true, false, fields);
    //uif.setDateWrapper(dw);
    formatters.add(uif);/*from   www. j a  v  a2s. co m*/

    fields = new Vector<UIFieldFormatterField>();
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 2, "dd", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.separator, 1, "/", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 2, "MM", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.separator, 1, "/", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 4, "YYYY", false));
    uif = new UIFieldFormatter("Date", true, "*", UIFieldFormatter.FormatterType.date,
            UIFieldFormatter.PartialDateEnum.Full, Date.class, true, false, fields);
    //uif.setDateWrapper(dw);
    formatters.add(uif);

    fields = new Vector<UIFieldFormatterField>();
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 4, "YYYY", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.separator, 1, "/", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 2, "MM", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.separator, 1, "/", false));
    fields.add(new UIFieldFormatterField(UIFieldFormatterField.FieldType.numeric, 2, "dd", false));
    uif = new UIFieldFormatter("Date", true, "*", UIFieldFormatter.FormatterType.date,
            UIFieldFormatter.PartialDateEnum.Full, Date.class, true, false, fields);
    //uif.setDateWrapper(dw);
    formatters.add(uif);

    return formatters;
}

From source file:edu.umn.cs.spatialHadoop.util.Parallel.java

public static <T> List<T> forEach(int start, int end, RunnableRange<T> r, int parallelism)
        throws InterruptedException {
    Vector<T> results = new Vector<T>();
    if (end <= start)
        return results;
    final Vector<Throwable> exceptions = new Vector<Throwable>();
    Thread.UncaughtExceptionHandler h = new Thread.UncaughtExceptionHandler() {
        public void uncaughtException(Thread th, Throwable ex) {
            exceptions.add(ex);
        }/*from   w ww. j ava2  s .  c o  m*/
    };

    // Put an upper bound on parallelism to avoid empty ranges
    if (parallelism > (end - start))
        parallelism = end - start;
    if (parallelism == 1) {
        // Avoid creating threads
        results.add(r.run(start, end));
    } else {
        LOG.info("Creating " + parallelism + " threads");
        final int[] partitions = new int[parallelism + 1];
        for (int i_thread = 0; i_thread <= parallelism; i_thread++)
            partitions[i_thread] = i_thread * (end - start) / parallelism + start;
        final Vector<RunnableRangeThread<T>> threads = new Vector<RunnableRangeThread<T>>();
        for (int i_thread = 0; i_thread < parallelism; i_thread++) {
            RunnableRangeThread<T> thread = new RunnableRangeThread<T>(r, partitions[i_thread],
                    partitions[i_thread + 1]);
            thread.setUncaughtExceptionHandler(h);
            threads.add(thread);
            threads.lastElement().start();
        }
        for (int i_thread = 0; i_thread < parallelism; i_thread++) {
            threads.get(i_thread).join();
            results.add(threads.get(i_thread).getResult());
        }
        if (!exceptions.isEmpty())
            throw new RuntimeException(exceptions.size() + " unhandled exceptions", exceptions.firstElement());
    }
    return results;
}

From source file:it.acubelab.smaph.SmaphUtils.java

/**
 * @param ftrCount//  w w w.  ja v a2 s . c o  m
 *            the number of features.
 * @return a vector containing all feature ids from 1 to ftrCount.
 */
public static Vector<Integer> getAllFtrVect(int ftrCount) {
    Vector<Integer> res = new Vector<>();
    for (int i = 1; i < ftrCount + 1; i++)
        res.add(i);
    return res;
}

From source file:de.innovationgate.wgpublisher.bi.BiBase.java

public static String getBrowserLanguageKey(javax.servlet.jsp.PageContext pageContext) {
    Enumeration enumLocales = pageContext.getRequest().getLocales();
    Vector vecLocales = new Vector();
    vecLocales.clear();//  www  .j  av  a  2  s . co  m
    String language = null;

    while (enumLocales.hasMoreElements())
        vecLocales.add((Locale) enumLocales.nextElement());
    for (int i = 0; i < vecLocales.size(); i++) {
        Locale currentLocale = (Locale) vecLocales.get(i);
        language = currentLocale.getLanguage().toUpperCase();
        if (language.equalsIgnoreCase("DE") || language.equalsIgnoreCase("EN"))
            break;
    }
    if (language == null || language.equals(""))
        language = "EN";
    return language;
}

From source file:Main.java

private static void addFiles(File root, Vector<String> files) {
    if (root == null)
        return;/* w ww  .  j a  va  2s  .co  m*/
    File[] listFiles = root.listFiles();
    if (listFiles == null)
        return;
    for (File f : listFiles) {

        if (f.isDirectory())
            addFiles(f, files);
        else if (f.getName().endsWith(".pfy"))
            files.add(f.getAbsolutePath());

    }

}

From source file:Main.java

/**
 * Searches parent node for matching child nodes and collects and returns
 * their matching attribute String values.
 *
 * @param node     The parent node/*w  w  w  .j  a v a  2 s  . c  o  m*/
 * @param elemName The matching child node element name
 * @param attr     The matching child node attribute name
 * @return List of attribute values
 */
public static Enumeration getChildrenAttributeValues(Node node, String elemName, String attr) {
    Vector vect = new Vector();
    NodeList nl = node.getChildNodes();
    int n = nl.getLength();
    for (int i = 0; i < n; i++) {
        Node nd = nl.item(i);
        if (nd.getNodeName().equals(elemName)) {
            vect.add(getAttribute(nd, attr));
        }
    }
    return vect.elements();
}

From source file:gov.nih.nci.ncicb.cadsr.evs.LexEVSQueryServiceImpl.java

public static CodedNodeSet restrictToSource(CodedNodeSet cns, String source) {
    if (cns == null)
        return cns;
    if (source == null || source.compareTo("*") == 0 || source.compareTo("") == 0
            || source.compareTo("ALL") == 0)
        return cns;

    LocalNameList contextList = null;//ww w.  java 2  s.  co  m
    LocalNameList sourceLnL = null;
    NameAndValueList qualifierList = null;

    Vector<String> w2 = new Vector<String>();
    w2.add(source);
    sourceLnL = vector2LocalNameList(w2);
    LocalNameList propertyLnL = null;
    CodedNodeSet.PropertyType[] types = new CodedNodeSet.PropertyType[] {
            CodedNodeSet.PropertyType.PRESENTATION };
    try {
        cns = cns.restrictToProperties(propertyLnL, types, sourceLnL, contextList, qualifierList);
    } catch (Exception ex) {
        System.out.println("restrictToSource throws exceptions.");
        return null;
    }
    return cns;
}

From source file:com.ripariandata.timberwolf.conf4j.ConfigFileParser.java

private static Vector<String> splitIntoLines(final String s, final int width) {
    String[] logicalLines = s.split("\\n");
    Vector<String> lines = new Vector<String>();
    for (String logicalLine : logicalLines) {
        if (logicalLine.length() <= width) {
            lines.add(logicalLine);
        } else {/* w  w  w  . j  av a 2s  .  c  o  m*/
            String[] tokens = logicalLine.split("\\s");
            String line = "";
            for (String token : tokens) {
                String proposedLine = line + (line == "" ? "" : " ") + token;
                if (proposedLine.length() > width) {
                    lines.add(line);

                    if (token.length() > width) {
                        int fullLinesForToken = token.length() / width;
                        for (int i = 0; i < fullLinesForToken; i++) {
                            lines.add(token.substring(i * width, (i + 1) * width));
                        }
                        line = token.substring(fullLinesForToken * width);
                    } else {
                        line = token;
                    }
                } else {
                    line = proposedLine;
                }
            }
            lines.add(line);
        }
    }
    return lines;
}

From source file:CreateNewType.java

private static Vector getDataTypes(Connection con, String typeToCreate) throws SQLException {
    String structName = null, distinctName = null, javaName = null;

    // create a vector of class DataType initialized with
    // the SQL code, the SQL type name, and two null entries
    // for the local type name and the creation parameter(s)

    Vector dataTypes = new Vector();
    dataTypes.add(new DataType(java.sql.Types.BIT, "BIT"));
    dataTypes.add(new DataType(java.sql.Types.TINYINT, "TINYINT"));
    dataTypes.add(new DataType(java.sql.Types.SMALLINT, "SMALLINT"));
    dataTypes.add(new DataType(java.sql.Types.INTEGER, "INTEGER"));
    dataTypes.add(new DataType(java.sql.Types.BIGINT, "BIGINT"));
    dataTypes.add(new DataType(java.sql.Types.FLOAT, "FLOAT"));
    dataTypes.add(new DataType(java.sql.Types.REAL, "REAL"));
    dataTypes.add(new DataType(java.sql.Types.DOUBLE, "DOUBLE"));
    dataTypes.add(new DataType(java.sql.Types.NUMERIC, "NUMERIC"));
    dataTypes.add(new DataType(java.sql.Types.DECIMAL, "DECIMAL"));
    dataTypes.add(new DataType(java.sql.Types.CHAR, "CHAR"));
    dataTypes.add(new DataType(java.sql.Types.VARCHAR, "VARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARCHAR, "LONGVARCHAR"));
    dataTypes.add(new DataType(java.sql.Types.DATE, "DATE"));
    dataTypes.add(new DataType(java.sql.Types.TIME, "TIME"));
    dataTypes.add(new DataType(java.sql.Types.TIMESTAMP, "TIMESTAMP"));
    dataTypes.add(new DataType(java.sql.Types.BINARY, "BINARY"));
    dataTypes.add(new DataType(java.sql.Types.VARBINARY, "VARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.LONGVARBINARY, "LONGVARBINARY"));
    dataTypes.add(new DataType(java.sql.Types.NULL, "NULL"));
    dataTypes.add(new DataType(java.sql.Types.OTHER, "OTHER"));
    dataTypes.add(new DataType(java.sql.Types.BLOB, "BLOB"));
    dataTypes.add(new DataType(java.sql.Types.CLOB, "CLOB"));

    DatabaseMetaData dbmd = con.getMetaData();
    ResultSet rs = dbmd.getTypeInfo();
    while (rs.next()) {
        int codeNumber = rs.getInt("DATA_TYPE");
        String dbmsName = rs.getString("TYPE_NAME");
        String createParams = rs.getString("CREATE_PARAMS");

        if (codeNumber == Types.STRUCT && structName == null)
            structName = dbmsName;/* w  w w.j a v a 2 s . c o m*/
        else if (codeNumber == Types.DISTINCT && distinctName == null)
            distinctName = dbmsName;
        else if (codeNumber == Types.JAVA_OBJECT && javaName == null)
            javaName = dbmsName;
        else {
            for (int i = 0; i < dataTypes.size(); i++) {
                // find entry that matches the SQL code, 
                // and if local type and params are not already set,
                // set them
                DataType type = (DataType) dataTypes.get(i);
                if (type.getCode() == codeNumber) {
                    type.setLocalTypeAndParams(dbmsName, createParams);
                }
            }
        }
    }

    if (typeToCreate.equals("s")) {
        int[] types = { Types.STRUCT, Types.DISTINCT, Types.JAVA_OBJECT };
        rs = dbmd.getUDTs(null, "%", "%", types);
        while (rs.next()) {
            String typeName = null;
            DataType dataType = null;

            if (dbmd.isCatalogAtStart())
                typeName = rs.getString(1) + dbmd.getCatalogSeparator() + rs.getString(2) + "."
                        + rs.getString(3);
            else
                typeName = rs.getString(2) + "." + rs.getString(3) + dbmd.getCatalogSeparator()
                        + rs.getString(1);

            switch (rs.getInt(5)) {
            case Types.STRUCT:
                dataType = new DataType(Types.STRUCT, typeName);
                dataType.setLocalTypeAndParams(structName, null);
                break;
            case Types.DISTINCT:
                dataType = new DataType(Types.DISTINCT, typeName);
                dataType.setLocalTypeAndParams(distinctName, null);
                break;
            case Types.JAVA_OBJECT:
                dataType = new DataType(Types.JAVA_OBJECT, typeName);
                dataType.setLocalTypeAndParams(javaName, null);
                break;
            }
            dataTypes.add(dataType);
        }
    }

    return dataTypes;
}