Beispiel #1
0
 protected String hvalue() throws ParseException {
   StringBuffer retval = new StringBuffer();
   while (lexer.hasMoreChars()) {
     char la = lexer.lookAhead(0);
     // Look for a character that can terminate a URL.
     if (la == '+'
         || la == '?'
         || la == ':'
         || la == '['
         || la == ']'
         || la == '/'
         || la == '$'
         || la == '_'
         || la == '-'
         || la == '"'
         || la == '!'
         || la == '~'
         || la == '*'
         || la == '.'
         || la == '('
         || la == ')'
         || Lexer.isAlpha(la)
         || Lexer.isDigit(la)) {
       lexer.consume(1);
       retval.append(la);
     } else if (la == '%') {
       retval.append(escaped());
     } else break;
   }
   return retval.toString();
 }
Beispiel #2
0
 /** Parser for the local phone #. */
 private String local_number() throws ParseException {
   StringBuffer s = new StringBuffer();
   if (debug) dbg_enter("local_number");
   try {
     int lc = 0;
     while (lexer.hasMoreChars()) {
       char la = lexer.lookAhead(0);
       if (la == '*'
           || la == '#'
           || la == '-'
           || la == '.'
           || la == '('
           || la == ')'
           || Lexer.isDigit(la)) {
         lexer.consume(1);
         s.append(la);
         lc++;
       } else if (lc > 0) break;
       else throw createParseException("unexepcted " + la);
     }
     return s.toString();
   } finally {
     if (debug) dbg_leave("local_number");
   }
 }
Beispiel #3
0
  /** Parser for the base phone number. */
  private String base_phone_number() throws ParseException {
    StringBuffer s = new StringBuffer();

    if (debug) dbg_enter("base_phone_number");
    try {
      int lc = 0;
      while (lexer.hasMoreChars()) {
        char w = lexer.lookAhead(0);
        if (Lexer.isDigit(w) || w == '-' || w == '.' || w == '(' || w == ')') {
          lexer.consume(1);
          s.append(w);
          lc++;
        } else if (lc > 0) break;
        else throw createParseException("unexpected " + w);
      }
      return s.toString();
    } finally {
      if (debug) dbg_leave("base_phone_number");
    }
  }
Beispiel #4
0
  /**
   * Parser for telephone subscriber.
   *
   * @return the parsed telephone number.
   */
  public final TelephoneNumber parseTelephoneNumber() throws ParseException {
    TelephoneNumber tn;

    if (debug) dbg_enter("telephone_subscriber");
    lexer.selectLexer("charLexer");
    try {
      char c = lexer.lookAhead(0);
      if (c == '+') tn = global_phone_number();
      else if (Lexer.isAlpha(c)
          || Lexer.isDigit(c)
          || c == '-'
          || c == '*'
          || c == '.'
          || c == '('
          || c == ')'
          || c == '#') {
        tn = local_phone_number();
      } else throw createParseException("unexpected char " + c);
      return tn;
    } finally {
      if (debug) dbg_leave("telephone_subscriber");
    }
  }
Beispiel #5
0
 protected static boolean isUnreserved(char next) {
   return Lexer.isAlpha(next) || Lexer.isDigit(next) || isMark(next);
 }