nekohtml

   }
    
    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
 * Java Class Version: 1.3 (47.0)
 * JD-Core Version:    0.7.1
 */
package org.cyberneko.html;

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

public abstract interface HTMLErrorReporter
{
  public abstract String formatMessage(String paramString, Object[] paramArrayOfObject);
  
  public abstract void reportWarning(String paramString, Object[] paramArrayOfObject)
    throws XMLParseException;
  
  public abstract void reportError(String paramString, Object[] paramArrayOfObject)
    throws XMLParseException;
}

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

public class HTMLEventInfo$SynthesizedItem
  implements HTMLEventInfo
{
  public int getBeginLineNumber()
  {
    return -1;
  }
  
  public int getBeginColumnNumber()
  {
    return -1;
  }
  
  public int getBeginCharacterOffset()
  {
    return -1;
  }
  
  public int getEndLineNumber()
  {
    return -1;
  }
  
  public int getEndColumnNumber()
  {
    return -1;
  }
  
  public int getEndCharacterOffset()
  {
    return -1;
  }
  
  public boolean isSynthesized()
  {
    return true;
  }
  
  public String toString()
  {
    return "synthesized";
  }
}

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

public abstract interface HTMLEventInfo
{
  public abstract int getBeginLineNumber();
  
  public abstract int getBeginColumnNumber();
  
  public abstract int getBeginCharacterOffset();
  
  public abstract int getEndLineNumber();
  
  public abstract int getEndColumnNumber();
  
  public abstract int getEndCharacterOffset();
  
  public abstract boolean isSynthesized();
  
  public static class SynthesizedItem
    implements HTMLEventInfo
  {
    public int getBeginLineNumber()
    {
      return -1;
    }
    
    public int getBeginColumnNumber()
    {
      return -1;
    }
    
    public int getBeginCharacterOffset()
    {
      return -1;
    }
    
    public int getEndLineNumber()
    {
      return -1;
    }
    
    public int getEndColumnNumber()
    {
      return -1;
    }
    
    public int getEndCharacterOffset()
    {
      return -1;
    }
    
    public boolean isSynthesized()
    {
      return true;
    }
    
    public String toString()
    {
      return "synthesized";
    }
  }
}

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

import java.io.EOFException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Stack;
import org.apache.xerces.util.EncodingMap;
import org.apache.xerces.util.NamespaceSupport;
import org.apache.xerces.util.XMLAttributesImpl;
import org.apache.xerces.util.XMLStringBuffer;
import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.NamespaceContext;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XMLDocumentHandler;
import org.apache.xerces.xni.XMLLocator;
import org.apache.xerces.xni.XMLString;
import org.cyberneko.html.xercesbridge.XercesBridge;

public class HTMLScanner$ContentScanner
  implements HTMLScanner.Scanner
{
  private final QName fQName;
  private final XMLAttributesImpl fAttributes;
  private final HTMLScanner this$0;
  
  public HTMLScanner$ContentScanner(HTMLScanner paramHTMLScanner)
  {
    this$0 = paramHTMLScanner;
    
    fQName = new QName();
    
    fAttributes = new XMLAttributesImpl();
  }
  
  public boolean scan(boolean complete)
    throws IOException
  {
    boolean next;
    do
    {
      try
      {
        next = false;
        switch (this$0.fScannerState)
        {
        case 0: 
          this$0.fBeginLineNumber = this$0.fCurrentEntity.lineNumber;
          this$0.fBeginColumnNumber = this$0.fCurrentEntity.columnNumber;
          this$0.fBeginCharacterOffset = this$0.fCurrentEntity.characterOffset;
          int c = this$0.read();
          if (c == 60)
          {
            this$0.setScannerState((short)1);
            next = true;
          }
          else if (c == 38)
          {
            this$0.scanEntityRef(this$0.fStringBuffer, true);
          }
          else
          {
            if (c == -1) {
              throw new EOFException();
            }
            this$0.fCurrentEntity.offset -= 1;
            this$0.fCurrentEntity.characterOffset -= 1;
            this$0.fCurrentEntity.columnNumber -= 1;
            scanCharacters();
          }
          break;
        case 1: 
          int c = this$0.read();
          if (c == 33)
          {
            if (this$0.skip("--", false))
            {
              scanComment();
            }
            else if (this$0.skip("[CDATA[", false))
            {
              scanCDATA();
            }
            else if (this$0.skip("DOCTYPE", false))
            {
              this$0.scanDoctype();
            }
            else
            {
              if (this$0.fReportErrors) {
                this$0.fErrorReporter.reportError("HTML1002", null);
              }
              this$0.skipMarkup(true);
            }
          }
          else if (c == 63)
          {
            scanPI();
          }
          else if (c == 47)
          {
            scanEndElement();
          }
          else
          {
            if (c == -1)
            {
              if (this$0.fReportErrors) {
                this$0.fErrorReporter.reportError("HTML1003", null);
              }
              if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
              {
                this$0.fStringBuffer.clear();
                this$0.fStringBuffer.append('<');
                this$0.fDocumentHandler.characters(this$0.fStringBuffer, null);
              }
              throw new EOFException();
            }
            this$0.fCurrentEntity.offset -= 1;
            this$0.fCurrentEntity.characterOffset -= 1;
            this$0.fCurrentEntity.columnNumber -= 1;
            this$0.fElementCount += 1;
            HTMLScanner.access$000(this$0)[0] = 0;
            String ename = scanStartElement(HTMLScanner.access$000(this$0));
            this$0.fBeginLineNumber = this$0.fCurrentEntity.lineNumber;
            this$0.fBeginColumnNumber = this$0.fCurrentEntity.columnNumber;
            this$0.fBeginCharacterOffset = this$0.fCurrentEntity.characterOffset;
            if ("script".equalsIgnoreCase(ename))
            {
              scanScriptContent();
            }
            else if ((!this$0.fParseNoScriptContent) && ("noscript".equalsIgnoreCase(ename)))
            {
              scanNoScriptContent();
            }
            else if ((ename != null) && (HTMLScanner.access$000(this$0)[0] == 0) && (HTMLElements.getElement(ename).isSpecial()) && ((!ename.equalsIgnoreCase("TITLE")) || (isEnded(ename))))
            {
              this$0.setScanner(this$0.fSpecialScanner.setElementName(ename));
              this$0.setScannerState((short)0);
              return true;
            }
          }
          this$0.setScannerState((short)0);
          break;
        case 10: 
          if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
          {
            XMLLocator locator = this$0;
            String encoding = this$0.fIANAEncoding;
            Augmentations augs = this$0.locationAugs();
            NamespaceContext nscontext = new NamespaceSupport();
            XercesBridge.getInstance().XMLDocumentHandler_startDocument(this$0.fDocumentHandler, locator, encoding, nscontext, augs);
          }
          if ((this$0.fInsertDoctype) && (this$0.fDocumentHandler != null))
          {
            String root = getElement46name;
            root = HTMLScanner.modifyName(root, this$0.fNamesElems);
            String pubid = this$0.fDoctypePubid;
            String sysid = this$0.fDoctypeSysid;
            this$0.fDocumentHandler.doctypeDecl(root, pubid, sysid, this$0.synthesizedAugs());
          }
          this$0.setScannerState((short)0);
          break;
        case 11: 
          if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth) && (complete))
          {
            this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
            this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
            this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
            this$0.fDocumentHandler.endDocument(this$0.locationAugs());
          }
          return false;
        default: 
          throw new RuntimeException("unknown scanner state: " + this$0.fScannerState);
        }
      }
      catch (EOFException e)
      {
        if (this$0.fCurrentEntityStack.empty()) {
          this$0.setScannerState((short)11);
        } else {
          this$0.fCurrentEntity = ((HTMLScanner.CurrentEntity)this$0.fCurrentEntityStack.pop());
        }
        next = true;
      }
    } while ((next) || (complete));
    return true;
  }
  
  private void scanNoScriptContent()
    throws IOException
  {
    XMLStringBuffer buffer = new XMLStringBuffer();
    for (;;)
    {
      int c = this$0.read();
      if (c == -1) {
        break;
      }
      if (c == 60)
      {
        String next = nextContent(10) + " ";
        if ((next.length() >= 10) && ("/noscript".equalsIgnoreCase(next.substring(0, 9))) && (('>' == next.charAt(9)) || (Character.isWhitespace(next.charAt(9)))))
        {
          this$0.fCurrentEntity.offset -= 1;
          this$0.fCurrentEntity.characterOffset -= 1;
          this$0.fCurrentEntity.columnNumber -= 1;
          break;
        }
      }
      if ((c == 13) || (c == 10))
      {
        this$0.fCurrentEntity.offset -= 1;
        this$0.fCurrentEntity.characterOffset -= 1;
        this$0.fCurrentEntity.columnNumber -= 1;
        int newlines = this$0.skipNewlines();
        for (int i = 0; i < newlines; i++) {
          buffer.append('\n');
        }
      }
      else
      {
        buffer.append((char)c);
      }
    }
    if ((length > 0) && (this$0.fDocumentHandler != null))
    {
      this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
      this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
      this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
      this$0.fDocumentHandler.characters(buffer, this$0.locationAugs());
    }
  }
  
  private void scanScriptContent()
    throws IOException
  {
    XMLStringBuffer buffer = new XMLStringBuffer();
    boolean waitForEndComment = false;
    for (;;)
    {
      int c = this$0.read();
      if (c == -1) {
        break;
      }
      if ((c == 45) && (HTMLScanner.access$100(this$0, buffer, "<!-")))
      {
        waitForEndComment = HTMLScanner.access$200(this$0);
      }
      else if ((!waitForEndComment) && (c == 60))
      {
        String next = nextContent(8) + " ";
        if ((next.length() >= 8) && ("/script".equalsIgnoreCase(next.substring(0, 7))) && (('>' == next.charAt(7)) || (Character.isWhitespace(next.charAt(7)))))
        {
          this$0.fCurrentEntity.offset -= 1;
          this$0.fCurrentEntity.characterOffset -= 1;
          this$0.fCurrentEntity.columnNumber -= 1;
          break;
        }
      }
      else if ((c == 62) && (HTMLScanner.access$100(this$0, buffer, "--")))
      {
        waitForEndComment = false;
      }
      if ((c == 13) || (c == 10))
      {
        this$0.fCurrentEntity.offset -= 1;
        this$0.fCurrentEntity.characterOffset -= 1;
        this$0.fCurrentEntity.columnNumber -= 1;
        int newlines = this$0.skipNewlines();
        for (int i = 0; i < newlines; i++) {
          buffer.append('\n');
        }
      }
      else
      {
        buffer.append((char)c);
      }
    }
    if (this$0.fScriptStripCommentDelims) {
      HTMLScanner.reduceToContent(buffer, "<!--", "-->");
    }
    if (this$0.fScriptStripCDATADelims) {
      HTMLScanner.reduceToContent(buffer, "<![CDATA[", "]]>");
    }
    if ((length > 0) && (this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
    {
      this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
      this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
      this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
      this$0.fDocumentHandler.characters(buffer, this$0.locationAugs());
    }
  }
  
  protected String nextContent(int len)
    throws IOException
  {
    int originalOffset = this$0.fCurrentEntity.offset;
    int originalColumnNumber = this$0.fCurrentEntity.columnNumber;
    int originalCharacterOffset = this$0.fCurrentEntity.characterOffset;
    
    char[] buff = new char[len];
    int nbRead = 0;
    for (nbRead = 0; nbRead < len; nbRead++)
    {
      if (this$0.fCurrentEntity.offset == this$0.fCurrentEntity.length)
      {
        if (this$0.fCurrentEntity.length != this$0.fCurrentEntity.buffer.length) {
          break;
        }
        this$0.load(this$0.fCurrentEntity.buffer.length);
      }
      int c = this$0.read();
      if (c == -1) {
        break;
      }
      buff[nbRead] = ((char)c);
    }
    this$0.fCurrentEntity.offset = originalOffset;
    this$0.fCurrentEntity.columnNumber = originalColumnNumber;
    this$0.fCurrentEntity.characterOffset = originalCharacterOffset;
    return new String(buff, 0, nbRead);
  }
  
  protected void scanCharacters()
    throws IOException
  {
    this$0.fStringBuffer.clear();
    for (;;)
    {
      int newlines = this$0.skipNewlines();
      if ((newlines == 0) && (this$0.fCurrentEntity.offset == this$0.fCurrentEntity.length)) {
        break;
      }
      int offset = this$0.fCurrentEntity.offset - newlines;
      for (int i = offset; i < this$0.fCurrentEntity.offset; i++) {
        this$0.fCurrentEntity.buffer[i] = '\n';
      }
      while (this$0.fCurrentEntity.offset < this$0.fCurrentEntity.length)
      {
        char c = this$0.fCurrentEntity.buffer[this$0.fCurrentEntity.offset];
        if ((c == '<') || (c == '&') || (c == '\n') || (c == '\r')) {
          break;
        }
        this$0.fCurrentEntity.offset += 1;
        this$0.fCurrentEntity.characterOffset += 1;
        this$0.fCurrentEntity.columnNumber += 1;
      }
      if ((this$0.fCurrentEntity.offset > offset) && (this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
      {
        this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
        this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
        this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
        this$0.fStringBuffer.append(this$0.fCurrentEntity.buffer, offset, this$0.fCurrentEntity.offset - offset);
      }
      boolean hasNext = this$0.fCurrentEntity.offset < this$0.fCurrentEntity.buffer.length;
      int next = hasNext ? this$0.fCurrentEntity.buffer[this$0.fCurrentEntity.offset] : -1;
      if ((next == 38) || (next == 60) || (next == -1)) {
        break;
      }
    }
    if (this$0.fStringBuffer.length != 0) {
      this$0.fDocumentHandler.characters(this$0.fStringBuffer, this$0.locationAugs());
    }
  }
  
  protected void scanCDATA()
    throws IOException
  {
    this$0.fStringBuffer.clear();
    if (this$0.fCDATASections)
    {
      if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
      {
        this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
        this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
        this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
        
        this$0.fDocumentHandler.startCDATA(this$0.locationAugs());
      }
    }
    else {
      this$0.fStringBuffer.append("[CDATA[");
    }
    boolean eof = scanMarkupContent(this$0.fStringBuffer, ']');
    if (!this$0.fCDATASections) {
      this$0.fStringBuffer.append("]]");
    }
    if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
    {
      this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
      this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
      this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
      if (this$0.fCDATASections)
      {
        this$0.fDocumentHandler.characters(this$0.fStringBuffer, this$0.locationAugs());
        
        this$0.fDocumentHandler.endCDATA(this$0.locationAugs());
      }
      else
      {
        this$0.fDocumentHandler.comment(this$0.fStringBuffer, this$0.locationAugs());
      }
    }
    if (eof) {
      throw new EOFException();
    }
  }
  
  protected void scanComment()
    throws IOException
  {
    this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
    this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
    this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
    XMLStringBuffer buffer = new XMLStringBuffer();
    boolean eof = scanMarkupContent(buffer, '-');
    if (eof)
    {
      this$0.fCurrentEntity.lineNumber = this$0.fEndLineNumber;
      this$0.fCurrentEntity.columnNumber = this$0.fEndColumnNumber;
      this$0.fCurrentEntity.characterOffset = this$0.fEndCharacterOffset;
      this$0.fCurrentEntity.buffer = ch;
      this$0.fCurrentEntity.offset = offset;
      this$0.fCurrentEntity.length = length;
      buffer = new XMLStringBuffer();
      for (;;)
      {
        int c = this$0.read();
        if (c == -1)
        {
          if (this$0.fReportErrors) {
            this$0.fErrorReporter.reportError("HTML1007", null);
          }
          eof = true;
          break label329;
        }
        if (c != 62)
        {
          buffer.append((char)c);
        }
        else
        {
          if ((c != 10) && (c != 13)) {
            break;
          }
          this$0.fCurrentEntity.offset -= 1;
          this$0.fCurrentEntity.characterOffset -= 1;
          this$0.fCurrentEntity.columnNumber -= 1;
          int newlines = this$0.skipNewlines();
          for (int i = 0; i < newlines; i++) {
            buffer.append('\n');
          }
        }
      }
      eof = false;
    }
    label329:
    if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
    {
      this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
      this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
      this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
      this$0.fDocumentHandler.comment(buffer, this$0.locationAugs());
    }
    if (eof) {
      throw new EOFException();
    }
  }
  
  protected boolean scanMarkupContent(XMLStringBuffer buffer, char cend)
    throws IOException
  {
    int c = -1;
    for (;;)
    {
      c = this$0.read();
      if (c == cend)
      {
        int count = 1;
        for (;;)
        {
          c = this$0.read();
          if (c != cend) {
            break;
          }
          count++;
        }
        if (c == -1)
        {
          if (!this$0.fReportErrors) {
            break;
          }
          this$0.fErrorReporter.reportError("HTML1007", null); break;
        }
        if (count < 2)
        {
          buffer.append(cend);
          
          this$0.fCurrentEntity.offset -= 1;
          this$0.fCurrentEntity.characterOffset -= 1;
          this$0.fCurrentEntity.columnNumber -= 1;
        }
        else if (c != 62)
        {
          for (int i = 0; i < count; i++) {
            buffer.append(cend);
          }
          this$0.fCurrentEntity.offset -= 1;
          this$0.fCurrentEntity.characterOffset -= 1;
          this$0.fCurrentEntity.columnNumber -= 1;
        }
        else
        {
          for (int i = 0; i < count - 2; i++) {
            buffer.append(cend);
          }
          break;
        }
      }
      else if ((c == 10) || (c == 13))
      {
        this$0.fCurrentEntity.offset -= 1;
        this$0.fCurrentEntity.characterOffset -= 1;
        this$0.fCurrentEntity.columnNumber -= 1;
        int newlines = this$0.skipNewlines();
        for (int i = 0; i < newlines; i++) {
          buffer.append('\n');
        }
      }
      else
      {
        if (c == -1)
        {
          if (!this$0.fReportErrors) {
            break;
          }
          this$0.fErrorReporter.reportError("HTML1007", null); break;
        }
        buffer.append((char)c);
      }
    }
    return c == -1;
  }
  
  protected void scanPI()
    throws IOException
  {
    if (this$0.fReportErrors) {
      this$0.fErrorReporter.reportWarning("HTML1008", null);
    }
    String target = this$0.scanName();
    if ((target != null) && (!target.equalsIgnoreCase("xml")))
    {
      for (;;)
      {
        int c = this$0.read();
        if ((c == 13) || (c == 10))
        {
          if (c == 13)
          {
            c = this$0.read();
            if (c != 10)
            {
              this$0.fCurrentEntity.offset -= 1;
              this$0.fCurrentEntity.characterOffset -= 1;
            }
          }
          this$0.fCurrentEntity.lineNumber += 1;
          this$0.fCurrentEntity.columnNumber = 1;
        }
        else
        {
          if (c == -1) {
            break;
          }
          if ((c != 32) && (c != 9))
          {
            this$0.fCurrentEntity.offset -= 1;
            this$0.fCurrentEntity.characterOffset -= 1;
            this$0.fCurrentEntity.columnNumber -= 1;
            break;
          }
        }
      }
      this$0.fStringBuffer.clear();
      for (;;)
      {
        int c = this$0.read();
        if ((c == 63) || (c == 47))
        {
          char c0 = (char)c;
          c = this$0.read();
          if (c == 62) {
            break;
          }
          this$0.fStringBuffer.append(c0);
          this$0.fCurrentEntity.offset -= 1;
          this$0.fCurrentEntity.characterOffset -= 1;
          this$0.fCurrentEntity.columnNumber -= 1;
        }
        else if ((c == 13) || (c == 10))
        {
          this$0.fStringBuffer.append('\n');
          if (c == 13)
          {
            c = this$0.read();
            if (c != 10)
            {
              this$0.fCurrentEntity.offset -= 1;
              this$0.fCurrentEntity.characterOffset -= 1;
            }
          }
          this$0.fCurrentEntity.lineNumber += 1;
          this$0.fCurrentEntity.columnNumber = 1;
        }
        else
        {
          if (c == -1) {
            break;
          }
          this$0.fStringBuffer.append((char)c);
        }
      }
      XMLString data = this$0.fStringBuffer;
      if (this$0.fDocumentHandler != null)
      {
        this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
        this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
        this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
        this$0.fDocumentHandler.processingInstruction(target, data, this$0.locationAugs());
      }
    }
    else
    {
      int beginLineNumber = this$0.fBeginLineNumber;
      int beginColumnNumber = this$0.fBeginColumnNumber;
      int beginCharacterOffset = this$0.fBeginCharacterOffset;
      fAttributes.removeAllAttributes();
      int aindex = 0;
      while (scanPseudoAttribute(fAttributes)) {
        if (fAttributes.getValue(aindex).length() == 0)
        {
          fAttributes.removeAttributeAt(aindex);
        }
        else
        {
          fAttributes.getName(aindex, fQName);
          fQName.rawname = fQName.rawname.toLowerCase();
          fAttributes.setName(aindex, fQName);
          aindex++;
        }
      }
      if (this$0.fDocumentHandler != null)
      {
        String version = fAttributes.getValue("version");
        String encoding = fAttributes.getValue("encoding");
        String standalone = fAttributes.getValue("standalone");
        
        boolean xmlDeclNow = (this$0.fIgnoreSpecifiedCharset) || (!changeEncoding(encoding));
        if (xmlDeclNow)
        {
          this$0.fBeginLineNumber = beginLineNumber;
          this$0.fBeginColumnNumber = beginColumnNumber;
          this$0.fBeginCharacterOffset = beginCharacterOffset;
          this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
          this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
          this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
          this$0.fDocumentHandler.xmlDecl(version, encoding, standalone, this$0.locationAugs());
        }
      }
    }
  }
  
  protected String scanStartElement(boolean[] empty)
    throws IOException
  {
    String ename = this$0.scanName();
    int length = ename != null ? ename.length() : 0;
    int c = length > 0 ? ename.charAt(0) : -1;
    if ((length == 0) || (((c < 97) || (c > 122)) && ((c < 65) || (c > 90))))
    {
      if (this$0.fReportErrors) {
        this$0.fErrorReporter.reportError("HTML1009", null);
      }
      if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
      {
        this$0.fStringBuffer.clear();
        this$0.fStringBuffer.append('<');
        if (length > 0) {
          this$0.fStringBuffer.append(ename);
        }
        this$0.fDocumentHandler.characters(this$0.fStringBuffer, null);
      }
      return null;
    }
    ename = HTMLScanner.modifyName(ename, this$0.fNamesElems);
    fAttributes.removeAllAttributes();
    int beginLineNumber = this$0.fBeginLineNumber;
    int beginColumnNumber = this$0.fBeginColumnNumber;
    int beginCharacterOffset = this$0.fBeginCharacterOffset;
    while (scanAttribute(fAttributes, empty)) {}
    this$0.fBeginLineNumber = beginLineNumber;
    this$0.fBeginColumnNumber = beginColumnNumber;
    this$0.fBeginCharacterOffset = beginCharacterOffset;
    if ((this$0.fByteStream != null) && (this$0.fElementDepth == -1)) {
      if (ename.equalsIgnoreCase("META"))
      {
        String httpEquiv = HTMLScanner.getValue(fAttributes, "http-equiv");
        if ((httpEquiv != null) && (httpEquiv.equalsIgnoreCase("content-type")))
        {
          String content = HTMLScanner.getValue(fAttributes, "content");
          int index1 = content != null ? content.toLowerCase().indexOf("charset=") : -1;
          if ((index1 != -1) && (!this$0.fIgnoreSpecifiedCharset))
          {
            int index2 = content.indexOf(';', index1);
            String charset = index2 != -1 ? content.substring(index1 + 8, index2) : content.substring(index1 + 8);
            changeEncoding(charset);
          }
        }
      }
      else if (ename.equalsIgnoreCase("BODY"))
      {
        this$0.fByteStream.clear();
        this$0.fByteStream = null;
      }
      else
      {
        HTMLElements.Element element = HTMLElements.getElement(ename);
        if ((parent != null) && (parent.length > 0) && 
          (parent[0].code == 14))
        {
          this$0.fByteStream.clear();
          this$0.fByteStream = null;
        }
      }
    }
    if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
    {
      fQName.setValues(null, ename, ename, null);
      
      this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
      this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
      this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
      if (empty[0] != 0) {
        this$0.fDocumentHandler.emptyElement(fQName, fAttributes, this$0.locationAugs());
      } else {
        this$0.fDocumentHandler.startElement(fQName, fAttributes, this$0.locationAugs());
      }
    }
    return ename;
  }
  
  private boolean changeEncoding(String charset)
  {
    if ((charset == null) || (this$0.fByteStream == null)) {
      return false;
    }
    boolean encodingChanged = false;
    try
    {
      String ianaEncoding = charset;
      String javaEncoding = EncodingMap.getIANA2JavaMapping(ianaEncoding.toUpperCase());
      if (javaEncoding == null)
      {
        javaEncoding = ianaEncoding;
        if (this$0.fReportErrors) {
          this$0.fErrorReporter.reportError("HTML1001", new Object[] { ianaEncoding });
        }
      }
      if (!javaEncoding.equals(this$0.fJavaEncoding)) {
        if (!this$0.isEncodingCompatible(javaEncoding, this$0.fJavaEncoding))
        {
          if (this$0.fReportErrors) {
            this$0.fErrorReporter.reportError("HTML1015", new Object[] { javaEncoding, this$0.fJavaEncoding });
          }
        }
        else
        {
          this$0.fIso8859Encoding = ((ianaEncoding == null) || (ianaEncoding.toUpperCase().startsWith("ISO-8859")) || (ianaEncoding.equalsIgnoreCase(this$0.fDefaultIANAEncoding)));
          
          this$0.fJavaEncoding = javaEncoding;
          this$0.fCurrentEntity.stream = new InputStreamReader(this$0.fByteStream, javaEncoding);
          this$0.fByteStream.playback();
          this$0.fElementDepth = this$0.fElementCount;
          this$0.fElementCount = 0;
          this$0.fCurrentEntity.offset = (this$0.fCurrentEntity.length = 0);
          this$0.fCurrentEntity.lineNumber = 1;
          this$0.fCurrentEntity.columnNumber = 1;
          this$0.fCurrentEntity.characterOffset = 0;
          encodingChanged = true;
        }
      }
    }
    catch (UnsupportedEncodingException e)
    {
      if (this$0.fReportErrors) {
        this$0.fErrorReporter.reportError("HTML1010", new Object[] { charset });
      }
      this$0.fByteStream.clear();
      this$0.fByteStream = null;
    }
    return encodingChanged;
  }
  
  protected boolean scanAttribute(XMLAttributesImpl attributes, boolean[] empty)
    throws IOException
  {
    return scanAttribute(attributes, empty, '/');
  }
  
  protected boolean scanPseudoAttribute(XMLAttributesImpl attributes)
    throws IOException
  {
    return scanAttribute(attributes, HTMLScanner.access$000(this$0), '?');
  }
  
  protected boolean scanAttribute(XMLAttributesImpl attributes, boolean[] empty, char endc)
    throws IOException
  {
    boolean skippedSpaces = this$0.skipSpaces();
    this$0.fBeginLineNumber = this$0.fCurrentEntity.lineNumber;
    this$0.fBeginColumnNumber = this$0.fCurrentEntity.columnNumber;
    this$0.fBeginCharacterOffset = this$0.fCurrentEntity.characterOffset;
    int c = this$0.read();
    if (c == -1)
    {
      if (this$0.fReportErrors) {
        this$0.fErrorReporter.reportError("HTML1007", null);
      }
      throw new EOFException();
    }
    if (c == 62) {
      return false;
    }
    this$0.fCurrentEntity.offset -= 1;
    this$0.fCurrentEntity.characterOffset -= 1;
    this$0.fCurrentEntity.columnNumber -= 1;
    String aname = this$0.scanName();
    if (aname == null)
    {
      if (this$0.fReportErrors) {
        this$0.fErrorReporter.reportError("HTML1011", null);
      }
      empty[0] = this$0.skipMarkup(false);
      return false;
    }
    if ((!skippedSpaces) && (this$0.fReportErrors)) {
      this$0.fErrorReporter.reportError("HTML1013", new Object[] { aname });
    }
    aname = HTMLScanner.modifyName(aname, this$0.fNamesAttrs);
    this$0.skipSpaces();
    c = this$0.read();
    if (c == -1)
    {
      if (this$0.fReportErrors) {
        this$0.fErrorReporter.reportError("HTML1007", null);
      }
      throw new EOFException();
    }
    if ((c == 47) || (c == 62))
    {
      fQName.setValues(null, aname, aname, null);
      attributes.addAttribute(fQName, "CDATA", "");
      attributes.setSpecified(attributes.getLength() - 1, true);
      if (this$0.fAugmentations) {
        addLocationItem(attributes, attributes.getLength() - 1);
      }
      if (c == 47)
      {
        this$0.fCurrentEntity.offset -= 1;
        this$0.fCurrentEntity.characterOffset -= 1;
        this$0.fCurrentEntity.columnNumber -= 1;
        empty[0] = this$0.skipMarkup(false);
      }
      return false;
    }
    if (c == 61)
    {
      this$0.skipSpaces();
      c = this$0.read();
      if (c == -1)
      {
        if (this$0.fReportErrors) {
          this$0.fErrorReporter.reportError("HTML1007", null);
        }
        throw new EOFException();
      }
      if (c == 62)
      {
        fQName.setValues(null, aname, aname, null);
        attributes.addAttribute(fQName, "CDATA", "");
        attributes.setSpecified(attributes.getLength() - 1, true);
        if (this$0.fAugmentations) {
          addLocationItem(attributes, attributes.getLength() - 1);
        }
        return false;
      }
      this$0.fStringBuffer.clear();
      HTMLScanner.access$300(this$0).clear();
      if ((c != 39) && (c != 34))
      {
        this$0.fCurrentEntity.offset -= 1;
        this$0.fCurrentEntity.characterOffset -= 1;
        this$0.fCurrentEntity.columnNumber -= 1;
        for (;;)
        {
          c = this$0.read();
          if ((Character.isSpace((char)c)) || (c == 62))
          {
            this$0.fCurrentEntity.offset -= 1;
            this$0.fCurrentEntity.characterOffset -= 1;
            this$0.fCurrentEntity.columnNumber -= 1;
            break;
          }
          if (c == -1)
          {
            if (this$0.fReportErrors) {
              this$0.fErrorReporter.reportError("HTML1007", null);
            }
            throw new EOFException();
          }
          if (c == 38)
          {
            int ce = this$0.scanEntityRef(HTMLScanner.access$400(this$0), false);
            if (ce != -1) {
              this$0.fStringBuffer.append((char)ce);
            } else {
              this$0.fStringBuffer.append(HTMLScanner.access$400(this$0));
            }
            HTMLScanner.access$300(this$0).append(HTMLScanner.access$400(this$0));
          }
          else
          {
            this$0.fStringBuffer.append((char)c);
            HTMLScanner.access$300(this$0).append((char)c);
          }
        }
        fQName.setValues(null, aname, aname, null);
        String avalue = this$0.fStringBuffer.toString();
        attributes.addAttribute(fQName, "CDATA", avalue);
        
        int lastattr = attributes.getLength() - 1;
        attributes.setSpecified(lastattr, true);
        attributes.setNonNormalizedValue(lastattr, HTMLScanner.access$300(this$0).toString());
        if (this$0.fAugmentations) {
          addLocationItem(attributes, attributes.getLength() - 1);
        }
        return true;
      }
      char quote = (char)c;
      boolean isStart = true;
      boolean prevSpace = false;
      do
      {
        boolean acceptSpace = (!this$0.fNormalizeAttributes) || ((!isStart) && (!prevSpace));
        c = this$0.read();
        if (c == -1)
        {
          if (this$0.fReportErrors) {
            this$0.fErrorReporter.reportError("HTML1007", null);
          }
          throw new EOFException();
        }
        if (c == 38)
        {
          isStart = false;
          int ce = this$0.scanEntityRef(HTMLScanner.access$400(this$0), false);
          if (ce != -1) {
            this$0.fStringBuffer.append((char)ce);
          } else {
            this$0.fStringBuffer.append(HTMLScanner.access$400(this$0));
          }
          HTMLScanner.access$300(this$0).append(HTMLScanner.access$400(this$0));
        }
        else if ((c == 32) || (c == 9))
        {
          if (acceptSpace) {
            this$0.fStringBuffer.append(this$0.fNormalizeAttributes ? ' ' : (char)c);
          }
          HTMLScanner.access$300(this$0).append((char)c);
        }
        else if ((c == 13) || (c == 10))
        {
          if (c == 13)
          {
            int c2 = this$0.read();
            if (c2 != 10)
            {
              this$0.fCurrentEntity.offset -= 1;
              this$0.fCurrentEntity.characterOffset -= 1;
              this$0.fCurrentEntity.columnNumber -= 1;
            }
            else
            {
              HTMLScanner.access$300(this$0).append('\r');
              c = c2;
            }
          }
          if (acceptSpace) {
            this$0.fStringBuffer.append(this$0.fNormalizeAttributes ? ' ' : '\n');
          }
          this$0.fCurrentEntity.lineNumber += 1;
          this$0.fCurrentEntity.columnNumber = 1;
          HTMLScanner.access$300(this$0).append((char)c);
        }
        else if (c != quote)
        {
          isStart = false;
          this$0.fStringBuffer.append((char)c);
          HTMLScanner.access$300(this$0).append((char)c);
        }
        prevSpace = (c == 32) || (c == 9) || (c == 13) || (c == 10);
        isStart = (isStart) && (prevSpace);
      } while (c != quote);
      if (this$0.fNormalizeAttributes) {
        if (this$0.fStringBuffer.ch[(this$0.fStringBuffer.length - 1)] == ' ') {
          this$0.fStringBuffer.length -= 1;
        }
      }
      fQName.setValues(null, aname, aname, null);
      String avalue = this$0.fStringBuffer.toString();
      attributes.addAttribute(fQName, "CDATA", avalue);
      
      int lastattr = attributes.getLength() - 1;
      attributes.setSpecified(lastattr, true);
      attributes.setNonNormalizedValue(lastattr, HTMLScanner.access$300(this$0).toString());
      if (this$0.fAugmentations) {
        addLocationItem(attributes, attributes.getLength() - 1);
      }
    }
    else
    {
      fQName.setValues(null, aname, aname, null);
      attributes.addAttribute(fQName, "CDATA", "");
      attributes.setSpecified(attributes.getLength() - 1, true);
      this$0.fCurrentEntity.offset -= 1;
      this$0.fCurrentEntity.characterOffset -= 1;
      this$0.fCurrentEntity.columnNumber -= 1;
      if (this$0.fAugmentations) {
        addLocationItem(attributes, attributes.getLength() - 1);
      }
    }
    return true;
  }
  
  protected void addLocationItem(XMLAttributes attributes, int index)
  {
    this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
    this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
    this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
    HTMLScanner.LocationItem locationItem = new HTMLScanner.LocationItem();
    locationItem.setValues(this$0.fBeginLineNumber, this$0.fBeginColumnNumber, this$0.fBeginCharacterOffset, this$0.fEndLineNumber, this$0.fEndColumnNumber, this$0.fEndCharacterOffset);
    
    Augmentations augs = attributes.getAugmentations(index);
    augs.putItem("http://cyberneko.org/html/features/augmentations", locationItem);
  }
  
  protected void scanEndElement()
    throws IOException
  {
    String ename = this$0.scanName();
    if ((this$0.fReportErrors) && (ename == null)) {
      this$0.fErrorReporter.reportError("HTML1012", null);
    }
    this$0.skipMarkup(false);
    if (ename != null)
    {
      ename = HTMLScanner.modifyName(ename, this$0.fNamesElems);
      if ((this$0.fDocumentHandler != null) && (this$0.fElementCount >= this$0.fElementDepth))
      {
        fQName.setValues(null, ename, ename, null);
        
        this$0.fEndLineNumber = this$0.fCurrentEntity.lineNumber;
        this$0.fEndColumnNumber = this$0.fCurrentEntity.columnNumber;
        this$0.fEndCharacterOffset = this$0.fCurrentEntity.characterOffset;
        this$0.fDocumentHandler.endElement(fQName, this$0.locationAugs());
      }
    }
  }
  
  private boolean isEnded(String ename)
  {
    String content = new String(this$0.fCurren
1 2 3 4 5 6 7 8

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