Package java.util

Examples of java.util.StringTokenizer


        }
        return buf.toString();
    }

    public static byte[] decodeMacAddress(final String mac) {
        final StringTokenizer tokens = new StringTokenizer(mac, "-");
        if(tokens.countTokens() != MAC_ADDRESS_TOKENS) {
            throw new IllegalArgumentException("Unexpected mac address representation: " + mac);
        }
        final StringBuilder buf = new StringBuilder(MAC_ADDRESS_TOKENS * 2);
        for(int i = 0; i < MAC_ADDRESS_TOKENS; i++) {
            buf.append(tokens.nextToken());
        }
        char[] c = buf.toString().toCharArray();
        return StringUtils.decodeHex(c);
    }
View Full Code Here


   * @param str Full string
   * @param splitter Characters to split on
   * @return List of String pieces from full string
   */
    public static List<String> split(String str, String splitter) {
        StringTokenizer tokens = new StringTokenizer(str, splitter);
        ArrayList<String> l = new ArrayList<String>(tokens.countTokens());
        while(tokens.hasMoreTokens()) {
            l.add(tokens.nextToken());
        }
        return l;
    }
View Full Code Here

   * @param splitter Characters to split on
   * @return List of String pieces from full string
   */
  public static List splitPreservingQuotedSubstring(String str, String splitter) {
    ArrayList l = new ArrayList();
    StringTokenizer tokens = new StringTokenizer(str, splitter);
        StringBuffer token = new StringBuffer();
    while(tokens.hasMoreTokens()) {
            token.setLength(0);
            token.append(tokens.nextToken());
            if ( token.charAt(0) == '"' ) {
                token.deleteCharAt(0);
                while ( tokens.hasMoreTokens() ) {
                    token.append(Constants.SPACE + tokens.nextToken());
                    if ( token.charAt(token.length() -1) == '"' ) {
                        token.deleteCharAt(token.length() - 1);
                        break;
                    }
                }
View Full Code Here

   * @param delimiter Characters which are delimit tokens
   * @return List of string tokens contained in the tokenized string
   */
  public static List getTokens(String str, String delimiter) {
    ArrayList l = new ArrayList();
    StringTokenizer tokens = new StringTokenizer(str, delimiter);
    while(tokens.hasMoreTokens()) {
      l.add(tokens.nextToken());
    }
    return l;
    }
View Full Code Here

     * @param str String to be tokenized
     * @param delimiter Characters which are delimit tokens
     * @return Number of tokens seperated by the delimiter
     */
    public static int getTokenCount(String str, String delimiter) {
        StringTokenizer tokens = new StringTokenizer(str, delimiter);
        return tokens.countTokens();
    }   
View Full Code Here

        if (text == null  ||  text.length() == 0) {
            return defaultValue;
        }
        final StringBuffer buf = new StringBuffer();
        String token;
        for (final StringTokenizer iter = new StringTokenizer(text, "_");  iter.hasMoreTokens();) { //$NON-NLS-1$
            token = iter.nextToken().toLowerCase();
            if (buf.length() > 0) {
                buf.append(' ');
            }
            buf.append(Character.toUpperCase(token.charAt(0)));
            buf.append(token.substring(1));
View Full Code Here

     * @since 5.0
     */
    public static String collapseWhitespace(String raw) {
        StringBuffer rv = new StringBuffer(raw.length());

        StringTokenizer izer = new StringTokenizer(raw, " "); //$NON-NLS-1$
        while (izer.hasMoreTokens()) {
            String tok = izer.nextToken();
            // Added one last check here so we don't append a "space" on the end of the string
            rv.append(tok);
            if( izer.hasMoreTokens() ) {
                rv.append(' ');
            }
        } // endwhile

        return rv.toString();
View Full Code Here

        StandardXMLTranslator translator = new StandardXMLTranslator(new StreamSource(new StringReader(sourceXML)));
        compareDocuments(sourceXML, translator.getString());
    }   
   
    private void compareDocuments(String expectedDoc, String actualDoc) {
        StringTokenizer tokens1 = new StringTokenizer(expectedDoc, "\r\n"); //$NON-NLS-1$
        StringTokenizer tokens2 = new StringTokenizer(actualDoc, "\n");//$NON-NLS-1$
        while(tokens1.hasMoreTokens()){
            String token1 = tokens1.nextToken().trim();
            if(!tokens2.hasMoreTokens()){
                fail("XML doc mismatch: expected=" + token1 + "\nactual=none");//$NON-NLS-1$ //$NON-NLS-2$
            }
            String token2 = tokens2.nextToken().trim();
            assertEquals("XML doc mismatch: ", token1, token2); //$NON-NLS-1$
        }
        if(tokens2.hasMoreTokens()){
            fail("XML doc mismatch: expected=none\nactual=" + tokens2.nextToken().trim());//$NON-NLS-1$
        }
    }   
View Full Code Here

        return names.xmlNames;
    }

    static PdfArray createDestinationArray(String value, PdfWriter writer) {
        PdfArray ar = new PdfArray();
        StringTokenizer tk = new StringTokenizer(value);
        int n = Integer.parseInt(tk.nextToken());
        ar.add(writer.getPageReference(n));
        if (!tk.hasMoreTokens()) {
            ar.add(PdfName.XYZ);
            ar.add(new float[]{0, 10000, 0});
        }
        else {
            String fn = tk.nextToken();
            if (fn.startsWith("/"))
                fn = fn.substring(1);
            ar.add(new PdfName(fn));
            for (int k = 0; k < 4 && tk.hasMoreTokens(); ++k) {
                fn = tk.nextToken();
                if (fn.equals("null"))
                    ar.add(PdfNull.PDFNULL);
                else
                    ar.add(new PdfNumber(fn));
            }
View Full Code Here

      }

      if (mBeans != null) {
        for (Iterator iterator = mBeans.iterator(); iterator.hasNext();) {
          String mBean = (String) iterator.next();
          StringTokenizer st = new StringTokenizer((String) attlist.get(name), ",");
          while (st.hasMoreTokens()) {
            String token = st.nextToken();
            if (token.equals("*")) {
              // Get all mbean's attributes
              try {
                List attributes = MXWrapper.getAttributeNames(mBean);
                if (attributes != null) {
View Full Code Here

TOP

Related Classes of java.util.StringTokenizer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.