示例#1
0
 /** Scan tag */
 public static Hashtable scanTag(Reader in) throws IOException {
   Hashtable atts = new Hashtable();
   skipSpace(in);
   while (c >= 0 && c != '>') {
     String att = scanIdentifier(in);
     String val = "";
     skipSpace(in);
     if (c == '=') {
       int quote = -1;
       c = in.read();
       skipSpace(in);
       if ((c == '\'') || (c == '\"')) {
         quote = c;
         c = in.read();
       }
       StringBuffer buf = new StringBuffer();
       while ((c > 0)
           && (((quote < 0)
                   && (c != ' ')
                   && (c != '\t')
                   && (c != '\n')
                   && (c != '\r')
                   && (c != '>'))
               || ((quote >= 0) && (c != quote)))) {
         buf.append((char) c);
         c = in.read();
       }
       if (c == quote) {
         c = in.read();
       }
       skipSpace(in);
       val = buf.toString();
     }
     // statusMsgStream.println("PUT " + att + " = '" + val + "'");
     if (!val.equals("")) {
       atts.put(att.toLowerCase(j86.java.util.Locale.ENGLISH), val);
     }
     while (true) {
       if ((c == '>')
           || (c < 0)
           || ((c >= 'a') && (c <= 'z'))
           || ((c >= 'A') && (c <= 'Z'))
           || ((c >= '0') && (c <= '9'))
           || (c == '_')) break;
       c = in.read();
     }
     // skipSpace(in);
   }
   return atts;
 }
示例#2
0
 /** Scan identifier */
 public static String scanIdentifier(Reader in) throws IOException {
   StringBuffer buf = new StringBuffer();
   while (true) {
     if (((c >= 'a') && (c <= 'z'))
         || ((c >= 'A') && (c <= 'Z'))
         || ((c >= '0') && (c <= '9'))
         || (c == '_')) {
       buf.append((char) c);
       c = in.read();
     } else {
       return buf.toString();
     }
   }
 }