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:org.zywx.wbpalmstar.plugin.uexzxing.qrcode.decoder.DecodedBitStreamParser.java

@SuppressWarnings("unchecked")
private static void decodeByteSegment(BitSource bits, StringBuffer result, int count,
        CharacterSetECI currentCharacterSetECI, Vector byteSegments, Hashtable hints) throws FormatException {
    byte[] readBytes = new byte[count];
    if (count << 3 > bits.available()) {
        throw FormatException.getFormatInstance();
    }// w  w  w. ja v  a2  s  .co m
    for (int i = 0; i < count; i++) {
        readBytes[i] = (byte) bits.readBits(8);
    }

    String encoding;
    if (currentCharacterSetECI == null) {
        // The spec isn't clear on this mode; see
        // section 6.4.5: t does not say which encoding to assuming
        // upon decoding. I have seen ISO-8859-1 used as well as
        // Shift_JIS -- without anything like an ECI designator to
        // give a hint.
        encoding = StringUtils.guessEncoding(readBytes, hints);
    } else {
        encoding = currentCharacterSetECI.getEncodingName();
    }
    if (null != encoding && !encoding.equals("UTF8")) {
        encoding = StringUtils.GBK;
    }
    try {
        int len = readBytes.length;
        ByteArrayBuffer buffer = new ByteArrayBuffer(len + 20);
        for (int i = 0; i < len; ++i) {
            int c = readBytes[i];
            if (c == 34 || c == 39 || c == 92 || c == 10 || c == 13 || c == 38) {
                buffer.append('\\');
            }
            buffer.append(c);
        }
        readBytes = buffer.toByteArray();
        result.append(new String(readBytes, encoding));
        //    result.append(new String(readBytes, encoding).replaceAll("\\s*|\t|\r|\n", "\\n"));
    } catch (UnsupportedEncodingException uce) {
        throw FormatException.getFormatInstance();
    }
    byteSegments.addElement(readBytes);
}

From source file:archive_v1.Retrieve.java

private void tapeId_tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tapeId_tableMouseClicked
    // TODO add your handling code here:
    Vector columnNames = new Vector();
    Vector data = new Vector();
    int columns = 0;
    String tape_id = tapeId_table.getModel().getValueAt(tapeId_table.getSelectedRow(), 0).toString();

    String sql = "", archive_date = "", archiver_name = "";
    create_archive_connection();/*from w  w w . ja v a  2  s  .  c o m*/
    try {
        statement_archive = conn_archive.createStatement();
        sql = "select * from archive where tape_id = '" + tape_id + "'";
        rs_archive = statement_archive.executeQuery(sql);
        columnNames.addElement("File Name");
        columnNames.addElement("size(bytes)");
        // Get row data 

        while (rs_archive.next()) {

            Vector row = new Vector(columns);
            row.addElement(rs_archive.getString("program_name"));
            row.addElement(rs_archive.getString("size"));
            archive_date = rs_archive.getString("archive_date");
            archiver_name = rs_archive.getString("archiver_name");
            data.addElement(row);

        }
        // populated data into table 
        DefaultTableModel tableModel = new DefaultTableModel(data, columnNames);
        pgmList_table.setModel(tableModel);

        archive_date_label.setText(archive_date);
        archiever_name_label.setText(archiver_name);
        // this.pgmList_table.setModel(DbUtils.resultSetToTableModel(rs_archive));
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        try {
            conn_archive.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}

From source file:com.duroty.application.admin.manager.AdminManager.java

/**
 * DOCUMENT ME!//from  w ww . j ava 2  s .  c  om
 *
 * @param hsession DOCUMENT ME!
 * @param idint DOCUMENT ME!
 *
 * @throws AdminException DOCUMENT ME!
 */
public Vector roles(Session hsession) throws AdminException {
    Vector roles = new Vector();

    try {
        Criteria crit = hsession.createCriteria(Roles.class);
        crit.addOrder(Order.asc("rolName"));

        ScrollableResults scroll = crit.scroll();

        while (scroll.next()) {
            Roles role = (Roles) scroll.get(0);
            roles.addElement(new RoleObj(role.getRolIdint(), role.getRolName()));
        }

        return roles;
    } catch (Exception ex) {
        throw new AdminException(ex);
    } finally {
        GeneralOperations.closeHibernateSession(hsession);
    }
}

From source file:org.openxdata.server.sms.FormSmsParser.java

private void setQuestionAnswer(QuestionData questionData, org.openxdata.model.FormData formData, String answer,
        List<String> errors) {
    //TODO May need to handle dynamic optiondef
    QuestionDef questionDef = questionData.getDef();
    if (questionDef.getType() == QuestionDef.QTN_TYPE_LIST_EXCLUSIVE
            || questionDef.getType() == QuestionDef.QTN_TYPE_LIST_EXCLUSIVE_DYNAMIC) {
        questionData.setAnswer(getOptionData(questionDef, answer, errors));
        formData.updateDynamicOptions(questionData, false);
    } else if (questionDef.getType() == QuestionDef.QTN_TYPE_LIST_MULTIPLE) {
        Vector<OptionData> optionAnswers = new Vector<OptionData>();
        String values[] = answer.split(" ");
        for (int index = 0; index < values.length; index++)
            optionAnswers.addElement(getOptionData(questionDef, values[index], errors));
        questionData.setAnswer(optionAnswers);
    } else if (questionDef.getType() == QuestionDef.QTN_TYPE_BOOLEAN)
        questionData.setAnswer(answer);/* w w  w  . j a  v  a2s .  c  o m*/
    else
        questionData.setTextAnswer(answer);
}

From source file:com.adito.boot.Util.java

/**
 * Split a string into an array taking into account delimiters, quotes and
 * escapes/* ww w .ja  va2 s . c  o m*/
 * 
 * @param str string to split
 * @param delim delimiter
 * @param quote quote character
 * @param escape escape character
 * @return array
 */

public static String[] splitString(String str, char delim, char quote, char escape) {
    Vector v = new Vector();
    StringBuffer str1 = new StringBuffer();
    char ch = ' ';
    boolean inQuote = false;
    boolean escaped = false;

    for (int i = 0; i < str.length(); i++) {
        ch = str.charAt(i);

        if ((escape != -1) && (ch == escape) && !escaped) {
            escaped = true;
        } else {
            if ((quote != -1) && (ch == quote) && !escaped) {
                inQuote = !inQuote;
            } else if (!inQuote && (ch == delim && !escaped)) {
                v.addElement(str1.toString());
                str1.setLength(0);
            } else {
                str1.append(ch);
            }
            if (escaped) {
                escaped = false;
            }
        }
    }

    if (str.length() > 0) {
        v.addElement(str1.toString());

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

    return array;
}

From source file:org.apache.jasper.compiler.JspConfig.java

private void processWebDotXml(ServletContext ctxt) throws JasperException {

    InputStream is = ctxt.getResourceAsStream(WEB_XML);
    if (is == null) {
        // no web.xml
        return;//  w  w w  . j  a v a2 s.co m
    }

    ParserUtils pu = new ParserUtils();
    TreeNode webApp = pu.parseXMLDocument(WEB_XML, is);
    if (webApp == null || !"2.4".equals(webApp.findAttribute("version"))) {
        defaultIsELIgnored = "true";
        return;
    }
    TreeNode jspConfig = webApp.findChild("jsp-config");
    if (jspConfig == null) {
        return;
    }

    jspProperties = new Vector();
    Iterator jspPropertyList = jspConfig.findChildren("jsp-property-group");
    while (jspPropertyList.hasNext()) {

        TreeNode element = (TreeNode) jspPropertyList.next();
        Iterator list = element.findChildren();

        Vector urlPatterns = new Vector();
        String pageEncoding = null;
        String scriptingInvalid = null;
        String elIgnored = null;
        String isXml = null;
        Vector includePrelude = new Vector();
        Vector includeCoda = new Vector();

        while (list.hasNext()) {

            element = (TreeNode) list.next();
            String tname = element.getName();

            if ("url-pattern".equals(tname))
                urlPatterns.addElement(element.getBody());
            else if ("page-encoding".equals(tname))
                pageEncoding = element.getBody();
            else if ("is-xml".equals(tname))
                isXml = element.getBody();
            else if ("el-ignored".equals(tname))
                elIgnored = element.getBody();
            else if ("scripting-invalid".equals(tname))
                scriptingInvalid = element.getBody();
            else if ("include-prelude".equals(tname))
                includePrelude.addElement(element.getBody());
            else if ("include-coda".equals(tname))
                includeCoda.addElement(element.getBody());
        }

        if (urlPatterns.size() == 0) {
            continue;
        }

        // Add one JspPropertyGroup for each URL Pattern.  This makes
        // the matching logic easier.
        for (int p = 0; p < urlPatterns.size(); p++) {
            String urlPattern = (String) urlPatterns.elementAt(p);
            String path = null;
            String extension = null;

            if (urlPattern.indexOf('*') < 0) {
                // Exact match
                path = urlPattern;
            } else {
                int i = urlPattern.lastIndexOf('/');
                String file;
                if (i >= 0) {
                    path = urlPattern.substring(0, i + 1);
                    file = urlPattern.substring(i + 1);
                } else {
                    file = urlPattern;
                }

                // pattern must be "*", or of the form "*.jsp"
                if (file.equals("*")) {
                    extension = "*";
                } else if (file.startsWith("*.")) {
                    extension = file.substring(file.indexOf('.') + 1);
                } else {
                    if (log.isWarnEnabled()) {
                        log.warn(Localizer.getMessage("jsp.warning.bad.urlpattern.propertygroup", urlPattern));
                    }
                    continue;
                }
            }

            JspProperty property = new JspProperty(isXml, elIgnored, scriptingInvalid, pageEncoding,
                    includePrelude, includeCoda);
            JspPropertyGroup propertyGroup = new JspPropertyGroup(path, extension, property);

            jspProperties.addElement(propertyGroup);
        }
    }
}

From source file:org.dhatim.cdr.SmooksResourceConfigurationList.java

/**
 * Get all SmooksResourceConfiguration entries targeted at the specified profile set. 
 * @param profileSet The profile set to searh against.
 * @return All SmooksResourceConfiguration entries targeted at the specified profile set.
 *///from ww  w.  j a  v a  2  s  .c  om
public SmooksResourceConfiguration[] getTargetConfigurations(ProfileSet profileSet) {
    Vector<SmooksResourceConfiguration> matchingSmooksResourceConfigurationsColl = new Vector<SmooksResourceConfiguration>();
    SmooksResourceConfiguration[] matchingSmooksResourceConfigurations;

    // Iterate over the SmooksResourceConfigurations defined on this list.
    for (int i = 0; i < size(); i++) {
        SmooksResourceConfiguration resourceConfig = get(i);
        ProfileTargetingExpression[] profileTargetingExpressions = resourceConfig
                .getProfileTargetingExpressions();

        for (int expIndex = 0; expIndex < profileTargetingExpressions.length; expIndex++) {
            ProfileTargetingExpression expression = profileTargetingExpressions[expIndex];

            if (expression.isMatch(profileSet)) {
                matchingSmooksResourceConfigurationsColl.addElement(resourceConfig);
                break;
            } else {
                logger.debug("Resource [" + resourceConfig + "] not targeted at profile ["
                        + profileSet.getBaseProfile() + "].  Sub Profiles: [" + profileSet + "]");
            }
        }
    }

    matchingSmooksResourceConfigurations = new SmooksResourceConfiguration[matchingSmooksResourceConfigurationsColl
            .size()];
    matchingSmooksResourceConfigurationsColl.toArray(matchingSmooksResourceConfigurations);

    return matchingSmooksResourceConfigurations;
}

From source file:com.toughra.mlearnplayer.EXEStrMgr.java

/**
 * Get a vector of the locales that are available
 * /*  ww  w.  j  a va 2 s. c  om*/
 * @param res
 * @param resName
 * @return 
 */
public Vector getLocaleList(Resources res, String resName) {
    Vector retVal = new Vector();
    Enumeration localesAvail = host.localeRes.listL10NLocales(localeResName);
    while (localesAvail.hasMoreElements()) {
        retVal.addElement(localesAvail.nextElement());
    }

    return retVal;
}

From source file:orca.shirako.container.RemoteRegistryCache.java

/**
 * Perform a single query of the XMLRPC registry
  * @return result list/*from  w w  w .  ja  v a  2  s. c o  m*/
 */
@SuppressWarnings("unchecked")
public List<String> singleQuery() {

    if (registryUrl == null) {
        logger.info("No registry URL specified, skipping query");
        return null;
    }
    logger.info("Contacting external registry at " + registryUrl);

    XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
    try {
        config.setServerURL(new URL(registryUrl));
    } catch (MalformedURLException e) {
        logger.error("Invalid registry URL " + registryUrl + ", caching thread terminating");
        return null;
    }

    XmlRpcClient client = new XmlRpcClient();
    client.setConfig(config);

    HttpClient h = new HttpClient(connMgr);
    // set this transport factory for host-specific SSLContexts to work
    XmlRpcCommonsTransportFactory f = new XmlRpcCommonsTransportFactory(client);
    f.setHttpClient(h);
    client.setTransportFactory(f);

    // set null identity - queries are not checked at the registry
    mkm.setCurrentGuid(null);

    Vector<Object> params = new Vector<Object>();
    // add a list of guids we already know      
    params.addElement(knownGuids());
    // we only want essential info on the actors (name, guid, location, cert)
    params.addElement(true);

    try {
        Map<String, Map<String, String>> mapResult = (Map<String, Map<String, String>>) client
                .execute(registryQueryMethod, params);
        // merge the results
        synchronized (cache) {
            // ignore the status entry if present
            mapResult.remove("STATUS");
            for (Map.Entry<String, Map<String, String>> entry : mapResult.entrySet()) {
                logger.info("Merging entry for actor " + entry.getKey());
                if (localActorGuids.contains(entry.getKey()))
                    logger.info("Registry returned local actor from query: " + entry.getKey() + ", skipping");
                else
                    nonMtCacheMerge(entry.getKey(), entry.getValue());
            }
        }
        return new ArrayList(mapResult.keySet()); // return list of new guids
    } catch (XmlRpcException e) {
        logger.error("Error querying XMLRPC registry, continuing");
        return null;
    }
}

From source file:com.jaspersoft.ireport.designer.data.fieldsproviders.ejbql.EJBQLFieldsReader.java

@SuppressWarnings("unchecked")
public Vector getFields(Object obj) {

    Vector fields = new Vector();
    java.beans.PropertyDescriptor[] pd = org.apache.commons.beanutils.PropertyUtils
            .getPropertyDescriptors(obj.getClass());
    for (int nd = 0; nd < pd.length; ++nd) {
        String fieldName = pd[nd].getName();
        if (pd[nd].getPropertyType() != null && pd[nd].getReadMethod() != null) {
            String returnType = pd[nd].getPropertyType().getName();
            JRDesignField field = new JRDesignField();
            field.setName(fieldName);/*from  w  w w  .ja v  a  2 s.  c  om*/
            field.setValueClassName(Misc.getJRFieldType(returnType));
            //field.setDescription(""); //Field returned by " +methods[i].getName() + " (real type: "+ returnType +")");
            fields.addElement(field);
        }
    }

    return fields;

}