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

public static String getParentPath(String childPath) {
    if (!childPath.equals("/")) {
        Vector<String> pathElements = new Vector<String>();
        StringTokenizer tokenizer = new StringTokenizer(childPath, "/");
        while (tokenizer.hasMoreTokens())
            pathElements.add(tokenizer.nextToken());

        StringBuffer parentPath = new StringBuffer().append("/");
        for (int i = 0; i < pathElements.size() - 1; i++)
            parentPath.append(pathElements.get(i)).append("/");
        return parentPath.toString();
    }//  w w  w .j  a  v  a2s  . c  o  m
    return null;

}

From source file:nz.net.catalyst.MaharaDroid.upload.http.RestClient.java

public static JSONObject UploadArtifact(String url, String token, String username, String blog, boolean draft,
        boolean allowcomments, String foldername, String tags, String filename, String title,
        String description, Context context) {
    Vector<String> pNames = new Vector<String>();
    Vector<String> pVals = new Vector<String>();

    if (title != null) {
        pNames.add("title");
        pVals.add(title);/*from  w w w .ja  v a 2  s  .co  m*/
    }
    if (description != null) {
        pNames.add("description");
        pVals.add(description);
    }
    if (token != null) {
        pNames.add("token");
        pVals.add(token);
    }
    if (username != null) {
        pNames.add("username");
        pVals.add(username);
    }
    if (foldername != null) {
        pNames.add("foldername");
        pVals.add(foldername);
    }
    if (tags != null) {
        pNames.add("tags");
        pVals.add(tags);
    }
    if (filename != null) {
        pNames.add("filename");
        pVals.add(filename);
    }
    if (blog != null) {
        pNames.add("blog");
        pVals.add(blog);
    }
    if (draft) {
        pNames.add("draft");
        pVals.add("true");
    }
    if (allowcomments) {
        pNames.add("allowcomments");
        pVals.add("true");
    }

    String[] paramNames, paramVals;
    paramNames = paramVals = new String[] {};
    paramNames = pNames.toArray(paramNames);
    paramVals = pVals.toArray(paramVals);

    return CallFunction(url, paramNames, paramVals, context);
}

From source file:com.peterphi.std.crypto.keygen.CaHelper.java

static private X509V3CertificateGenerator addSSLServerExtensions(X509V3CertificateGenerator gen) {
    gen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(false));
    gen.addExtension(X509Extensions.KeyUsage, false,
            new KeyUsage(KeyUsage.keyEncipherment | KeyUsage.digitalSignature));
    Vector<DERObjectIdentifier> extendedKeyUsageV = new Vector<DERObjectIdentifier>();
    extendedKeyUsageV.add(KeyPurposeId.id_kp_serverAuth);
    extendedKeyUsageV.add(KeyPurposeId.id_kp_clientAuth);
    // Netscape Server Gated Crypto
    // extendedKeyUsageV.add(new DERObjectIdentifier("2.16.840.1.113730.4.1"));
    // Microsoft Server Gated Crypto
    // extendedKeyUsageV
    // .add(new DERObjectIdentifier("1.3.6.1.4.1.311.10.3.3"));
    gen.addExtension(X509Extensions.ExtendedKeyUsage, getExtendedKeyUsageCriticality(),
            new ExtendedKeyUsage(extendedKeyUsageV));
    // gen.addExtension(X509Extensions.SubjectAlternativeName, false,
    // new GeneralNames(new GeneralName(GeneralName.rfc822Name,
    // "test@test.test")));
    // gen.addExtension(netscapeCertType, false, new DERBitString(
    // new byte[] { 64 }));

    return gen;/*w w  w  .  j  av  a2s  .  c  om*/
}

From source file:marytts.tools.voiceimport.DatabaseImportMain.java

private static File determineVoiceBuildingDir(String[] args) {
    // Determine the voice building directory in the following order:
    // 1. System property "user.dir"
    // 2. First command line argument
    // 3. current directory
    // 4. Prompt user via gui.
    // Do a sanity check -- do they exist, do they have a wav/ subdirectory?

    String voiceBuildingDir = null;
    Vector<String> candidates = new Vector<String>();
    candidates.add(System.getProperty("user.dir"));
    if (args.length > 0)
        candidates.add(args[0]);//from   www  .  j a v  a 2 s  . c o  m
    candidates.add("."); // current directory
    for (String dir : candidates) {
        if (dir != null && new File(dir).isDirectory() && new File(dir + "/wav").isDirectory()) {
            voiceBuildingDir = dir;
            break;
        }
    }
    if (voiceBuildingDir == null) { // need to ask user
        JFrame window = new JFrame("This is the Frames's Title Bar!");
        JFileChooser fc = new JFileChooser();
        fc.setDialogTitle("Choose Voice Building Directory");
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        System.out.println("Opening GUI....... ");
        //outDir.setText(file.getAbsolutePath());
        //System.exit(0);
        int returnVal = fc.showOpenDialog(window);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = fc.getSelectedFile();
            if (file != null)
                voiceBuildingDir = file.getAbsolutePath();
        }
    }
    System.setProperty("user.dir", voiceBuildingDir);
    if (voiceBuildingDir != null) {
        return new File(voiceBuildingDir);
    } else {
        return null;
    }
}

From source file:com.google.orkut.client.api.Util.java

static Vector forEachItemInList(JSONObject data, String key, Converter processor) {
    Vector items = new Vector();
    try {/*from  w  w w .j av  a  2  s  . c o  m*/
        JSONArray itemList = data.getJSONArray(key);
        if (itemList == null) {
            return items;
        }
        int numItems = itemList.length();
        for (int i = 0; i < numItems; i++) {
            JSONObject json = itemList.getJSONObject(i);
            try {
                items.add(processor.convert(json));
            } catch (CreationException e) {
                // ignore and skip conversion of this item
            } catch (RuntimeException e) {
                // we skip any runtime exception too. This is to catch any exception
                // that occurs while the object is being initialized.
                // TODO(Sachin Shenoy): Don't silently eat up exception, provide
                // mechanism to log these. 
            }
        }
    } catch (JSONException jse) {
        throw new RuntimeException("Unexpected json exception.", jse);
    }
    return items;
}

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

/**
 * Only Loads the Locales with empty Country and Variant
 *//*from  ww w.  j a  va  2s  .c  o m*/
public static void initializeLocales() {
    SchemaI18NService srv = getInstance();
    if (srv != null) {
        Vector<Locale> locs = srv.getLocales();
        if (locs.size() == 0) {
            for (Locale locale : Locale.getAvailableLocales()) {
                if (StringUtils.isNotEmpty(locale.getCountry())) {
                    locs.add(locale);
                }
            }
            Collections.sort(locs, new Comparator<Locale>() {
                public int compare(Locale o1, Locale o2) {
                    return o1.getDisplayName().compareTo(o2.getDisplayName());
                }
            });
        }
    }
}

From source file:marytts.datatypes.MaryDataType.java

/**
 * Provide the names of all registered data types that can be used as input.
 * /* w w  w . ja  v  a  2s .  c om*/
 * @return a vector containing the string names of data types.
 * @throws IllegalStateException
 *             if this method is called while registration is ongoing.
 */
public static Vector<String> getInputTypeStrings() {
    if (!registrationComplete)
        throw new IllegalStateException("Cannot inquire about data types while registration is ongoing");
    Vector<String> result = new Vector<String>(10);
    for (MaryDataType t : knownDataTypes) {
        if (t.isInputType())
            result.add(t.name());
    }
    return result;
}

From source file:Main.java

public static Vector getElementsByAttribValue(org.w3c.dom.Element element, String attrib, String val) {
    NodeList desElements = element.getElementsByTagName("*");
    Vector selElements = new Vector(desElements.getLength() / 10, 10);

    for (int i = 0; i < desElements.getLength(); i++) {
        org.w3c.dom.Node desElement = desElements.item(i);

        if (desElement.getNodeType() == org.w3c.dom.Element.ELEMENT_NODE) {
            NamedNodeMap attributeNodes = desElement.getAttributes();

            org.w3c.dom.Node selAttribNode = attributeNodes.getNamedItem(attrib);

            if (selAttribNode != null && selAttribNode.getNodeValue().equalsIgnoreCase(val)) {
                selElements.add(desElement);
            }/*from  ww  w  . j a  va 2 s.c o  m*/
        }
    }

    return selElements;
}

From source file:marytts.datatypes.MaryDataType.java

/**
 * Provide the names of all registered data types that can be used as output.
 * //  w ww .  j  av  a2s.c  om
 * @return a vector containing the string names of data types.
 * @throws IllegalStateException
 *             if this method is called while registration is ongoing.
 */
public static Vector<String> getOutputTypeStrings() {
    if (!registrationComplete)
        throw new IllegalStateException("Cannot inquire about data types while registration is ongoing");
    Vector<String> result = new Vector<String>(10);
    for (MaryDataType t : knownDataTypes) {
        if (t.isOutputType())
            result.add(t.name());
    }
    return result;
}

From source file:Main.java

public static Vector getElementsByTagAndAttribValue(org.w3c.dom.Element element, String tag, String attrib,
        String val) {
    NodeList desElements = element.getElementsByTagName(tag);
    Vector selElements = new Vector(desElements.getLength() / 10, 10);

    for (int i = 0; i < desElements.getLength(); i++) {
        org.w3c.dom.Node desElement = desElements.item(i);

        if (desElement.getNodeType() == org.w3c.dom.Element.ELEMENT_NODE) {
            NamedNodeMap attributeNodes = desElement.getAttributes();

            org.w3c.dom.Node selAttribNode = attributeNodes.getNamedItem(attrib);

            if (selAttribNode != null && selAttribNode.getNodeValue().equalsIgnoreCase(val)) {
                selElements.add(desElement);
            }/*from www  .ja va2 s . com*/
        }
    }

    return selElements;
}