home *** CD-ROM | disk | FTP | other *** search
- package com.sfs.html;
-
- import java.io.InputStream;
- import java.util.Hashtable;
-
- class HtmlTokenizer {
- // $FF: renamed from: in java.io.InputStream
- private InputStream field_0;
- private byte[] inBuf = new byte[100];
- private char[] buf = new char[200];
- private int index;
- private int length;
-
- private boolean identifierChar(char var1) {
- if (var1 != '_' && var1 != '#' && var1 != '+' && var1 != '-') {
- return Character.isLetterOrDigit(var1);
- } else {
- return true;
- }
- }
-
- private void readSpaces() throws Exception {
- while(Character.isWhitespace(this.read())) {
- }
-
- this.index += -1;
- }
-
- private void reset() {
- this.index = 0;
- }
-
- protected boolean getCloseTag(String var1) {
- try {
- this.reset();
- this.readSpaces();
- if (this.read() != '<') {
- return false;
- } else {
- this.readSpaces();
- if (this.read() != '/') {
- return false;
- } else {
- this.readSpaces();
- String var2 = this.readIdentifier();
- if (!var1.equalsIgnoreCase(var2)) {
- return false;
- } else {
- this.readUntil('>');
- this.read();
- this.clear();
- return true;
- }
- }
- }
- } catch (Exception var3) {
- return false;
- }
- }
-
- private char read() throws Exception {
- while(this.index == this.length) {
- int var1 = this.field_0.read(this.inBuf);
- if (var1 <= 0) {
- throw new Exception();
- }
-
- if (this.length + var1 > this.buf.length) {
- char[] var2 = new char[this.buf.length + this.inBuf.length];
- System.arraycopy(this.buf, 0, var2, 0, this.length);
- this.buf = var2;
- }
-
- for(int var3 = 0; var3 < var1; ++this.length) {
- this.buf[this.length] = (char)(this.inBuf[var3] & 255);
- ++var3;
- }
- }
-
- return this.buf[this.index++];
- }
-
- protected Hashtable getOpenTag(String var1) {
- try {
- this.reset();
- this.readSpaces();
- if (this.read() != '<') {
- return null;
- } else {
- this.readSpaces();
- String var2 = this.readIdentifier();
- if (!var1.equalsIgnoreCase(var2)) {
- return null;
- } else {
- this.readSpaces();
-
- Hashtable var3;
- String var4;
- String var5;
- for(var3 = new Hashtable(); this.read() != '>'; var3.put(var4.toUpperCase(), var5)) {
- this.index += -1;
- this.clear();
- var4 = this.readIdentifier();
- var5 = "";
- this.readSpaces();
- if (this.read() == '=') {
- this.readSpaces();
- var5 = this.readIdentifier();
- this.readSpaces();
- }
- }
-
- this.clear();
- return var3;
- }
- }
- } catch (Exception var6) {
- return null;
- }
- }
-
- protected void getTagOrText() {
- try {
- this.reset();
- this.readSpaces();
- if (this.read() == '<') {
- this.readUntil('>');
- this.read();
- this.clear();
- } else {
- this.getText();
- }
- } catch (Exception var1) {
- this.getText();
- }
- }
-
- protected HtmlTokenizer(InputStream var1) {
- this.field_0 = var1;
- }
-
- protected boolean eof() {
- this.reset();
-
- try {
- this.read();
- return false;
- } catch (Exception var1) {
- return true;
- }
- }
-
- private String makeMassagedString(char[] var1, int var2, int var3) {
- char[] var4 = new char[var3];
- int var5 = 0;
-
- for(int var6 = 0; var6 < var3; ++var6) {
- char var7 = var1[var2 + var6];
- if (var7 != '&') {
- var4[var5++] = var7;
- } else {
- int var8 = -1;
- char var9 = ' ';
-
- for(int var10 = var6 + 1; var8 < 0 && var10 < var3; ++var10) {
- if (var1[var2 + var10] == ';') {
- String var11 = new String(var1, var2 + var6 + 1, var10 - var6 - 1);
- if (var11.equals("lt")) {
- var9 = '<';
- var8 = var10;
- } else if (var11.equals("gt")) {
- var9 = '>';
- var8 = var10;
- } else if (var11.equals("amp")) {
- var9 = '&';
- var8 = var10;
- } else if (var11.equals("quot")) {
- var9 = '"';
- var8 = var10;
- } else if (var11.equals("nbsp")) {
- var9 = 160;
- var8 = var10;
- } else if (var11.equals("copy")) {
- var9 = 169;
- var8 = var10;
- } else if (var11.equals("reg")) {
- var9 = 174;
- var8 = var10;
- } else if (var11.equals("Agrave")) {
- var9 = 192;
- var8 = var10;
- } else if (var11.equals("agrave")) {
- var9 = 224;
- var8 = var10;
- } else if (var11.equals("Aacute")) {
- var9 = 193;
- var8 = var10;
- } else if (var11.equals("aacute")) {
- var9 = 225;
- var8 = var10;
- } else if (var11.equals("Acirc")) {
- var9 = 194;
- var8 = var10;
- } else if (var11.equals("acirc")) {
- var9 = 194;
- var8 = var10;
- } else if (var11.equals("Atilde")) {
- var9 = 195;
- var8 = var10;
- } else if (var11.equals("atilde")) {
- var9 = 227;
- var8 = var10;
- } else if (var11.equals("Auml")) {
- var9 = 196;
- var8 = var10;
- } else if (var11.equals("auml")) {
- var9 = 228;
- var8 = var10;
- } else if (var11.equals("Aring")) {
- var9 = 197;
- var8 = var10;
- } else if (var11.equals("aring")) {
- var9 = 229;
- var8 = var10;
- } else if (var11.equals("Aelig")) {
- var9 = 198;
- var8 = var10;
- } else if (var11.equals("aelig")) {
- var9 = 230;
- var8 = var10;
- } else if (var11.equals("Ccedil")) {
- var9 = 199;
- var8 = var10;
- } else if (var11.equals("ccedil")) {
- var9 = 231;
- var8 = var10;
- } else if (var11.equals("Egrave")) {
- var9 = 200;
- var8 = var10;
- } else if (var11.equals("egrave")) {
- var9 = 232;
- var8 = var10;
- } else if (var11.equals("Eacute")) {
- var9 = 201;
- var8 = var10;
- } else if (var11.equals("eacute")) {
- var9 = 233;
- var8 = var10;
- } else if (var11.equals("Ecirc")) {
- var9 = 202;
- var8 = var10;
- } else if (var11.equals("ecirc")) {
- var9 = 234;
- var8 = var10;
- } else if (var11.equals("Euml")) {
- var9 = 203;
- var8 = var10;
- } else if (var11.equals("euml")) {
- var9 = 235;
- var8 = var10;
- } else if (var11.equals("Igrave")) {
- var9 = 204;
- var8 = var10;
- } else if (var11.equals("igrave")) {
- var9 = 236;
- var8 = var10;
- } else if (var11.equals("Iacute")) {
- var9 = 205;
- var8 = var10;
- } else if (var11.equals("iacute")) {
- var9 = 237;
- var8 = var10;
- } else if (var11.equals("Icirc")) {
- var9 = 206;
- var8 = var10;
- } else if (var11.equals("icirc")) {
- var9 = 238;
- var8 = var10;
- } else if (var11.equals("Iuml")) {
- var9 = 207;
- var8 = var10;
- } else if (var11.equals("iuml")) {
- var9 = 239;
- var8 = var10;
- } else if (var11.equals("ETH")) {
- var9 = 208;
- var8 = var10;
- } else if (var11.equals("eth")) {
- var9 = 240;
- var8 = var10;
- } else if (var11.equals("Ntilde")) {
- var9 = 209;
- var8 = var10;
- } else if (var11.equals("ntilde")) {
- var9 = 241;
- var8 = var10;
- } else if (var11.equals("Ograve")) {
- var9 = 210;
- var8 = var10;
- } else if (var11.equals("ograve")) {
- var9 = 242;
- var8 = var10;
- } else if (var11.equals("Oacute")) {
- var9 = 211;
- var8 = var10;
- } else if (var11.equals("oacute")) {
- var9 = 243;
- var8 = var10;
- } else if (var11.equals("Ocirc")) {
- var9 = 212;
- var8 = var10;
- } else if (var11.equals("ocirc")) {
- var9 = 244;
- var8 = var10;
- } else if (var11.equals("Otilde")) {
- var9 = 213;
- var8 = var10;
- } else if (var11.equals("otilde")) {
- var9 = 245;
- var8 = var10;
- } else if (var11.equals("Ouml")) {
- var9 = 214;
- var8 = var10;
- } else if (var11.equals("ouml")) {
- var9 = 246;
- var8 = var10;
- } else if (var11.equals("Oslash")) {
- var9 = 216;
- var8 = var10;
- } else if (var11.equals("oslash")) {
- var9 = 248;
- var8 = var10;
- } else if (var11.equals("Ugrave")) {
- var9 = 217;
- var8 = var10;
- } else if (var11.equals("ugrave")) {
- var9 = 249;
- var8 = var10;
- } else if (var11.equals("Uacute")) {
- var9 = 218;
- var8 = var10;
- } else if (var11.equals("uacute")) {
- var9 = 250;
- var8 = var10;
- } else if (var11.equals("Ucirc")) {
- var9 = 219;
- var8 = var10;
- } else if (var11.equals("ucirc")) {
- var9 = 251;
- var8 = var10;
- } else if (var11.equals("Uuml")) {
- var9 = 220;
- var8 = var10;
- } else if (var11.equals("uuml")) {
- var9 = 252;
- var8 = var10;
- } else if (var11.equals("Yacute")) {
- var9 = 221;
- var8 = var10;
- } else if (var11.equals("uacute")) {
- var9 = 253;
- var8 = var10;
- } else if (var11.equals("THORN")) {
- var9 = 222;
- var8 = var10;
- } else if (var11.equals("thorn")) {
- var9 = 254;
- var8 = var10;
- } else if (var11.equals("szlig")) {
- var9 = 223;
- var8 = var10;
- } else if (var11.equals("uuml")) {
- var9 = 255;
- var8 = var10;
- } else if (var11.charAt(0) == '#') {
- int var12 = 0;
-
- for(int var13 = var6 + 2; var13 < var10; ++var13) {
- var12 = 10 * var12 + var1[var2 + var13] - 48;
- var8 = var10;
- }
-
- var9 = (char)var12;
- }
- }
- }
-
- if (var8 > 0) {
- var4[var5++] = var9;
- var6 = var8;
- } else {
- var4[var5++] = var7;
- }
- }
- }
-
- return new String(var4, 0, var5);
- }
-
- protected String getPreformattedText(String var1) {
- this.reset();
-
- try {
- while(!this.endOfPreformattedText(var1)) {
- this.read();
- }
- } catch (Exception var3) {
- }
-
- this.index -= 1 + var1.length();
- if (this.index == 0) {
- return null;
- } else {
- String var2 = this.makeMassagedString(this.buf, 0, this.index);
- this.clear();
- return var2;
- }
- }
-
- private boolean endOfPreformattedText(String var1) {
- if (this.index < 1 + var1.length()) {
- return false;
- } else if (this.buf[this.index - 1 - var1.length()] != '<') {
- return false;
- } else {
- for(int var2 = 0; var2 < var1.length(); ++var2) {
- if (var1.charAt(var2) != this.buf[this.index - var1.length() + var2]) {
- return false;
- }
- }
-
- return true;
- }
- }
-
- private void clear() {
- int var1 = 0;
-
- for(int var2 = this.index; var2 < this.length; ++var2) {
- this.buf[var1] = this.buf[var2];
- ++var1;
- }
-
- this.length -= this.index;
- this.index = 0;
- }
-
- private String readIdentifier() throws Exception {
- int var1 = this.index;
- char var2 = this.read();
- if (var2 == '"') {
- String var3 = this.readUntil(var2);
- this.read();
- return var3;
- } else if (this.identifierChar(var2)) {
- while(this.identifierChar(this.read())) {
- }
-
- this.index += -1;
- return new String(this.buf, var1, this.index - var1);
- } else {
- while(!this.identifierChar(this.read())) {
- }
-
- this.index += -1;
- return new String(this.buf, var1, 1);
- }
- }
-
- private String readUntil(char var1) {
- int var2 = this.index;
-
- try {
- while(this.read() != var1) {
- }
-
- this.index += -1;
- } catch (Exception var4) {
- }
-
- for(int var3 = var2; var3 < this.index; ++var3) {
- if (Character.isWhitespace(this.buf[var3])) {
- this.buf[var3] = ' ';
- }
- }
-
- return this.makeMassagedString(this.buf, var2, this.index - var2);
- }
-
- protected String getText() {
- try {
- this.reset();
- if (this.read() == '<') {
- return null;
- } else {
- this.index += -1;
- String var1 = this.readUntil('<');
- this.clear();
- return var1;
- }
- } catch (Exception var2) {
- return null;
- }
- }
- }
-