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:edu.ku.brc.specify.tasks.services.PickListUtils.java

/**
 * @param pl//from  w w  w .jav  a  2s  . c  o m
 * @param bpl
 * @return
 */
private static boolean pickListsEqual(final PickList pl, final BldrPickList bpl) {
    if (!StringUtils.equals(pl.getName(), bpl.getName()))
        return false;
    if (!StringUtils.equals(pl.getTableName(), bpl.getTableName()))
        return false;
    if (!StringUtils.equals(pl.getFieldName(), bpl.getFieldName()))
        return false;
    if (!StringUtils.equals(pl.getFormatter(), bpl.getFormatter()))
        return false;

    if (!equals(pl.getType(), bpl.getType()))
        return false;
    if (!equals(pl.getReadOnly(), bpl.getReadOnly()))
        return false;
    if (!equals(pl.getSizeLimit(), bpl.getSizeLimit()))
        return false;
    if (!equals(pl.getIsSystem(), bpl.getIsSystem()))
        return false;
    if (!equals(pl.getSortType(), bpl.getSortType()))
        return false;

    Vector<PickListItem> plis = new Vector<PickListItem>(pl.getPickListItems());
    Vector<BldrPickListItem> bplis = bpl.getItems();

    if ((plis.size() == 0) && (bplis == null || bplis.size() == 0))
        return true;

    if (plis.size() != bplis.size())
        return false;

    if (pl.getSortType() == PickListIFace.PL_ORDINAL_SORT) {
        Collections.sort(plis, pliComparatorOrd);
        Collections.sort(bplis);
    } else {
        Collections.sort(plis, pliComparatorTitle);
        Collections.sort(bplis, bldrPliComparatorTitle);
    }

    for (int i = 0; i < plis.size(); i++) {
        PickListItem pli = plis.get(i);
        BldrPickListItem bpli = bplis.get(i);
        //System.out.println("["+pli.getOrdinal()+"]["+bpli.getOrdinal()+"]["+pli.getTitle()+"]["+bpli.getTitle()+"]["+pli.getValue()+"]["+bpli.getValue()+"]");
        if (!StringUtils.equals(pli.getTitle(), bpli.getTitle()))
            return false;
        if (!StringUtils.equals(pli.getValue(), bpli.getValue()))
            return false;
    }

    return true;
}

From source file:com.fluidops.iwb.deepzoom.DZConvert.java

/**
 * Saves strings as text to the given file
 * @param lines the image to be saved//ww  w  . jav  a2  s .c  om
 * @param file the file to which it is saved
 */
private static void saveText(Vector lines, File file) throws IOException {
    PrintStream ps = null;
    try {
        FileOutputStream fos = new FileOutputStream(file);
        ps = new PrintStream(fos);
        for (int i = 0; i < lines.size(); i++)
            ps.println((String) lines.elementAt(i));
    } catch (IOException e) {
        throw new IOException("Unable to write to text file: " + file);
    } finally {
        IOUtils.closeQuietly(ps);
    }
}

From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java

/**
 * Returns a list of all Strain  /*w w  w. j  a  v a  2s . c o  m*/
 * Used for submission and search screens
 * 
 * @return Strain
 * @throws Exception
 */
private static List getQueryStrainList(HttpServletRequest inRequest, String inAddBlank) throws Exception {
    log.debug("Entering NewDropdownUtil.getQueryStrainList");

    // Get values for dropdown lists for Strain
    List<DropdownOption> theReturnList = new ArrayList<DropdownOption>();
    Strain str = new Strain();
    Vector strain = str.retrieveAllWhere("strain_name IS NOT NULL ORDER BY strain_name");
    for (int j = 0; j < strain.size(); j++) {
        Strain Str = (Strain) strain.elementAt(j);
        if (Str.getStrain_id() != null) {
            DropdownOption theOption = new DropdownOption(Str.getStrain_name(), Str.getStrain_id().toString());
            theReturnList.add(theOption);
        }
    }
    log.debug("Exiting getQueryStrainList.size " + theReturnList.size());
    return theReturnList;
}

From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java

/**
 * Returns a list of all Staining  // w  w  w  .  j  a v a2  s  .  c om
 * Used for submission and search screens
 * 
 * @return Staining
 * @throws Exception
 */
private static List getQueryStainingList(HttpServletRequest inRequest, String inAddBlank) throws Exception {
    log.debug("Entering NewDropdownUtil.getQueryStainingList");

    // Get values for dropdown lists for Staining
    List<DropdownOption> theReturnList = new ArrayList<DropdownOption>();
    Stain st = new Stain();
    Vector stain = st.retrieveAllWhere("stain_name IS NOT NULL ORDER BY stain_description");
    for (int j = 0; j < stain.size(); j++) {
        Stain St = (Stain) stain.elementAt(j);
        if (St.getStain_id() != null) {
            DropdownOption theOption = new DropdownOption(St.getStain_description(),
                    St.getStain_id().toString());
            theReturnList.add(theOption);
        }
    }
    log.debug("Exiting getQueryStainingList.size " + theReturnList.size());
    return theReturnList;
}

From source file:com.funambol.framework.tools.WBXMLTools.java

private static String parseWBXML(SyncMLParser parser, boolean[] inTag) throws IOException {
    /**/*from w  ww . j a  v a  2 s  .c  o m*/
     * inTag[0]: flag for tag <Put> or <Results>
     * inTag[1]: flag for tag <Item> not in Put or Results
     * inTag[2]: flag for tag <Data> (inside a Item not in Put or Results)
     * inTag[3]: flag for tag <Cred>
     * inTag[4]: set if tag Meta inside Cred contains "b64"
     * inTag[5]: set if tag Meta inside Cred contains "auth-md5"
     */
    StringBuffer buf = new StringBuffer();
    boolean leave = false;

    String tagName = null;
    String text = null;

    do {
        ParseEvent event = parser.read();
        switch (event.getType()) {
        case Xml.START_TAG:
            tagName = event.getName();

            buf.append("<");
            buf.append(tagName);
            Vector attrs = event.getAttributes();
            if (attrs != null) {
                for (int i = 0; i < attrs.size(); i++) {
                    Attribute attr = (Attribute) attrs.elementAt(i);
                    buf.append(" ");
                    buf.append(attr.getName());
                    buf.append("='");
                    buf.append(attr.getValue());
                    buf.append("'");
                }
            }
            buf.append(">");

            //
            //This is util for replace the Data content if contains
            //illegal character
            //
            if (!inTag[0]) {
                inTag[0] = ("Put".equals(tagName) || "Results".equals(tagName));
            }

            if (!inTag[0]) {
                if (!inTag[1]) {
                    inTag[1] = "Item".equals(tagName);
                } else if (inTag[1]) {
                    inTag[2] = "Data".equals(tagName);
                }
            }

            //
            //This is util to establish if the auth-md5 credential are
            //encoded in Base64
            //
            if (!inTag[3]) {
                inTag[3] = "Cred".equals(tagName);
            }

            text = parseWBXML(parser, inTag);

            if (inTag[3]) {
                if ("Meta".equals(tagName)) {
                    inTag[4] = (text.indexOf("b64") >= 0);
                    inTag[5] = (text.indexOf("auth-md5") >= 0);
                    buf.append(text);
                    text = parseWBXML(parser, inTag);
                }
            }

            buf.append(text);
            break;

        case Xml.END_TAG:
            tagName = event.getName();
            if (tagName != null) {
                if (tagName.equals("Put") || tagName.equals("Results")) {
                    if (inTag[0]) {
                        inTag[0] = false;
                    }
                } else if (tagName.equals("Cred")) {
                    if (inTag[3]) {
                        inTag[3] = false;
                        inTag[4] = false;
                        inTag[5] = false;
                    }
                } else if (tagName.equals("Item")) {
                    if (inTag[1]) {
                        inTag[1] = false;
                    }
                } else if (tagName.equals("Data")) {
                    if (inTag[2]) {
                        inTag[2] = false;
                    }
                }
            }
            buf.append("</");
            buf.append(event.getName());
            buf.append(">");
            leave = true;
            break;

        case Xml.END_DOCUMENT:
            leave = true;
            break;

        case Xml.TEXT:
            text = event.getText();

            if (!inTag[0] && inTag[1] && inTag[2]) {
                text = replaceDataContent(text);
            }
            buf.append(text);
            break;

        case Xml.WAP_EXTENSION:
            text = event.getText();

            if (!inTag[0] && inTag[1] && inTag[2]) {
                text = replaceDataContent(text);
            }

            if (event instanceof WapExtensionEvent) {
                WapExtensionEvent e = (WapExtensionEvent) event;
                Object content = e.getContent();

                if (inTag[5] && !inTag[4] && content != null) {
                    if (content instanceof byte[]) {
                        text = new String(Base64.encode((byte[]) content));
                    }
                }
            }

            buf.append(text);
            break;

        case Xml.WHITESPACE:
            break;

        default:
        }
    } while (!leave);

    return buf.toString();
}

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();
    }//from w ww.ja  v  a  2 s.c  o m
    return null;

}

From source file:gov.nih.nci.evs.browser.utils.CodeSearchUtils.java

public static LocalNameList vector2LocalNameList(Vector<String> v) {
    if (v == null)
        return null;
    LocalNameList list = new LocalNameList();
    for (int i = 0; i < v.size(); i++) {
        String vEntry = (String) v.elementAt(i);
        list.addEntry(vEntry);//  ww w.j a  v  a2 s . c o  m
    }
    return list;
}

From source file:com.ushahidi.android.app.Util.java

/**
 * Create csv/*  www .  j a va2 s . c  om*/
 * 
 * @param Vector<String> text
 * @return csv
 */
public static String implode(Vector<String> text) {
    String implode = "";
    int i = 0;
    for (String value : text) {
        implode += i == text.size() - 1 ? value : value + ",";
        i++;
    }

    return implode;
}

From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java

/**
 * Returns a list of all Institution  //from   w ww  .  j  a  va2 s  .  c om
 * Used for submission and search screens
 * 
 * @return Institution
 * @throws Exception
 */
private static List getQueryInstitutionList(HttpServletRequest inRequest, String inAddBlank) throws Exception {
    log.debug("Entering NewDropdownUtil.getQueryInstitutionList");

    Annotations annot = new Annotations();
    Login login = new Login();
    // Get values for dropdown lists for Institution
    List<DropdownOption> theReturnList = new ArrayList<DropdownOption>();

    Vector logins = login.retrieveAllWhere("loginuid is not null order by pi_name");

    Hashtable v1 = new Hashtable();
    for (int j = 0; j < logins.size(); j++) {
        Login LogIn = (Login) logins.elementAt(j);

        if (LogIn.getLoginuid() != null) {
            if (LogIn.getInstitute() != null) {

                Vector v = annot.retrieveByANNOTATIONS__DONATOR_ID(LogIn.getLoginuid());

                if (v.size() != 0) {
                    DropdownOption theOption = new DropdownOption(LogIn.getInstitute(), LogIn.getInstitute());
                    theReturnList.add(theOption);
                } //if
            } //if
        } //if
    } //for

    log.debug("Exiting getQueryInstitutionList.size " + theReturnList.size());
    return theReturnList;
}

From source file:gov.nih.nci.caIMAGE.util.NewDropdownUtil.java

/**
 * Returns a list of all Institution  // ww w  . j  a  v a2s.com
 * Used for submission and search screens
 * 
 * @return Institution
 * @throws Exception
 */
private static List getQueryPIList(HttpServletRequest inRequest, String inAddBlank) throws Exception {
    log.debug("Entering NewDropdownUtil.getQueryPIList");

    Annotations annot = new Annotations();
    Login login = new Login();
    // Get values for dropdown lists for Institution
    List<DropdownOption> theReturnList = new ArrayList<DropdownOption>();

    Vector logins = login.retrieveAllWhere("loginuid is not null order by pi_name");

    Hashtable v1 = new Hashtable();
    for (int j = 0; j < logins.size(); j++) {
        Login LogIn = (Login) logins.elementAt(j);

        if (LogIn.getLoginuid() != null) {
            if (LogIn.getInstitute() != null) {

                Vector v = annot.retrieveByANNOTATIONS__DONATOR_ID(LogIn.getLoginuid());

                if (v.size() != 0) {
                    DropdownOption theOption = new DropdownOption(LogIn.getPi_name(),
                            LogIn.getLoginuid().toString());
                    theReturnList.add(theOption);
                } //if
            } //if
        } //if
    } //for

    log.debug("Exiting getQueryPIList.size " + theReturnList.size());
    return theReturnList;
}