protected void processFormattedData(String src) { Vector baseName = new Vector(); Vector names = new Vector(); Vector values = new Vector(); int ptr = 0; int begin = 0; int nestLevel = 0; boolean whitespace = false; boolean foundEquals = false; String lastToken = null; String lastBaseName = null; String paramName = null; char c; if (src == null) return; while (ptr < src.length()) { foundEquals = false; whitespace = true; do { c = src.charAt(ptr); whitespace = false; if (Character.isSpace(c)) whitespace = true; else if (c == '=') { whitespace = true; foundEquals = true; } else if (c == '{') { if (lastBaseName != null) { baseName.addElement(lastBaseName); lastBaseName = null; } whitespace = true; } else if (c == '}') { if (baseName.size() > 0) { baseName.removeElementAt(baseName.size() - 1); } whitespace = true; } } while (whitespace && ++ptr < src.length()); begin = ptr; if (foundEquals && paramName == null) paramName = lastToken; if (ptr < src.length()) { do { c = src.charAt(ptr); whitespace = false; if (Character.isSpace(c)) whitespace = true; else if (c == '=') whitespace = true; else if (c == '{') whitespace = true; else if (c == '}') whitespace = true; } while (!whitespace && ++ptr < src.length()); lastToken = src.substring(begin, ptr); lastBaseName = lastToken; if (paramName != null) { int l = baseName.size(); String temp = ""; if (baseName.size() > 0) { for (int i = 0; i < l; i++) { temp += (String) (baseName.elementAt(i)); temp += "."; } } temp += paramName; names.addElement(temp); values.addElement(lastToken); paramName = null; } } } argNames = new String[names.size()]; args = new String[values.size()]; for (int i = 0; i < names.size(); i++) { argNames[i] = (String) (names.elementAt(i)); args[i] = (String) (values.elementAt(i)); } }
public int nextToken() throws IOException { StringBuffer sb = null; try { if (pushedBack) pushedBack = false; else { ttype = TT_EOF; char c; // Loop over white space while (true) { c = nextChar(); if (c == '\n') lineno++; if (Character.isSpace(c)) ; else if (c == ';') { // Read ' comment while ((c = nextChar()) != '\n') ; lineno++; } else if (c == '/') { c = nextChar(); if (c == '*') { // Read /**/ comment while (true) { while ((c = nextChar()) != '*') if (c == '\n') lineno++; c = nextChar(); if (c == '/') break; } } else if (c == '/') { // Read // comment while ((c = nextChar()) != '\n') ; lineno++; } else break; } else { break; } } if (c == '"' || c == '\'') { ttype = c; sb = new StringBuffer(); while ((c = nextChar()) != ttype) { if (c == '\\') { c = nextChar(); if (c == 'n') sb.append('\n'); if (c == 't') sb.append('\t'); else sb.append(c); } else sb.append(c); } sval = sb.toString(); } else if (!(Character.isJavaLetterOrDigit(c) || c == '<' || c == '.' || c == '-' || c == '+' || c == '[' || c == '$')) { ttype = c; } else { ttype = TT_WORD; sb = new StringBuffer(); sb.append((char) c); while (true) { c = nextChar(); if (Character.isJavaLetterOrDigit(c) || c == '<' || c == '>' || c == '/' || c == ';' || c == '.' || c == '-' || c == '+' || c == '[' || c == '$') sb.append((char) c); else { sval = sb.toString(); pushbackChar(c); break; } } } } return ttype; } catch (IOException e) { if (e.getMessage().equals("Done")) { if (ttype == TT_EOF) eof = true; if (sb != null) sval = sb.toString(); return ttype; } else throw e; } }