Examples of StringCharacterIterator


Examples of java.text.StringCharacterIterator

     * @param str The expression string
     * @return The expression parts
     */
    public static String[] getExpressionsFromString(String str)
    {
        CharacterIterator ci = new StringCharacterIterator(str);
        int braces = 0;
        String text = "";
        ArrayList exprList = new ArrayList();
        while( ci.getIndex() != ci.getEndIndex() )
        {
            char c = ci.current();
            if( c == ',' && braces == 0)
            {
                exprList.add(text);
                text = "";
            }
            else if( c == '(' )
            {
                braces++;
                text += c;
            }
            else if( c == ')' )
            {
                braces--;
                text += c;
            }
            else
            {
                text += c;
            }
            ci.next();
        }
        exprList.add(text);
        return (String[])exprList.toArray(new String[exprList.size()]);
    }
View Full Code Here

Examples of java.text.StringCharacterIterator

    public Parser(String input, Imports imports)
    {
        this.input = input;
        this.imports = imports;

        ci = new StringCharacterIterator(input);
    }
View Full Code Here

Examples of java.text.StringCharacterIterator

     **/
    public Lexer(String input)
    {
        this.input = input;

        ci = new StringCharacterIterator(input);
    }
View Full Code Here

Examples of java.text.StringCharacterIterator

   * Creates a new CommandlineParser
   *
   * @param text text to parse
   */
  public CommandlineParser(final String text) {
    ci = new StringCharacterIterator(text);
  }
View Full Code Here

Examples of java.text.StringCharacterIterator

         **/
        public Parser(String input)
        {
            this.input = input;

            ci = new StringCharacterIterator(input);
        }
View Full Code Here

Examples of java.text.StringCharacterIterator

    *
    */
    private String checkforRegex(String aRegexFragment){
      final StringBuilder result = new StringBuilder();

      final StringCharacterIterator iterator = new StringCharacterIterator(aRegexFragment);
      char character =  iterator.current();
      while (character != CharacterIterator.DONE ){
        /*
        * All literals need to have backslashes doubled.
        */
        if (character == '.') {
          result.append("\\.");
        }
        else if (character == '\\') {
          result.append("\\\\");
        }
        else if (character == '?') {
          result.append("\\?");
        }
        else if (character == '*') {
          result.append("\\*");
        }
        else if (character == '+') {
          result.append("\\+");
        }
        else if (character == '&') {
          result.append("\\&");
        }
        else if (character == ':') {
          result.append("\\:");
        }
        else if (character == '{') {
          result.append("\\{");
        }
        else if (character == '}') {
          result.append("\\}");
        }
        else if (character == '[') {
          result.append("\\[");
        }
        else if (character == ']') {
          result.append("\\]");
        }
        else if (character == '(') {
          result.append("\\(");
        }
        else if (character == ')') {
          result.append("\\)");
        }
        else if (character == '^') {
          result.append("\\^");
        }
        else if (character == '$') {
          result.append("\\$");
        }
        else if (character == '|') {
          result.append("\\|");
        }
        else {
          //the char is not a special one
          //add it to the result as is
          result.append(character);
        }
        character = iterator.next();
      }
      return result.toString();
   
View Full Code Here

Examples of java.text.StringCharacterIterator

    {
        if ( snippet != null )
        {
            final StringBuffer result = new StringBuffer( );

            final StringCharacterIterator iterator = new StringCharacterIterator( snippet );
            char character = iterator.current( );
            while ( character != StringCharacterIterator.DONE )
            {
                if ( character == '<' )
                {
                    result.append( "&lt;" );
                }
                else if ( character == '>' )
                {
                    result.append( "&gt;" );
                } // What else really needs to be escaped? SAX parsers are
                // inconsistent here...
                /*
                 * else if (character == '\"') { result.append("&quot;"); } else
                 * if (character == '\'') { result.append("&#039;"); } else if
                 * (character == '\\') { result.append("&#092;"); }
                 */
                else if ( character == '&' )
                {
                    result.append( "&amp;" );
                }
                else
                {
                    // the char is not a special one
                    // add it to the result as is
                    result.append( character );
                }
                character = iterator.next( );
            }
            return result.toString( );
        }
        return null;
    }
View Full Code Here

Examples of java.text.StringCharacterIterator

     * @param str The expression string
     * @return The expression parts
     */
    public static String[] getExpressionsFromString(String str)
    {
        CharacterIterator ci = new StringCharacterIterator(str);
        int braces = 0;
        String text = "";
        ArrayList exprList = new ArrayList();
        while (ci.getIndex() != ci.getEndIndex())
        {
            char c = ci.current();
            if (c == ',' && braces == 0)
            {
                exprList.add(text);
                text = "";
            }
            else if (c == '(')
            {
                braces++;
                text += c;
            }
            else if (c == ')')
            {
                braces--;
                text += c;
            }
            else
            {
                text += c;
            }
            ci.next();
        }
        exprList.add(text);
        return (String[])exprList.toArray(new String[exprList.size()]);
    }
View Full Code Here

Examples of java.text.StringCharacterIterator

   * @param text
   *            Raw text.
   *
   */
  protected void appendHTML(final StringBuilder sbuf, final String text) {
    final StringCharacterIterator ci = new StringCharacterIterator(text);
    char ch = ci.current();

    while (ch != CharacterIterator.DONE) {
      appendHTML(sbuf, ch);
      ch = ci.next();
    }
  }
View Full Code Here

Examples of java.text.StringCharacterIterator

//      }.format(text);
//    } catch (Exception ble) { // BadLocationException
//      System.err.println("Couldn't insert initial text.");
//    }

    final StringCharacterIterator ci = new StringCharacterIterator(text);
    char ch = ci.current();

    while (ch != CharacterIterator.DONE) {
      // display text after "#" as link
      if (ch == '#') {
        ch = ci.next();

        /*
         * '##' means just a single '#'
         */
        if (ch == '#') {
          appendHTML(sbuf, ch);
          ch = ci.next();
        } else {
          final String link = extractLink(ci);

          /*
           * Emit link (if any)
           */
          if (link != null) {
            buildLink(sbuf, link);
          }

          ch = ci.current();
        }
      } else {
        appendHTML(sbuf, ch);
        ch = ci.next();
      }
    }

    return sbuf.toString();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.