⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pagedescription.java

📁 一些简要的公爵类一些简要的公爵类一些简要的公爵类
💻 JAVA
字号:
/* Generated By:JavaCC: Do not edit this line. PageDescription.java */
package net.nutch.quality.dynamic;

import java.io.*;
import java.util.*;

/************************************************
 * PageDescription gives the URL and the textual
 * description for a target page.  It loads in
 * a Sherlock plugin file.
 * 
 * @author Mike Cafarella
 ************************************************/

public class PageDescription implements PageDescriptionConstants {
    HashMap values = new HashMap();
    ArrayList inputs = new ArrayList();
    ArrayList interprets = new ArrayList();

    public HashMap getValues() {
        return values;

    }

    public ArrayList getInputs() {
        return inputs;
    }

    public ArrayList getInterprets() {
        return interprets;
    }

    /**
     * Test out sherlock parsing
     */
    public static void main(String argv[]) throws IOException, ParseException {
        if (argv.length < 1) {
            System.out.println("Usage: java net.nutch.quality.PageDescription <srcFile>");
            return;
        }
        PageDescription pd = new PageDescription(new FileInputStream(new File(argv[0])));
        pd.parse();
    }

  final public void parse() throws ParseException {
    jj_consume_token(10);
    label_1:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case KEYWORD:
        ;
        break;
      default:
        jj_la1[0] = jj_gen;
        break label_1;
      }
      param();
    }
    jj_consume_token(11);
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 13:
      case 14:
      case 15:
        ;
        break;
      default:
        jj_la1[1] = jj_gen;
        break label_2;
      }
      element();
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 12:
      jj_consume_token(12);
      break;
    default:
      jj_la1[2] = jj_gen;
      ;
    }
  }

  final public void param() throws ParseException {
  String keyword;
  String value;
    jj_consume_token(KEYWORD);
              keyword = token.image.toLowerCase();
    jj_consume_token(EQUALS);
    value = value();
    values.put(keyword,value);
  }

  final public void element() throws ParseException {
  HashMap input;
  HashMap interpret;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 13:
      jj_consume_token(13);
        input = new HashMap(); inputs.add(input);
      label_3:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case KEYWORD:
          ;
          break;
        default:
          jj_la1[3] = jj_gen;
          break label_3;
        }
        inputItem(input);
      }
      break;
    case 14:
      jj_consume_token(14);
        interpret = new HashMap(); interprets.add(interpret);
      label_4:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case KEYWORD:
          ;
          break;
        default:
          jj_la1[4] = jj_gen;
          break label_4;
        }
        matchItem(interpret);
      }
      break;
    case 15:
      jj_consume_token(15);
      jj_consume_token(KEYWORD);
      label_5:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case KEYWORD:
          ;
          break;
        default:
          jj_la1[5] = jj_gen;
          break label_5;
        }
        jj_consume_token(KEYWORD);
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case EQUALS:
          jj_consume_token(EQUALS);
          value();
          break;
        default:
          jj_la1[6] = jj_gen;
          ;
        }
      }
      break;
    default:
      jj_la1[7] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case 16:
      jj_consume_token(16);
      break;
    case 11:
      jj_consume_token(11);
      break;
    default:
      jj_la1[8] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
  }

  final public void inputItem(HashMap input) throws ParseException {
  String keyword;
  String value = null;
    jj_consume_token(KEYWORD);
              keyword = token.image.toLowerCase();
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case EQUALS:
      jj_consume_token(EQUALS);
      value = value();
      break;
    default:
      jj_la1[9] = jj_gen;
      ;
    }
   input.put(keyword,value);
  }

  final public void matchItem(HashMap interpret) throws ParseException {
  String keyword;
  String value = null;
    jj_consume_token(KEYWORD);
              keyword = token.image.toLowerCase();
    jj_consume_token(EQUALS);
    value = value();
   interpret.put(keyword,value);
  }

  final public String value() throws ParseException {
  String image;
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case QUOTED_VALUE:
      jj_consume_token(QUOTED_VALUE);
                    image = token.image.substring(1,token.image.length()-1);
      break;
    case UNQUOTED_VALUE:
      jj_consume_token(UNQUOTED_VALUE);
                      image = token.image;
      break;
    default:
      jj_la1[10] = jj_gen;
      jj_consume_token(-1);
      throw new ParseException();
    }
     {if (true) return image;}
    throw new Error("Missing return statement in function");
  }

  public PageDescriptionTokenManager token_source;
  SimpleCharStream jj_input_stream;
  public Token token, jj_nt;
  private int jj_ntk;
  private int jj_gen;
  final private int[] jj_la1 = new int[11];
  static private int[] jj_la1_0;
  static {
      jj_la1_0();
   }
   private static void jj_la1_0() {
      jj_la1_0 = new int[] {0x40,0xe000,0x1000,0x40,0x40,0x40,0x80,0xe000,0x10800,0x80,0x300,};
   }

  public PageDescription(java.io.InputStream stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new PageDescriptionTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.InputStream stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public PageDescription(java.io.Reader stream) {
    jj_input_stream = new SimpleCharStream(stream, 1, 1);
    token_source = new PageDescriptionTokenManager(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public void ReInit(java.io.Reader stream) {
    jj_input_stream.ReInit(stream, 1, 1);
    token_source.ReInit(jj_input_stream);
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public PageDescription(PageDescriptionTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  public void ReInit(PageDescriptionTokenManager tm) {
    token_source = tm;
    token = new Token();
    jj_ntk = -1;
    jj_gen = 0;
    for (int i = 0; i < 11; i++) jj_la1[i] = -1;
  }

  final private Token jj_consume_token(int kind) throws ParseException {
    Token oldToken;
    if ((oldToken = token).next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    if (token.kind == kind) {
      jj_gen++;
      return token;
    }
    token = oldToken;
    jj_kind = kind;
    throw generateParseException();
  }

  final public Token getNextToken() {
    if (token.next != null) token = token.next;
    else token = token.next = token_source.getNextToken();
    jj_ntk = -1;
    jj_gen++;
    return token;
  }

  final public Token getToken(int index) {
    Token t = token;
    for (int i = 0; i < index; i++) {
      if (t.next != null) t = t.next;
      else t = t.next = token_source.getNextToken();
    }
    return t;
  }

  final private int jj_ntk() {
    if ((jj_nt=token.next) == null)
      return (jj_ntk = (token.next=token_source.getNextToken()).kind);
    else
      return (jj_ntk = jj_nt.kind);
  }

  private java.util.Vector jj_expentries = new java.util.Vector();
  private int[] jj_expentry;
  private int jj_kind = -1;

  public ParseException generateParseException() {
    jj_expentries.removeAllElements();
    boolean[] la1tokens = new boolean[17];
    for (int i = 0; i < 17; i++) {
      la1tokens[i] = false;
    }
    if (jj_kind >= 0) {
      la1tokens[jj_kind] = true;
      jj_kind = -1;
    }
    for (int i = 0; i < 11; i++) {
      if (jj_la1[i] == jj_gen) {
        for (int j = 0; j < 32; j++) {
          if ((jj_la1_0[i] & (1<<j)) != 0) {
            la1tokens[j] = true;
          }
        }
      }
    }
    for (int i = 0; i < 17; i++) {
      if (la1tokens[i]) {
        jj_expentry = new int[1];
        jj_expentry[0] = i;
        jj_expentries.addElement(jj_expentry);
      }
    }
    int[][] exptokseq = new int[jj_expentries.size()][];
    for (int i = 0; i < jj_expentries.size(); i++) {
      exptokseq[i] = (int[])jj_expentries.elementAt(i);
    }
    return new ParseException(token, exptokseq, tokenImage);
  }

  final public void enable_tracing() {
  }

  final public void disable_tracing() {
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -