nekohtml-1.9.14

16:39:17.253 INFO  jd.cli.Main - Decompiling nekohtml-1.9.14.jar
package org.cyberneko.html;

import java.util.Enumeration;
import java.util.Hashtable;
import org.apache.xerces.xni.Augmentations;

public class HTMLAugmentations
  implements Augmentations
{
  protected final Hashtable fItems = new Hashtable();
  
  public HTMLAugmentations() {}
  
  HTMLAugmentations(Augmentations augs)
  {
    for (Enumeration keys = augs.keys(); keys.hasMoreElements();)
    {
      String key = (String)keys.nextElement();
      Object value = augs.getItem(key);
      if ((value instanceof HTMLScanner.LocationItem)) {
        value = new HTMLScanner.LocationItem((HTMLScanner.LocationItem)value);
      }
      fItems.put(key, value);
    }
  }
  
  public void removeAllItems()
  {
    fItems.clear();
  }
  
  public void clear()
  {
    fItems.clear();
  }
  
  public Object putItem(String key, Object item)
  {
    return fItems.put(key, item);
  }
  
  public Object getItem(String key)
  {
    return fItems.get(key);
  }
  
  public Object removeItem(String key)
  {
    return fItems.remove(key);
  }
  
  public Enumeration keys()
  {
    return fItems.keys();
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLAugmentations
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

import org.apache.xerces.xni.parser.XMLComponent;

public abstract interface HTMLComponent
  extends XMLComponent
{
  public abstract Boolean getFeatureDefault(String paramString);
  
  public abstract Object getPropertyDefault(String paramString);
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLComponent
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.xni.parser.XMLParseException;

public class HTMLConfiguration$ErrorReporter
  implements HTMLErrorReporter
{
  protected Locale fLastLocale;
  protected ResourceBundle fErrorMessages;
  private final HTMLConfiguration this$0;
  
  protected HTMLConfiguration$ErrorReporter(HTMLConfiguration paramHTMLConfiguration)
  {
    this$0 = paramHTMLConfiguration;
  }
  
  public String formatMessage(String key, Object[] args)
  {
    if (!this$0.getFeature("http://cyberneko.org/html/features/report-errors/simple"))
    {
      if (!this$0.fLocale.equals(fLastLocale))
      {
        fErrorMessages = null;
        fLastLocale = this$0.fLocale;
      }
      if (fErrorMessages == null) {
        fErrorMessages = ResourceBundle.getBundle("org/cyberneko/html/res/ErrorMessages", this$0.fLocale);
      }
      try
      {
        String value = fErrorMessages.getString(key);
        return MessageFormat.format(value, args);
      }
      catch (MissingResourceException e) {}
    }
    return formatSimpleMessage(key, args);
  }
  
  public void reportWarning(String key, Object[] args)
    throws XMLParseException
  {
    if (this$0.fErrorHandler != null) {
      this$0.fErrorHandler.warning("http://cyberneko.org/html", key, createException(key, args));
    }
  }
  
  public void reportError(String key, Object[] args)
    throws XMLParseException
  {
    if (this$0.fErrorHandler != null) {
      this$0.fErrorHandler.error("http://cyberneko.org/html", key, createException(key, args));
    }
  }
  
  protected XMLParseException createException(String key, Object[] args)
  {
    String message = formatMessage(key, args);
    return new XMLParseException(this$0.fDocumentScanner, message);
  }
  
  protected String formatSimpleMessage(String key, Object[] args)
  {
    StringBuffer str = new StringBuffer();
    str.append("http://cyberneko.org/html");
    str.append('#');
    str.append(key);
    if ((args != null) && (args.length > 0))
    {
      str.append('\t');
      for (int i = 0; i < args.length; i++)
      {
        if (i > 0) {
          str.append('\t');
        }
        str.append(String.valueOf(args[i]));
      }
    }
    return str.toString();
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLConfiguration.ErrorReporter
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

import java.io.IOException;
import java.lang.reflect.Field;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Vector;
import org.apache.xerces.util.DefaultErrorHandler;
import org.apache.xerces.util.ParserConfigurationSettings;
import org.apache.xerces.xni.XMLDTDContentModelHandler;
import org.apache.xerces.xni.XMLDTDHandler;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLConfigurationException;
import org.apache.xerces.xni.parser.XMLDocumentFilter;
import org.apache.xerces.xni.parser.XMLDocumentSource;
import org.apache.xerces.xni.parser.XMLEntityResolver;
import org.apache.xerces.xni.parser.XMLErrorHandler;
import org.apache.xerces.xni.parser.XMLInputSource;
import org.apache.xerces.xni.parser.XMLParseException;
import org.apache.xerces.xni.parser.XMLPullParserConfiguration;
import org.cyberneko.html.filters.NamespaceBinder;
import org.cyberneko.html.xercesbridge.XercesBridge;

public class HTMLConfiguration
  extends ParserConfigurationSettings
  implements XMLPullParserConfiguration
{
  protected static final String NAMESPACES = "http://xml.org/sax/features/namespaces";
  protected static final String AUGMENTATIONS = "http://cyberneko.org/html/features/augmentations";
  protected static final String REPORT_ERRORS = "http://cyberneko.org/html/features/report-errors";
  protected static final String SIMPLE_ERROR_FORMAT = "http://cyberneko.org/html/features/report-errors/simple";
  protected static final String BALANCE_TAGS = "http://cyberneko.org/html/features/balance-tags";
  protected static final String NAMES_ELEMS = "http://cyberneko.org/html/properties/names/elems";
  protected static final String NAMES_ATTRS = "http://cyberneko.org/html/properties/names/attrs";
  protected static final String FILTERS = "http://cyberneko.org/html/properties/filters";
  protected static final String ERROR_REPORTER = "http://cyberneko.org/html/properties/error-reporter";
  protected static final String ERROR_DOMAIN = "http://cyberneko.org/html";
  private static final Class[] DOCSOURCE = { XMLDocumentSource.class };
  protected XMLDocumentHandler fDocumentHandler;
  protected XMLDTDHandler fDTDHandler;
  protected XMLDTDContentModelHandler fDTDContentModelHandler;
  protected XMLErrorHandler fErrorHandler = new DefaultErrorHandler();
  protected XMLEntityResolver fEntityResolver;
  protected Locale fLocale = Locale.getDefault();
  protected boolean fCloseStream;
  protected final Vector fHTMLComponents = new Vector(2);
  protected final HTMLScanner fDocumentScanner = createDocumentScanner();
  protected final HTMLTagBalancer fTagBalancer = new HTMLTagBalancer();
  protected final NamespaceBinder fNamespaceBinder = new NamespaceBinder();
  protected final HTMLErrorReporter fErrorReporter = new ErrorReporter();
  protected static boolean XERCES_2_0_0 = false;
  protected static boolean XERCES_2_0_1 = false;
  protected static boolean XML4J_4_0_x = false;
  
  static
  {
    try
    {
      String VERSION = "org.apache.xerces.impl.Version";
      Object version = ObjectFactory.createObject(VERSION, VERSION);
      Field field = version.getClass().getField("fVersion");
      String versionStr = String.valueOf(field.get(version));
      XERCES_2_0_0 = versionStr.equals("Xerces-J 2.0.0");
      XERCES_2_0_1 = versionStr.equals("Xerces-J 2.0.1");
      XML4J_4_0_x = versionStr.startsWith("XML4J 4.0.");
    }
    catch (Throwable e) {}
  }
  
  public HTMLConfiguration()
  {
    addComponent(fDocumentScanner);
    addComponent(fTagBalancer);
    addComponent(fNamespaceBinder);
    
    String VALIDATION = "http://xml.org/sax/features/validation";
    String[] recognizedFeatures = { "http://cyberneko.org/html/features/augmentations", "http://xml.org/sax/features/namespaces", VALIDATION, "http://cyberneko.org/html/features/report-errors", "http://cyberneko.org/html/features/report-errors/simple", "http://cyberneko.org/html/features/balance-tags" };
    
    addRecognizedFeatures(recognizedFeatures);
    setFeature("http://cyberneko.org/html/features/augmentations", false);
    setFeature("http://xml.org/sax/features/namespaces", true);
    setFeature(VALIDATION, false);
    setFeature("http://cyberneko.org/html/features/report-errors", false);
    setFeature("http://cyberneko.org/html/features/report-errors/simple", false);
    setFeature("http://cyberneko.org/html/features/balance-tags", true);
    if (XERCES_2_0_0)
    {
      recognizedFeatures = new String[] { "http://apache.org/xml/features/scanner/notify-builtin-refs" };
      
      addRecognizedFeatures(recognizedFeatures);
    }
    if ((XERCES_2_0_0) || (XERCES_2_0_1) || (XML4J_4_0_x))
    {
      recognizedFeatures = new String[] { "http://apache.org/xml/features/validation/schema/normalized-value", "http://apache.org/xml/features/scanner/notify-char-refs" };
      
      addRecognizedFeatures(recognizedFeatures);
    }
    String[] recognizedProperties = { "http://cyberneko.org/html/properties/names/elems", "http://cyberneko.org/html/properties/names/attrs", "http://cyberneko.org/html/properties/filters", "http://cyberneko.org/html/properties/error-reporter" };
    
    addRecognizedProperties(recognizedProperties);
    setProperty("http://cyberneko.org/html/properties/names/elems", "upper");
    setProperty("http://cyberneko.org/html/properties/names/attrs", "lower");
    setProperty("http://cyberneko.org/html/properties/error-reporter", fErrorReporter);
    if (XERCES_2_0_0)
    {
      String SYMBOL_TABLE = "http://apache.org/xml/properties/internal/symbol-table";
      recognizedProperties = new String[] { SYMBOL_TABLE };
      
      addRecognizedProperties(recognizedProperties);
      Object symbolTable = ObjectFactory.createObject("org.apache.xerces.util.SymbolTable", "org.apache.xerces.util.SymbolTable");
      
      setProperty(SYMBOL_TABLE, symbolTable);
    }
  }
  
  protected HTMLScanner createDocumentScanner()
  {
    return new HTMLScanner();
  }
  
  public void pushInputSource(XMLInputSource inputSource)
  {
    fDocumentScanner.pushInputSource(inputSource);
  }
  
  public void evaluateInputSource(XMLInputSource inputSource)
  {
    fDocumentScanner.evaluateInputSource(inputSource);
  }
  
  public void setFeature(String featureId, boolean state)
    throws XMLConfigurationException
  {
    super.setFeature(featureId, state);
    int size = fHTMLComponents.size();
    for (int i = 0; i < size; i++)
    {
      HTMLComponent component = (HTMLComponent)fHTMLComponents.elementAt(i);
      component.setFeature(featureId, state);
    }
  }
  
  public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException
  {
    super.setProperty(propertyId, value);
    if (propertyId.equals("http://cyberneko.org/html/properties/filters"))
    {
      XMLDocumentFilter[] filters = (XMLDocumentFilter[])getProperty("http://cyberneko.org/html/properties/filters");
      if (filters != null) {
        for (int i = 0; i < filters.length; i++)
        {
          XMLDocumentFilter filter = filters[i];
          if ((filter instanceof HTMLComponent)) {
            addComponent((HTMLComponent)filter);
          }
        }
      }
    }
    int size = fHTMLComponents.size();
    for (int i = 0; i < size; i++)
    {
      HTMLComponent component = (HTMLComponent)fHTMLComponents.elementAt(i);
      component.setProperty(propertyId, value);
    }
  }
  
  public void setDocumentHandler(XMLDocumentHandler handler)
  {
    fDocumentHandler = handler;
    if ((handler instanceof HTMLTagBalancingListener)) {
      fTagBalancer.setTagBalancingListener((HTMLTagBalancingListener)handler);
    }
  }
  
  public XMLDocumentHandler getDocumentHandler()
  {
    return fDocumentHandler;
  }
  
  public void setDTDHandler(XMLDTDHandler handler)
  {
    fDTDHandler = handler;
  }
  
  public XMLDTDHandler getDTDHandler()
  {
    return fDTDHandler;
  }
  
  public void setDTDContentModelHandler(XMLDTDContentModelHandler handler)
  {
    fDTDContentModelHandler = handler;
  }
  
  public XMLDTDContentModelHandler getDTDContentModelHandler()
  {
    return fDTDContentModelHandler;
  }
  
  public void setErrorHandler(XMLErrorHandler handler)
  {
    fErrorHandler = handler;
  }
  
  public XMLErrorHandler getErrorHandler()
  {
    return fErrorHandler;
  }
  
  public void setEntityResolver(XMLEntityResolver resolver)
  {
    fEntityResolver = resolver;
  }
  
  public XMLEntityResolver getEntityResolver()
  {
    return fEntityResolver;
  }
  
  public void setLocale(Locale locale)
  {
    if (locale == null) {
      locale = Locale.getDefault();
    }
    fLocale = locale;
  }
  
  public Locale getLocale()
  {
    return fLocale;
  }
  
  public void parse(XMLInputSource source)
    throws XNIException, IOException
  {
    setInputSource(source);
    parse(true);
  }
  
  public void setInputSource(XMLInputSource inputSource)
    throws XMLConfigurationException, IOException
  {
    reset();
    fCloseStream = ((inputSource.getByteStream() == null) && (inputSource.getCharacterStream() == null));
    
    fDocumentScanner.setInputSource(inputSource);
  }
  
  public boolean parse(boolean complete)
    throws XNIException, IOException
  {
    try
    {
      boolean more = fDocumentScanner.scanDocument(complete);
      if (!more) {
        cleanup();
      }
      return more;
    }
    catch (XNIException e)
    {
      cleanup();
      throw e;
    }
    catch (IOException e)
    {
      cleanup();
      throw e;
    }
  }
  
  public void cleanup()
  {
    fDocumentScanner.cleanup(fCloseStream);
  }
  
  protected void addComponent(HTMLComponent component)
  {
    fHTMLComponents.addElement(component);
    
    String[] features = component.getRecognizedFeatures();
    addRecognizedFeatures(features);
    int featureCount = features != null ? features.length : 0;
    for (int i = 0; i < featureCount; i++)
    {
      Boolean state = component.getFeatureDefault(features[i]);
      if (state != null) {
        setFeature(features[i], state.booleanValue());
      }
    }
    String[] properties = component.getRecognizedProperties();
    addRecognizedProperties(properties);
    int propertyCount = properties != null ? properties.length : 0;
    for (int i = 0; i < propertyCount; i++)
    {
      Object value = component.getPropertyDefault(properties[i]);
      if (value != null) {
        setProperty(properties[i], value);
      }
    }
  }
  
  protected void reset()
    throws XMLConfigurationException
  {
    int size = fHTMLComponents.size();
    for (int i = 0; i < size; i++)
    {
      HTMLComponent component = (HTMLComponent)fHTMLComponents.elementAt(i);
      component.reset(this);
    }
    XMLDocumentSource lastSource = fDocumentScanner;
    if (getFeature("http://xml.org/sax/features/namespaces"))
    {
      lastSource.setDocumentHandler(fNamespaceBinder);
      fNamespaceBinder.setDocumentSource(fTagBalancer);
      lastSource = fNamespaceBinder;
    }
    if (getFeature("http://cyberneko.org/html/features/balance-tags"))
    {
      lastSource.setDocumentHandler(fTagBalancer);
      fTagBalancer.setDocumentSource(fDocumentScanner);
      lastSource = fTagBalancer;
    }
    XMLDocumentFilter[] filters = (XMLDocumentFilter[])getProperty("http://cyberneko.org/html/properties/filters");
    if (filters != null) {
      for (int i = 0; i < filters.length; i++)
      {
        XMLDocumentFilter filter = filters[i];
        XercesBridge.getInstance().XMLDocumentFilter_setDocumentSource(filter, lastSource);
        lastSource.setDocumentHandler(filter);
        lastSource = filter;
      }
    }
    lastSource.setDocumentHandler(fDocumentHandler);
  }
  
  protected class ErrorReporter
    implements HTMLErrorReporter
  {
    protected Locale fLastLocale;
    protected ResourceBundle fErrorMessages;
    
    protected ErrorReporter() {}
    
    public String formatMessage(String key, Object[] args)
    {
      if (!getFeature("http://cyberneko.org/html/features/report-errors/simple"))
      {
        if (!fLocale.equals(fLastLocale))
        {
          fErrorMessages = null;
          fLastLocale = fLocale;
        }
        if (fErrorMessages == null) {
          fErrorMessages = ResourceBundle.getBundle("org/cyberneko/html/res/ErrorMessages", fLocale);
        }
        try
        {
          String value = fErrorMessages.getString(key);
          return MessageFormat.format(value, args);
        }
        catch (MissingResourceException e) {}
      }
      return formatSimpleMessage(key, args);
    }
    
    public void reportWarning(String key, Object[] args)
      throws XMLParseException
    {
      if (fErrorHandler != null) {
        fErrorHandler.warning("http://cyberneko.org/html", key, createException(key, args));
      }
    }
    
    public void reportError(String key, Object[] args)
      throws XMLParseException
    {
      if (fErrorHandler != null) {
        fErrorHandler.error("http://cyberneko.org/html", key, createException(key, args));
      }
    }
    
    protected XMLParseException createException(String key, Object[] args)
    {
      String message = formatMessage(key, args);
      return new XMLParseException(fDocumentScanner, message);
    }
    
    protected String formatSimpleMessage(String key, Object[] args)
    {
      StringBuffer str = new StringBuffer();
      str.append("http://cyberneko.org/html");
      str.append('#');
      str.append(key);
      if ((args != null) && (args.length > 0))
      {
        str.append('\t');
        for (int i = 0; i < args.length; i++)
        {
          if (i > 0) {
            str.append('\t');
          }
          str.append(String.valueOf(args[i]));
        }
      }
      return str.toString();
    }
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLConfiguration
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

public class HTMLElements$Element
{
  public static final int INLINE = 1;
  public static final int BLOCK = 2;
  public static final int EMPTY = 4;
  public static final int CONTAINER = 8;
  public static final int SPECIAL = 16;
  public short code;
  public String name;
  public int flags;
  public short[] parentCodes;
  public Element[] parent;
  public short bounds;
  public short[] closes;
  
  public HTMLElements$Element(short code, String name, int flags, short parent, short[] closes)
  {
    this(code, name, flags, new short[] { parent }, (short)-1, closes);
  }
  
  public HTMLElements$Element(short code, String name, int flags, short parent, short bounds, short[] closes)
  {
    this(code, name, flags, new short[] { parent }, bounds, closes);
  }
  
  public HTMLElements$Element(short code, String name, int flags, short[] parents, short[] closes)
  {
    this(code, name, flags, parents, (short)-1, closes);
  }
  
  public HTMLElements$Element(short code, String name, int flags, short[] parents, short bounds, short[] closes)
  {
    this.code = code;
    this.name = name;
    this.flags = flags;
    parentCodes = parents;
    parent = null;
    this.bounds = bounds;
    this.closes = closes;
  }
  
  public final boolean isInline()
  {
    return (flags & 0x1) != 0;
  }
  
  public final boolean isBlock()
  {
    return (flags & 0x2) != 0;
  }
  
  public final boolean isEmpty()
  {
    return (flags & 0x4) != 0;
  }
  
  public final boolean isContainer()
  {
    return (flags & 0x8) != 0;
  }
  
  public final boolean isSpecial()
  {
    return (flags & 0x10) != 0;
  }
  
  public boolean closes(short tag)
  {
    if (closes != null) {
      for (int i = 0; i < closes.length; i++) {
        if (closes[i] == tag) {
          return true;
        }
      }
    }
    return false;
  }
  
  public int hashCode()
  {
    return name.hashCode();
  }
  
  public boolean equals(Object o)
  {
    return name.equals(o);
  }
  
  public String toString()
  {
    return super.toString() + "(name=" + name + ")";
  }
  
  public boolean isParent(Element element)
  {
    if (parent == null) {
      return false;
    }
    for (int i = 0; i < parent.length; i++) {
      if (code == parent[i].code) {
        return true;
      }
    }
    return false;
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLElements.Element
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

public class HTMLElements$ElementList
{
  public int size;
  public HTMLElements.Element[] data = new HTMLElements.Element[120];
  
  public void addElement(HTMLElements.Element element)
  {
    if (size == data.length)
    {
      HTMLElements.Element[] newarray = new HTMLElements.Element[size + 20];
      System.arraycopy(data, 0, newarray, 0, size);
      data = newarray;
    }
    data[(size++)] = element;
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLElements.ElementList
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

public class HTMLElements
{
  public static final short A = 0;
  public static final short ABBR = 1;
  public static final short ACRONYM = 2;
  public static final short ADDRESS = 3;
  public static final short APPLET = 4;
  public static final short AREA = 5;
  public static final short B = 6;
  public static final short BASE = 7;
  public static final short BASEFONT = 8;
  public static final short BDO = 9;
  public static final short BGSOUND = 10;
  public static final short BIG = 11;
  public static final short BLINK = 12;
  public static final short BLOCKQUOTE = 13;
  public static final short BODY = 14;
  public static final short BR = 15;
  public static final short BUTTON = 16;
  public static final short CAPTION = 17;
  public static final short CENTER = 18;
  public static final short CITE = 19;
  public static final short CODE = 20;
  public static final short COL = 21;
  public static final short COLGROUP = 22;
  public static final short COMMENT = 23;
  public static final short DEL = 24;
  public static final short DFN = 25;
  public static final short DIR = 26;
  public static final short DIV = 27;
  public static final short DD = 28;
  public static final short DL = 29;
  public static final short DT = 30;
  public static final short EM = 31;
  public static final short EMBED = 32;
  public static final short FIELDSET = 33;
  public static final short FONT = 34;
  public static final short FORM = 35;
  public static final short FRAME = 36;
  public static final short FRAMESET = 37;
  public static final short H1 = 38;
  public static final short H2 = 39;
  public static final short H3 = 40;
  public static final short H4 = 41;
  public static final short H5 = 42;
  public static final short H6 = 43;
  public static final short HEAD = 44;
  public static final short HR = 45;
  public static final short HTML = 46;
  public static final short I = 47;
  public static final short IFRAME = 48;
  public static final short ILAYER = 49;
  public static final short IMG = 50;
  public static final short INPUT = 51;
  public static final short INS = 52;
  public static final short ISINDEX = 53;
  public static final short KBD = 54;
  public static final short KEYGEN = 55;
  public static final short LABEL = 56;
  public static final short LAYER = 57;
  public static final short LEGEND = 58;
  public static final short LI = 59;
  public static final short LINK = 60;
  public static final short LISTING = 61;
  public static final short MAP = 62;
  public static final short MARQUEE = 63;
  public static final short MENU = 64;
  public static final short META = 65;
  public static final short MULTICOL = 66;
  public static final short NEXTID = 67;
  public static final short NOBR = 68;
  public static final short NOEMBED = 69;
  public static final short NOFRAMES = 70;
  public static final short NOLAYER = 71;
  public static final short NOSCRIPT = 72;
  public static final short OBJECT = 73;
  public static final short OL = 74;
  public static final short OPTION = 75;
  public static final short OPTGROUP = 76;
  public static final short P = 77;
  public static final short PARAM = 78;
  public static final short PLAINTEXT = 79;
  public static final short PRE = 80;
  public static final short Q = 81;
  public static final short RB = 82;
  public static final short RBC = 83;
  public static final short RP = 84;
  public static final short RT = 85;
  public static final short RTC = 86;
  public static final short RUBY = 87;
  public static final short S = 88;
  public static final short SAMP = 89;
  public static final short SCRIPT = 90;
  public static final short SELECT = 91;
  public static final short SMALL = 92;
  public static final short SOUND = 93;
  public static final short SPACER = 94;
  public static final short SPAN = 95;
  public static final short STRIKE = 96;
  public static final short STRONG = 97;
  public static final short STYLE = 98;
  public static final short SUB = 99;
  public static final short SUP = 100;
  public static final short TABLE = 101;
  public static final short TBODY = 102;
  public static final short TD = 103;
  public static final short TEXTAREA = 104;
  public static final short TFOOT = 105;
  public static final short TH = 106;
  public static final short THEAD = 107;
  public static final short TITLE = 108;
  public static final short TR = 109;
  public static final short TT = 110;
  public static final short U = 111;
  public static final short UL = 112;
  public static final short VAR = 113;
  public static final short WBR = 114;
  public static final short XML = 115;
  public static final short XMP = 116;
  public static final short UNKNOWN = 117;
  protected static final Element[][] ELEMENTS_ARRAY = new Element[26][];
  protected static final ElementList ELEMENTS = new ElementList();
  public static final Element NO_SUCH_ELEMENT = new Element((short)117, "", 8, new short[] { 14, 44 }, null);
  
  static
  {
    ELEMENTS_ARRAY[0] = { new Element(0, "A", 1, 14, new short[] { 0 }), new Element(1, "ABBR", 1, 14, null), new Element(2, "ACRONYM", 1, 14, null), new Element(3, "ADDRESS", 2, 14, null), new Element(4, "APPLET", 0, 14, null), new Element(5, "AREA", 4, 62, null) };
    
    ELEMENTS_ARRAY[1] = { new Element(6, "B", 1, 14, null), new Element(7, "BASE", 4, 44, null), new Element(8, "BASEFONT", 0, 44, null), new Element(9, "BDO", 1, 14, null), new Element(10, "BGSOUND", 4, 44, null), new Element(11, "BIG", 1, 14, null), new Element(12, "BLINK", 1, 14, null), new Element(13, "BLOCKQUOTE", 2, 14, new short[] { 77 }), new Element(14, "BODY", 8, 46, new short[] { 44 }), new Element(15, "BR", 4, 14, null), new Element(16, "BUTTON", 0, 14, null) };
    
    ELEMENTS_ARRAY[2] = { new Element(17, "CAPTION", 1, 101, null), new Element(18, "CENTER", 0, 14, null), new Element(19, "CITE", 1, 14, null), new Element(20, "CODE", 1, 14, null), new Element(21, "COL", 4, 101, null), new Element(22, "COLGROUP", 0, 101, new short[] { 21, 22 }), new Element(23, "COMMENT", 16, 46, null) };
    
    ELEMENTS_ARRAY[3] = { new Element(24, "DEL", 0, 14, null), new Element(25, "DFN", 1, 14, null), new Element(26, "DIR", 0, 14, null), new Element(27, "DIV", 2, 14, new short[] { 77 }), new Element(28, "DD", 0, 29, new short[] { 30, 28 }), new Element(29, "DL", 2, 14, null), new Element(30, "DT", 0, 29, new short[] { 30, 28 }) };
    
    ELEMENTS_ARRAY[4] = { new Element(31, "EM", 1, 14, null), new Element(32, "EMBED", 0, 14, null) };
    
    ELEMENTS_ARRAY[5] = { new Element(33, "FIELDSET", 0, 14, null), new Element(34, "FONT", 8, 14, null), new Element(35, "FORM", 8, new short[] { 14, 103, 27 }, new short[] { 16, 77 }), new Element(36, "FRAME", 4, 37, null), new Element(37, "FRAMESET", 0, 46, null) };
    
    ELEMENTS_ARRAY[7] = { new Element(38, "H1", 2, new short[] { 14, 0 }, new short[] { 38, 39, 40, 41, 42, 43, 77 }), new Element(39, "H2", 2, new short[] { 14, 0 }, new short[] { 38, 39, 40, 41, 42, 43, 77 }), new Element(40, "H3", 2, new short[] { 14, 0 }, new short[] { 38, 39, 40, 41, 42, 43, 77 }), new Element(41, "H4", 2, new short[] { 14, 0 }, new short[] { 38, 39, 40, 41, 42, 43, 77 }), new Element(42, "H5", 2, new short[] { 14, 0 }, new short[] { 38, 39, 40, 41, 42, 43, 77 }), new Element(43, "H6", 2, new short[] { 14, 0 }, new short[] { 38, 39, 40, 41, 42, 43, 77 }), new Element(44, "HEAD", 0, 46, null), new Element(45, "HR", 4, 14, new short[] { 77 }), new Element(46, "HTML", 0, null, null) };
    
    ELEMENTS_ARRAY[8] = { new Element(47, "I", 1, 14, null), new Element(48, "IFRAME", 2, 14, null), new Element(49, "ILAYER", 2, 14, null), new Element(50, "IMG", 4, 14, null), new Element(51, "INPUT", 4, 14, null), new Element(52, "INS", 0, 14, null), new Element(53, "ISINDEX", 0, 44, null) };
    
    ELEMENTS_ARRAY[10] = { new Element(54, "KBD", 1, 14, null), new Element(55, "KEYGEN", 0, 14, null) };
    
    ELEMENTS_ARRAY[11] = { new Element(56, "LABEL", 0, 14, null), new Element(57, "LAYER", 2, 14, null), new Element(58, "LEGEND", 1, 33, null), new Element(59, "LI", 0, new short[] { 14, 112, 74 }, new short[] { 59 }), new Element(60, "LINK", 4, 44, null), new Element(61, "LISTING", 0, 14, null) };
    
    ELEMENTS_ARRAY[12] = { new Element(62, "MAP", 1, 14, null), new Element(63, "MARQUEE", 0, 14, null), new Element(64, "MENU", 0, 14, null), new Element(65, "META", 4, 44, new short[] { 98, 108 }), new Element(66, "MULTICOL", 0, 14, null) };
    
    ELEMENTS_ARRAY[13] = { new Element(67, "NEXTID", 4, 14, null), new Element(68, "NOBR", 1, 14, null), new Element(69, "NOEMBED", 0, 14, null), new Element(70, "NOFRAMES", 0, null, null), new Element(71, "NOLAYER", 0, 14, null), new Element(72, "NOSCRIPT", 0, new short[] { 14 }, null) };
    
    ELEMENTS_ARRAY[14] = { new Element(73, "OBJECT", 0, 14, null), new Element(74, "OL", 2, 14, null), new Element(76, "OPTGROUP", 0, 91, new short[] { 75 }), new Element(75, "OPTION", 0, 91, new short[] { 75 }) };
    
    ELEMENTS_ARRAY[15] = { new Element(77, "P", 8, 14, new short[] { 77 }), new Element(78, "PARAM", 4, new short[] { 73, 4 }, null), new Element(79, "PLAINTEXT", 16, 14, null), new Element(80, "PRE", 0, 14, null) };
    
    ELEMENTS_ARRAY[16] = { new Element(81, "Q", 1, 14, null) };
    
    ELEMENTS_ARRAY[17] = { new Element(82, "RB", 1, 87, new short[] { 82 }), new Element(83, "RBC", 0, 87, null), new Element(84, "RP", 1, 87, new short[] { 82 }), new Element(85, "RT", 1, 87, new short[] { 82, 84 }), new Element(86, "RTC", 0, 87, new short[] { 83 }), new Element(87, "RUBY", 0, 14, new short[] { 87 }) };
    
    ELEMENTS_ARRAY[18] = { new Element(88, "S", 0, 14, null), new Element(89, "SAMP", 1, 14, null), new Element(90, "SCRIPT", 16, new short[] { 44, 14 }, null), new Element(91, "SELECT", 8, 14, new short[] { 91 }), new Element(92, "SMALL", 1, 14, null), new Element(93, "SOUND", 4, 44, null), new Element(94, "SPACER", 4, 14, null), new Element(95, "SPAN", 8, 14, null), new Element(96, "STRIKE", 1, 14, null), new Element(97, "STRONG", 1, 14, null), new Element(98, "STYLE", 16, new short[] { 44, 14 }, new short[] { 98, 108, 65 }), new Element(99, "SUB", 1, 14, null), new Element(100, "SUP", 1, 14, null) };
    
    ELEMENTS_ARRAY[19] = { new Element(101, "TABLE", 10, 14, null), new Element(102, "TBODY", 0, 101, new short[] { 107, 102, 105, 103, 106, 109, 22 }), new Element(103, "TD", 8, 109, 101, new short[] { 103, 106 }), new Element(104, "TEXTAREA", 16, 14, null), new Element(105, "TFOOT", 0, 101, new short[] { 107, 102, 105, 103, 106, 109 }), new Element(106, "TH", 8, 109, 101, new short[] { 103, 106 }), new Element(107, "THEAD", 0, 101, new short[] { 107, 102, 105, 103, 106, 109, 22 }), new Element(108, "TITLE", 16, new short[] { 44, 14 }, null), new Element(109, "TR", 2, new short[] { 102, 107, 105 }, 101, new short[] { 103, 106, 109, 22 }), new Element(110, "TT", 1, 14, null) };
    
    ELEMENTS_ARRAY[20] = { new Element(111, "U", 1, 14, null), new Element(112, "UL", 2, 14, null) };
    
    ELEMENTS_ARRAY[21] = { new Element(113, "VAR", 1, 14, null) };
    
    ELEMENTS_ARRAY[22] = { new Element(114, "WBR", 4, 14, null) };
    
    ELEMENTS_ARRAY[23] = { new Element(115, "XML", 0, 14, null), new Element(116, "XMP", 16, 14, null) };
    for (int i = 0; i < ELEMENTS_ARRAY.length; i++)
    {
      Element[] elements = ELEMENTS_ARRAY[i];
      if (elements != null) {
        for (int j = 0; j < elements.length; j++)
        {
          Element element = elements[j];
          ELEMENTS.addElement(element);
        }
      }
    }
    ELEMENTS.addElement(NO_SUCH_ELEMENT);
    for (int i = 0; i < ELEMENTSsize; i++)
    {
      Element element = ELEMENTSdata[i];
      if (parentCodes != null)
      {
        parent = new Element[parentCodes.length];
        for (int j = 0; j < parentCodes.length; j++) {
          parent[j] = ELEMENTSdata[parentCodes[j]];
        }
        parentCodes = null;
      }
    }
  }
  
  public static final Element getElement(short code)
  {
    return ELEMENTSdata[code];
  }
  
  public static final Element getElement(String ename)
  {
    return getElement(ename, NO_SUCH_ELEMENT);
  }
  
  public static final Element getElement(String ename, Element element)
  {
    if (ename.length() > 0)
    {
      int c = ename.charAt(0);
      if ((c >= 97) && (c <= 122)) {
        c = 65 + c - 97;
      }
      if ((c >= 65) && (c <= 90))
      {
        Element[] elements = ELEMENTS_ARRAY[(c - 65)];
        if (elements != null) {
          for (int i = 0; i < elements.length; i++)
          {
            Element elem = elements[i];
            if (name.equalsIgnoreCase(ename)) {
              return elem;
            }
          }
        }
      }
    }
    return element;
  }
  
  public static class Element
  {
    public static final int INLINE = 1;
    public static final int BLOCK = 2;
    public static final int EMPTY = 4;
    public static final int CONTAINER = 8;
    public static final int SPECIAL = 16;
    public short code;
    public String name;
    public int flags;
    public short[] parentCodes;
    public Element[] parent;
    public short bounds;
    public short[] closes;
    
    public Element(short code, String name, int flags, short parent, short[] closes)
    {
      this(code, name, flags, new short[] { parent }, (short)-1, closes);
    }
    
    public Element(short code, String name, int flags, short parent, short bounds, short[] closes)
    {
      this(code, name, flags, new short[] { parent }, bounds, closes);
    }
    
    public Element(short code, String name, int flags, short[] parents, short[] closes)
    {
      this(code, name, flags, parents, (short)-1, closes);
    }
    
    public Element(short code, String name, int flags, short[] parents, short bounds, short[] closes)
    {
      this.code = code;
      this.name = name;
      this.flags = flags;
      parentCodes = parents;
      parent = null;
      this.bounds = bounds;
      this.closes = closes;
    }
    
    public final boolean isInline()
    {
      return (flags & 0x1) != 0;
    }
    
    public final boolean isBlock()
    {
      return (flags & 0x2) != 0;
    }
    
    public final boolean isEmpty()
    {
      return (flags & 0x4) != 0;
    }
    
    public final boolean isContainer()
    {
      return (flags & 0x8) != 0;
    }
    
    public final boolean isSpecial()
    {
      return (flags & 0x10) != 0;
    }
    
    public boolean closes(short tag)
    {
      if (closes != null) {
        for (int i = 0; i < closes.length; i++) {
          if (closes[i] == tag) {
            return true;
          }
        }
      }
      return false;
    }
    
    public int hashCode()
    {
      return name.hashCode();
    }
    
    public boolean equals(Object o)
    {
      return name.equals(o);
    }
    
    public String toString()
    {
      return super.toString() + "(name=" + name + ")";
    }
    
    public boolean isParent(Element element)
    {
      if (parent == null) {
        return false;
      }
      for (int i = 0; i < parent.length; i++) {
        if (code == parent[i].code) {
          return true;
        }
      }
      return false;
    }
  }
  
  public static class ElementList
  {
    public int size;
    public HTMLElements.Element[] data = new HTMLElements.Element[120];
    
    public void addElement(HTMLElements.Element element)
    {
      if (size == data.length)
      {
        HTMLElements.Element[] newarray = new HTMLElements.Element[size + 20];
        System.arraycopy(data, 0, newarray, 0, size);
        data = newarray;
      }
      data[(size++)] = element;
    }
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLElements
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

class HTMLEntities$IntProperties$Entry
{
  public int key;
  public String value;
  public Entry next;
  
  public HTMLEntities$IntProperties$Entry(int key, String value, Entry next)
  {
    this.key = key;
    this.value = value;
    this.next = next;
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLEntities.IntProperties.Entry
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

class HTMLEntities$IntProperties
{
  private Entry[] entries;
  
  HTMLEntities$IntProperties()
  {
    entries = new Entry[101];
  }
  
  public void put(int key, String value)
  {
    int hash = key % entries.length;
    Entry entry = new Entry(key, value, entries[hash]);
    entries[hash] = entry;
  }
  
  public String get(int key)
  {
    int hash = key % entries.length;
    Entry entry = entries[hash];
    while (entry != null)
    {
      if (key == key) {
        return value;
      }
      entry = next;
    }
    return null;
  }
  
  static class Entry
  {
    public int key;
    public String value;
    public Entry next;
    
    public Entry(int key, String value, Entry next)
    {
      this.key = key;
      this.value = value;
      this.next = next;
    }
  }
}

/* Location:
 * Qualified Name:     org.cyberneko.html.HTMLEntities.IntProperties
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

import java.io.IOException;
import java.io.PrintStream;
import java.util.Enumeration;
import java.util.Properties;

public class HTMLEntities
{
  protected static final Properties ENTITIES = new Properties();
  protected static final IntProperties SEITITNE = new IntProperties();
  
  static
  {
    load0("res/HTMLlat1.properties");
    load0("res/HTMLspecial.properties");
    load0("res/HTMLsymbol.properties");
    load0("res/XMLbuiltin.properties");
    
    Enumeration keys = ENTITIES.propertyNames();
    while (keys.hasMoreElements())
    {
      String key = (String)keys.nextElement();
      String value = ENTITIES.getProperty(key);
      if (value.length() == 1)
      {
        int ivalue = value.charAt(0);
        SEITITNE.put(ivalue, key);
      }
    }
  }
  
  public static int get(String name)
  {
    String value = (String)ENTITIES.get(name);
    return value != null ? value.charAt(0) : -1;
  }
  
  public static String get(int c)
  {
    return SEITITNE.get(c);
  }
  
  private static void load0(String filename)
  {
    try
    {
      ENTITIES.load(HTMLEntities.class.getResourceAsStream(filename));
    }
    catch (IOException e)
    {
      System.err.println("error: unable to load resource \"" + filename + "\"");
    }
  }
  
  static class IntProperties
  {
    private Entry[] entries;
    
    I
1 2 3 4 5 6 7 8 9

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd