Example usage for java.util Vector size

List of usage examples for java.util Vector size

Introduction

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

Prototype

public synchronized int size() 

Source Link

Document

Returns the number of components in this vector.

Usage

From source file:Main.java

public static String[] getElementPath(Node node) {
    Vector vector = new Vector();
    for (; node != null; node = node.getParentNode())
        if (node.getNodeType() == 1)
            if (!hasSameNamedSibling(node))
                vector.addElement(node.getNodeName());
            else//  www . j  ava  2s.  c o m
                vector.addElement(node.getNodeName() + "[" + (getElementIndex(node) + 1) + "]");

    int i = vector.size();
    String as[] = new String[i];
    int j = i - 1;
    for (int k = 0; k < i;) {
        as[k] = (String) vector.elementAt(j);
        k++;
        j--;
    }

    return as;
}

From source file:com.nec.nsgui.action.cifs.CommonUtil.java

public static String getCurSessionsID(HttpServletRequest request) throws Exception {
    SessionManager sm = SessionManager.getInstance();
    Vector admvec = (Vector) (sm.getActiveSessionsInfo(request).get(NSActionConst.NSUSER_NSADMIN));
    Vector viwvec = (Vector) (sm.getActiveSessionsInfo(request).get(NSActionConst.NSUSER_NSVIEW));
    String sessionsId = new String();
    sessionsId = "";
    if (admvec != null) {
        for (int i = 0; i < admvec.size(); i++) {
            ClientInfoBean cib = (ClientInfoBean) admvec.get(i);
            String sid = cib.getSessionId();
            sessionsId = sessionsId + sid + " ";
        }/*  w  w  w .jav a  2 s.  co  m*/
    }
    if (viwvec != null) {
        for (int i = 0; i < viwvec.size(); i++) {
            ClientInfoBean cib = (ClientInfoBean) viwvec.get(i);
            String sid = cib.getSessionId();
            sessionsId = sessionsId + sid + " ";
        }
    }
    return sessionsId;
}

From source file:net.rim.ejde.internal.model.BlackBerryPropertiesFactory.java

/**
 * Gets the icons./* w  w  w  .j a  v a  2 s . c  om*/
 *
 * @param project
 *            the project
 * @param iProject
 *            the i project
 *
 * @return the icons
 */
protected static Icon[] getIcons(final Project project, final IProject iProject) {
    IJavaProject javaProject = JavaCore.create(iProject);
    final Vector<Icon> newIcons = new Vector<Icon>();
    Icon icon = null, rooloverIcon;

    Vector<File> iconFiles = project.getIcons();
    // we only get the first icon
    if ((iconFiles != null) && (iconFiles.size() > 0)) {
        final File iconFile = iconFiles.get(0);
        if (iconFile.exists()) {
            icon = new Icon(getTargetRelFilePath(iconFile, project, javaProject));
            newIcons.add(icon);
        }
    }

    iconFiles = project.getRolloverIcons();
    // we only get the first rollover icon
    if ((iconFiles != null) && (iconFiles.size() > 0)) {
        final File iconFile = iconFiles.get(0);
        if (iconFile.exists()) {
            // If there is only 1 icon it cannot be a focus icon, so set focus status based on existence of first icon
            rooloverIcon = new Icon(getTargetRelFilePath(iconFile, project, javaProject),
                    Boolean.valueOf(icon != null));
            newIcons.add(rooloverIcon);
        }
    }

    return newIcons.toArray(new Icon[newIcons.size()]);
}

From source file:FileUtil.java

public static Vector removeDuplicateDomains(Vector s) {
    int i = 0;//ww w  .ja v  a  2 s.com
    int j = 0;
    boolean duplicates = false;
    String str1 = "";
    String str2 = "";

    Vector v = new Vector();

    for (i = 0; i < s.size(); i++) {
        duplicates = false;
        for (j = (i + 1); j < s.size(); j++) {
            str1 = "";
            str2 = "";
            str1 = s.elementAt(i).toString().trim();
            str2 = s.elementAt(j).toString().trim();
            if (str1.indexOf('@') > -1) {
                str1 = str1.substring(str1.indexOf('@'));
            }
            if (str2.indexOf('@') > -1) {
                str2 = str2.substring(str2.indexOf('@'));
            }

            if (str1.equalsIgnoreCase(str2)) {
                duplicates = true;
            }

        }
        if (duplicates == false) {
            v.addElement(s.elementAt(i).toString().trim());
        }

    }

    return v;
}

From source file:com.sittinglittleduck.DirBuster.GenBaseCase.java

private static String getBaseCaseAgain(Manager manager, URL failurl, String failString) throws IOException {
    int failcode;
    String baseResponce = "";

    GetMethod httpget = new GetMethod(failurl.toString());
    // set the custom HTTP headers
    Vector HTTPheaders = manager.getHTTPHeaders();
    for (int a = 0; a < HTTPheaders.size(); a++) {
        HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a);
        /*/*from  ww w. j av  a 2s.co  m*/
         * Host header has to be set in a different way!
         */
        if (httpHeader.getHeader().startsWith("Host")) {
            httpget.getParams().setVirtualHost(httpHeader.getValue());
        } else {
            httpget.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue());
        }
    }
    httpget.setFollowRedirects(Config.followRedirects);

    // save the http responce code for the base case
    failcode = manager.getHttpclient().executeMethod(httpget);
    manager.workDone();

    // we now need to get the content as we need a base case!
    if (failcode == 200) {
        if (Config.debug) {
            System.out.println("DEBUG GenBaseCase: base case for " + failurl.toString() + "came back as 200!");
        }

        BufferedReader input = new BufferedReader(new InputStreamReader(httpget.getResponseBodyAsStream()));
        String tempLine;
        StringBuffer buf = new StringBuffer();
        while ((tempLine = input.readLine()) != null) {
            buf.append("\r\n" + tempLine);
        }
        baseResponce = buf.toString();
        input.close();

        // HTMLparse.parseHTML();

        // HTMLparse htmlParse = new HTMLparse(baseResponce, null);
        // Thread parse  = new Thread(htmlParse);
        // parse.start();

        // clean up the base case, based on the basecase URL
        baseResponce = FilterResponce.CleanResponce(baseResponce, failurl, failString);

        httpget.releaseConnection();

        /*
         * return the cleaned responce
         */
        return baseResponce;
    } else {
        /*
         * we have a big problem here as the server has returned an other responce code, for the same request
         * TODO: think of a way to deal with this!
         */
        return null;
    }
}

From source file:com.sittinglittleduck.DirBuster.GenBaseCase.java

public static BaseCase genURLFuzzBaseCase(Manager manager, String fuzzStart, String FuzzEnd)
        throws MalformedURLException, IOException {
    BaseCase baseCase = null;//  www  .j  a  v  a2  s  .  c  o m
    int failcode = 0;
    String failString = Config.failCaseString;
    String baseResponce = "";

    /*
     * markers for using regex instead
     */
    boolean useRegexInstead = false;
    String regex = null;

    URL failurl = new URL(fuzzStart + failString + FuzzEnd);

    GetMethod httpget = new GetMethod(failurl.toString());
    // set the custom HTTP headers
    Vector HTTPheaders = manager.getHTTPHeaders();
    for (int a = 0; a < HTTPheaders.size(); a++) {
        HTTPHeader httpHeader = (HTTPHeader) HTTPheaders.elementAt(a);
        /*
         * Host header has to be set in a different way!
         */
        if (httpHeader.getHeader().startsWith("Host")) {
            httpget.getParams().setVirtualHost(httpHeader.getValue());
        } else {
            httpget.setRequestHeader(httpHeader.getHeader(), httpHeader.getValue());
        }
    }
    httpget.setFollowRedirects(Config.followRedirects);

    // save the http responce code for the base case
    failcode = manager.getHttpclient().executeMethod(httpget);
    manager.workDone();

    if (failcode == 200) {
        if (Config.debug) {
            System.out.println("DEBUG GenBaseCase: base case for " + failurl.toString() + "came back as 200!");
        }

        BufferedReader input = new BufferedReader(new InputStreamReader(httpget.getResponseBodyAsStream()));
        String tempLine;
        StringBuffer buf = new StringBuffer();
        while ((tempLine = input.readLine()) != null) {
            buf.append("\r\n" + tempLine);
        }
        baseResponce = buf.toString();
        input.close();

        // clean up the base case, based on the basecase URL
        baseResponce = FilterResponce.CleanResponce(baseResponce, failurl, failString);

        if (Config.debug) {
            System.out.println("DEBUG GenBaseCase: base case was set to :" + baseResponce);
        }
    }

    httpget.releaseConnection();

    /*
     * create the base case object
     */
    baseCase = new BaseCase(null, failcode, false, failurl, baseResponce, null, useRegexInstead, regex);

    return baseCase;
}

From source file:Main.java

public static void writeContatctInfo(String accountId, Vector contactInfo, File contactInfoFile)
        throws IOException {
    contactInfoFile.getParentFile().mkdirs();
    FileOutputStream contactFileOutputStream = new FileOutputStream(contactInfoFile);
    DataOutputStream out = new DataOutputStream(contactFileOutputStream);
    out.writeUTF((String) contactInfo.get(0));
    out.writeInt(((Integer) (contactInfo.get(1))).intValue());
    for (int i = 2; i < contactInfo.size(); ++i) {
        out.writeUTF((String) contactInfo.get(i));
    }/*from  w  w  w  . java 2 s.  c o  m*/
    out.close();
}

From source file:Main.java

public static void cleanText(Node node) {
    try {/*from w  w w.j a v  a 2 s.  com*/
        NodeList childNodes = node.getChildNodes();
        int noChildren = childNodes.getLength();
        Node n = null;
        short type = 0;
        Vector rem = new Vector();
        for (int i = 0; i < noChildren; i++) {
            n = childNodes.item(i);
            type = n.getNodeType();
            if (type == Node.TEXT_NODE) {
                rem.add(n);
            } else if (type == Node.ELEMENT_NODE) {
                cleanText(n);
            }
        }
        for (int i = 0; i < rem.size(); i++) {
            node.removeChild((Node) rem.get(i));
        }
    } catch (Exception e) {
        //DebugUtil.debug(e);
    }
}

From source file:kenh.xscript.ScriptUtils.java

/**
 * Debug method for <code>Element</code>
 * @param element//from  w ww  .j  a v a2  s . com
 * @param level
 * @param stream
 */
private static final void debug_(Element element, int level, PrintStream stream) {
    String repeatStr = "    ";

    String prefix = StringUtils.repeat(repeatStr, level);
    stream.print(prefix + "<" + element.getClass().getCanonicalName());

    // Attribute output
    Map<String, String> attributes = element.getAttributes();
    if (attributes != null && attributes.size() > 0) {
        Set<String> keys = attributes.keySet();
        for (String key : keys) {
            stream.print(" " + key + "=\"" + attributes.get(key) + "\"");
        }
    }

    Vector<Element> children = element.getChildren();
    String text = element.getText();
    if ((children == null || children.size() == 0) && StringUtils.isBlank(text)) {
        stream.println("/>");
        return;
    } else {
        stream.println(">");

        // child elements
        if (children != null && children.size() > 0) {
            for (Element child : children) {
                debug_(child, level + 1, stream);
            }
        }

        // text/context
        if (StringUtils.isNotBlank(text)) {
            stream.println(prefix + repeatStr + "<![CDATA[" + text + "]]>");
        }

        stream.println(prefix + "</" + element.getClass().getCanonicalName() + ">");
    }
}

From source file:gdt.data.grain.Support.java

private static boolean itemExists(String name, Vector<String> vec) {
    if (name == null)
        return false;
    if (vec == null)
        return false;
    int cnt = vec.size();
    for (int i = 0; i < cnt; i++) {
        if (name.compareTo((String) vec.get(i)) == 0)
            return true;
    }//from w w  w.  ja  va 2s  .c  om
    return false;
}