nekohtml-1.9.14

eturn cl;
  }
}

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

import java.security.PrivilegedAction;

class SecuritySupport12$2
  implements PrivilegedAction
{
  private final SecuritySupport12 this$0;
  
  SecuritySupport12$2(SecuritySupport12 paramSecuritySupport12)
  {
    this$0 = paramSecuritySupport12;
  }
  
  public Object run()
  {
    ClassLoader cl = null;
    try
    {
      cl = ClassLoader.getSystemClassLoader();
    }
    catch (SecurityException ex) {}
    return cl;
  }
}

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

import java.security.PrivilegedAction;

class SecuritySupport12$3
  implements PrivilegedAction
{
  private final ClassLoader val$cl;
  private final SecuritySupport12 this$0;
  
  SecuritySupport12$3(SecuritySupport12 paramSecuritySupport12, ClassLoader paramClassLoader)
  {
    this$0 = paramSecuritySupport12;val$cl = paramClassLoader;
  }
  
  public Object run()
  {
    ClassLoader parent = null;
    try
    {
      parent = val$cl.getParent();
    }
    catch (SecurityException ex) {}
    return parent == val$cl ? null : parent;
  }
}

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

import java.security.PrivilegedAction;

class SecuritySupport12$4
  implements PrivilegedAction
{
  private final String val$propName;
  private final SecuritySupport12 this$0;
  
  SecuritySupport12$4(SecuritySupport12 paramSecuritySupport12, String paramString)
  {
    this$0 = paramSecuritySupport12;val$propName = paramString;
  }
  
  public Object run()
  {
    return System.getProperty(val$propName);
  }
}

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.security.PrivilegedExceptionAction;

class SecuritySupport12$5
  implements PrivilegedExceptionAction
{
  private final File val$file;
  private final SecuritySupport12 this$0;
  
  SecuritySupport12$5(SecuritySupport12 paramSecuritySupport12, File paramFile)
  {
    this$0 = paramSecuritySupport12;val$file = paramFile;
  }
  
  public Object run()
    throws FileNotFoundException
  {
    return new FileInputStream(val$file);
  }
}

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

import java.io.InputStream;
import java.security.PrivilegedAction;

class SecuritySupport12$6
  implements PrivilegedAction
{
  private final ClassLoader val$cl;
  private final String val$name;
  private final SecuritySupport12 this$0;
  
  SecuritySupport12$6(SecuritySupport12 paramSecuritySupport12, ClassLoader paramClassLoader, String paramString)
  {
    this$0 = paramSecuritySupport12;val$cl = paramClassLoader;val$name = paramString;
  }
  
  public Object run()
  {
    InputStream ris;
    InputStream ris;
    if (val$cl == null) {
      ris = ClassLoader.getSystemResourceAsStream(val$name);
    } else {
      ris = val$cl.getResourceAsStream(val$name);
    }
    return ris;
  }
}

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

import java.io.File;
import java.security.PrivilegedAction;

class SecuritySupport12$7
  implements PrivilegedAction
{
  private final File val$f;
  private final SecuritySupport12 this$0;
  
  SecuritySupport12$7(SecuritySupport12 paramSecuritySupport12, File paramFile)
  {
    this$0 = paramSecuritySupport12;val$f = paramFile;
  }
  
  public Object run()
  {
    return new Boolean(val$f.exists());
  }
}

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

import java.io.File;
import java.security.PrivilegedAction;

class SecuritySupport12$8
  implements PrivilegedAction
{
  private final File val$f;
  private final SecuritySupport12 this$0;
  
  SecuritySupport12$8(SecuritySupport12 paramSecuritySupport12, File paramFile)
  {
    this$0 = paramSecuritySupport12;val$f = paramFile;
  }
  
  public Object run()
  {
    return new Long(val$f.lastModified());
  }
}

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

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;

class SecuritySupport12
  extends SecuritySupport
{
  ClassLoader getContextClassLoader()
  {
    (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        ClassLoader cl = null;
        try
        {
          cl = Thread.currentThread().getContextClassLoader();
        }
        catch (SecurityException ex) {}
        return cl;
      }
    });
  }
  
  ClassLoader getSystemClassLoader()
  {
    (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
    {
      public Object run()
      {
        ClassLoader cl = null;
        try
        {
          cl = ClassLoader.getSystemClassLoader();
        }
        catch (SecurityException ex) {}
        return cl;
      }
    });
  }
  
  ClassLoader getParentClassLoader(ClassLoader cl)
  {
    (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final ClassLoader val$cl;
      
      public Object run()
      {
        ClassLoader parent = null;
        try
        {
          parent = val$cl.getParent();
        }
        catch (SecurityException ex) {}
        return parent == val$cl ? null : parent;
      }
    });
  }
  
  String getSystemProperty(String propName)
  {
    (String)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final String val$propName;
      
      public Object run()
      {
        return System.getProperty(val$propName);
      }
    });
  }
  
  FileInputStream getFileInputStream(File file)
    throws FileNotFoundException
  {
    try
    {
      (FileInputStream)AccessController.doPrivileged(new PrivilegedExceptionAction()
      {
        private final File val$file;
        
        public Object run()
          throws FileNotFoundException
        {
          return new FileInputStream(val$file);
        }
      });
    }
    catch (PrivilegedActionException e)
    {
      throw ((FileNotFoundException)e.getException());
    }
  }
  
  InputStream getResourceAsStream(ClassLoader cl, String name)
  {
    (InputStream)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final ClassLoader val$cl;
      private final String val$name;
      
      public Object run()
      {
        InputStream ris;
        InputStream ris;
        if (val$cl == null) {
          ris = ClassLoader.getSystemResourceAsStream(val$name);
        } else {
          ris = val$cl.getResourceAsStream(val$name);
        }
        return ris;
      }
    });
  }
  
  boolean getFileExists(File f)
  {
    ((Boolean)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final File val$f;
      
      public Object run()
      {
        return new Boolean(val$f.exists());
      }
    })).booleanValue();
  }
  
  long getLastModified(File f)
  {
    ((Long)AccessController.doPrivileged(new PrivilegedAction()
    {
      private final File val$f;
      
      public Object run()
      {
        return new Long(val$f.lastModified());
      }
    })).longValue();
  }
}

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

import java.io.PrintStream;

public class Version
{
  public static String getVersion()
  {
    return "NekoHTML 1.9.14";
  }
  
  public static void main(String[] argv)
  {
    System.out.println(getVersion());
  }
}

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

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.XMLResourceIdentifier;
import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLComponentManager;
import org.apache.xerces.xni.parser.XMLConfigurationException;
import org.apache.xerces.xni.parser.XMLDocumentFilter;
import org.apache.xerces.xni.parser.XMLDocumentSource;
import org.cyberneko.html.HTMLComponent;
import org.cyberneko.html.xercesbridge.XercesBridge;

public class DefaultFilter
  implements XMLDocumentFilter, HTMLComponent
{
  protected XMLDocumentHandler fDocumentHandler;
  protected XMLDocumentSource fDocumentSource;
  
  public void setDocumentHandler(XMLDocumentHandler handler)
  {
    fDocumentHandler = handler;
  }
  
  public XMLDocumentHandler getDocumentHandler()
  {
    return fDocumentHandler;
  }
  
  public void setDocumentSource(XMLDocumentSource source)
  {
    fDocumentSource = source;
  }
  
  public XMLDocumentSource getDocumentSource()
  {
    return fDocumentSource;
  }
  
  public void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      XercesBridge.getInstance().XMLDocumentHandler_startDocument(fDocumentHandler, locator, encoding, nscontext, augs);
    }
  }
  
  public void xmlDecl(String version, String encoding, String standalone, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.xmlDecl(version, encoding, standalone, augs);
    }
  }
  
  public void doctypeDecl(String root, String publicId, String systemId, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.doctypeDecl(root, publicId, systemId, augs);
    }
  }
  
  public void comment(XMLString text, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.comment(text, augs);
    }
  }
  
  public void processingInstruction(String target, XMLString data, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.processingInstruction(target, data, augs);
    }
  }
  
  public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.startElement(element, attributes, augs);
    }
  }
  
  public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.emptyElement(element, attributes, augs);
    }
  }
  
  public void characters(XMLString text, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.characters(text, augs);
    }
  }
  
  public void ignorableWhitespace(XMLString text, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.ignorableWhitespace(text, augs);
    }
  }
  
  public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.startGeneralEntity(name, id, encoding, augs);
    }
  }
  
  public void textDecl(String version, String encoding, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.textDecl(version, encoding, augs);
    }
  }
  
  public void endGeneralEntity(String name, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.endGeneralEntity(name, augs);
    }
  }
  
  public void startCDATA(Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.startCDATA(augs);
    }
  }
  
  public void endCDATA(Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.endCDATA(augs);
    }
  }
  
  public void endElement(QName element, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.endElement(element, augs);
    }
  }
  
  public void endDocument(Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      fDocumentHandler.endDocument(augs);
    }
  }
  
  public void startDocument(XMLLocator locator, String encoding, Augmentations augs)
    throws XNIException
  {
    startDocument(locator, encoding, null, augs);
  }
  
  public void startPrefixMapping(String prefix, String uri, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      XercesBridge.getInstance().XMLDocumentHandler_startPrefixMapping(fDocumentHandler, prefix, uri, augs);
    }
  }
  
  public void endPrefixMapping(String prefix, Augmentations augs)
    throws XNIException
  {
    if (fDocumentHandler != null) {
      XercesBridge.getInstance().XMLDocumentHandler_endPrefixMapping(fDocumentHandler, prefix, augs);
    }
  }
  
  public String[] getRecognizedFeatures()
  {
    return null;
  }
  
  public Boolean getFeatureDefault(String featureId)
  {
    return null;
  }
  
  public String[] getRecognizedProperties()
  {
    return null;
  }
  
  public Object getPropertyDefault(String propertyId)
  {
    return null;
  }
  
  public void reset(XMLComponentManager componentManager)
    throws XMLConfigurationException
  {}
  
  public void setFeature(String featureId, boolean state)
    throws XMLConfigurationException
  {}
  
  public void setProperty(String propertyId, Object value)
    throws XMLConfigurationException
  {}
  
  protected static String[] merge(String[] array1, String[] array2)
  {
    if (array1 == array2) {
      return array1;
    }
    if (array1 == null) {
      return array2;
    }
    if (array2 == null) {
      return array1;
    }
    String[] array3 = new String[array1.length + array2.length];
    System.arraycopy(array1, 0, array3, 0, array1.length);
    System.arraycopy(array2, 0, array3, array1.length, array2.length);
    
    return array3;
  }
}

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

import java.util.Hashtable;
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.XMLLocator;
import org.apache.xerces.xni.XMLResourceIdentifier;
import org.apache.xerces.xni.XMLString;
import org.apache.xerces.xni.XNIException;

public class ElementRemover
  extends DefaultFilter
{
  protected static final Object NULL = new Object();
  protected Hashtable fAcceptedElements = new Hashtable();
  protected Hashtable fRemovedElements = new Hashtable();
  protected int fElementDepth;
  protected int fRemovalElementDepth;
  
  public void acceptElement(String element, String[] attributes)
  {
    Object key = element.toLowerCase();
    Object value = NULL;
    if (attributes != null)
    {
      String[] newarray = new String[attributes.length];
      for (int i = 0; i < attributes.length; i++) {
        newarray[i] = attributes[i].toLowerCase();
      }
      value = attributes;
    }
    fAcceptedElements.put(key, value);
  }
  
  public void removeElement(String element)
  {
    Object key = element.toLowerCase();
    Object value = NULL;
    fRemovedElements.put(key, value);
  }
  
  public void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs)
    throws XNIException
  {
    fElementDepth = 0;
    fRemovalElementDepth = Integer.MAX_VALUE;
    super.startDocument(locator, encoding, nscontext, augs);
  }
  
  public void startDocument(XMLLocator locator, String encoding, Augmentations augs)
    throws XNIException
  {
    startDocument(locator, encoding, null, augs);
  }
  
  public void startPrefixMapping(String prefix, String uri, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.startPrefixMapping(prefix, uri, augs);
    }
  }
  
  public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException
  {
    if ((fElementDepth <= fRemovalElementDepth) && (handleOpenTag(element, attributes))) {
      super.startElement(element, attributes, augs);
    }
    fElementDepth += 1;
  }
  
  public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException
  {
    if ((fElementDepth <= fRemovalElementDepth) && (handleOpenTag(element, attributes))) {
      super.emptyElement(element, attributes, augs);
    }
  }
  
  public void comment(XMLString text, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.comment(text, augs);
    }
  }
  
  public void processingInstruction(String target, XMLString data, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.processingInstruction(target, data, augs);
    }
  }
  
  public void characters(XMLString text, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.characters(text, augs);
    }
  }
  
  public void ignorableWhitespace(XMLString text, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.ignorableWhitespace(text, augs);
    }
  }
  
  public void startGeneralEntity(String name, XMLResourceIdentifier id, String encoding, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.startGeneralEntity(name, id, encoding, augs);
    }
  }
  
  public void textDecl(String version, String encoding, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.textDecl(version, encoding, augs);
    }
  }
  
  public void endGeneralEntity(String name, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.endGeneralEntity(name, augs);
    }
  }
  
  public void startCDATA(Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.startCDATA(augs);
    }
  }
  
  public void endCDATA(Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.endCDATA(augs);
    }
  }
  
  public void endElement(QName element, Augmentations augs)
    throws XNIException
  {
    if ((fElementDepth <= fRemovalElementDepth) && (elementAccepted(rawname))) {
      super.endElement(element, augs);
    }
    fElementDepth -= 1;
    if (fElementDepth == fRemovalElementDepth) {
      fRemovalElementDepth = Integer.MAX_VALUE;
    }
  }
  
  public void endPrefixMapping(String prefix, Augmentations augs)
    throws XNIException
  {
    if (fElementDepth <= fRemovalElementDepth) {
      super.endPrefixMapping(prefix, augs);
    }
  }
  
  protected boolean elementAccepted(String element)
  {
    Object key = element.toLowerCase();
    return fAcceptedElements.containsKey(key);
  }
  
  protected boolean elementRemoved(String element)
  {
    Object key = element.toLowerCase();
    return fRemovedElements.containsKey(key);
  }
  
  protected boolean handleOpenTag(QName element, XMLAttributes attributes)
  {
    if (elementAccepted(rawname))
    {
      Object key = rawname.toLowerCase();
      Object value = fAcceptedElements.get(key);
      if (value != NULL)
      {
        String[] anames = (String[])value;
        int attributeCount = attributes.getLength();
        label125:
        for (int i = 0; i < attributeCount; i++)
        {
          String aname = attributes.getQName(i).toLowerCase();
          for (int j = 0; j < anames.length; j++) {
            if (anames[j].equals(aname)) {
              break label125;
            }
          }
          attributes.removeAttributeAt(i--);
          attributeCount--;
        }
      }
      else
      {
        attributes.removeAllAttributes();
      }
      return true;
    }
    if (elementRemoved(rawname)) {
      fRemovalElementDepth = fElementDepth;
    }
    return false;
  }
}

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

import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni.QName;
import org.apache.xerces.xni.XMLAttributes;
import org.apache.xerces.xni.XNIException;
import org.cyberneko.html.HTMLEventInfo;

public class Identity
  extends DefaultFilter
{
  protected static final String AUGMENTATIONS = "http://cyberneko.org/html/features/augmentations";
  protected static final String FILTERS = "http://cyberneko.org/html/properties/filters";
  
  public void startElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException
  {
    if ((augs == null) || (!synthesized(augs))) {
      super.startElement(element, attributes, augs);
    }
  }
  
  public void emptyElement(QName element, XMLAttributes attributes, Augmentations augs)
    throws XNIException
  {
    if ((augs == null) || (!synthesized(augs))) {
      super.emptyElement(element, attributes, augs);
    }
  }
  
  public void endElement(QName element, Augmentations augs)
    throws XNIException
  {
    if ((augs == null) || (!synthesized(augs))) {
      super.endElement(element, augs);
    }
  }
  
  protected static boolean synthesized(Augmentations augs)
  {
    HTMLEventInfo info = (HTMLEventInfo)augs.getItem("http://cyberneko.org/html/features/augmentations");
    return info != null ? info.isSynthesized() : false;
  }
}

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

class NamespaceBinder$NamespaceSupport$Entry
{
  public String prefix;
  public String uri;
  
  public NamespaceBinder$NamespaceSupport$Entry(String prefix, String uri)
  {
    this.prefix = prefix;
    this.uri = uri;
  }
}

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

import java.util.Enumeration;
import java.util.Vector;
import org.apache.xerces.xni.NamespaceContext;

public class NamespaceBinder$NamespaceSupport
  implements NamespaceContext
{
  protected int fTop = 0;
  protected int[] fLevels = new int[10];
  protected Entry[] fEntries = new Entry[10];
  
  public NamespaceBinder$NamespaceSupport()
  {
    pushContext();
    declarePrefix("xml", NamespaceContext.XML_URI);
    declarePrefix("xmlns", NamespaceContext.XMLNS_URI);
  }
  
  public String getURI(String prefix)
  {
    for (int i = fLevels[fTop] - 1; i >= 0; i--)
    {
      Entry entry = fEntries[i];
      if (prefix.equals(prefix)) {
        return uri;
      }
    }
    return null;
  }
  
  public int getDeclaredPrefixCount()
  {
    return fLevels[fTop] - fLevels[(fTop - 1)];
  }
  
  public String getDeclaredPrefixAt(int index)
  {
    return fEntries[(fLevels[(fTop - 1)] + index)].prefix;
  }
  
  public NamespaceContext getParentContext()
  {
    return this;
  }
  
  public void reset()
  {
    fLevels[(fTop = 1)] = fLevels[(fTop - 1)];
  }
  
  public void pushContext()
  {
    if (++fTop == fLevels.length)
    {
      int[] iarray = new int[fLevels.length + 10];
      System.arraycopy(fLevels, 0, iarray, 0, fLevels.length);
      fLevels = iarray;
    }
    fLevels[fTop] = fLevels[(fTop - 1)];
  }
  
  public void popContext()
  {
    if (fTop > 1) {
      fTop -= 1;
    }
  }
  
  public boolean declarePrefix(String prefix, String uri)
  {
    int count = getDeclaredPrefixCount();
    for (int i = 0; i < count; i++)
    {
      String dprefix = getDeclaredPrefixAt(i);
      if (dprefix.equals(prefix)) {
        return false;
      }
    }
    Entry entry = new Entry(prefix, uri);
    if (fLevels[fTop] == fEntries.length)
    {
      Entry[] earray = new Entry[fEntries.length + 10];
      System.arraycopy(fEntries, 0, earray, 0, fEntries.length);
      fEntries = earray;
    }
    int tmp114_111 = fTop; int[] tmp114_107 = fLevels; int tmp116_115 = tmp114_107[tmp114_111];tmp114_107[tmp114_111] = (tmp116_115 + 1);fEntries[tmp116_115] = entry;
    return true;
  }
  
  public String getPrefix(String uri)
  {
    for (int i = fLevels[fTop] - 1; i >= 0; i--)
    {
      Entry entry = fEntries[i];
      if (uri.equals(uri)) {
        return prefix;
      }
    }
    return null;
  }
  
  public Enumeration getAllPrefixes()
  {
    Vector prefixes = new Vector();
    for (int i = fLevels[1]; i < fLevels[fTop]; i++)
    {
      String prefix = fEntries[i].prefix;
      if (!prefixes.contains(prefix)) {
        prefixes.addElement(prefix);
      }
    }
    return prefixes.elements();
  }
  
  static class Entry
  {
    public String prefix;
    public String uri;
    
    public Entry(String prefix, String uri)
    {
      this.prefix = prefix;
      this.uri = uri;
    }
  }
}

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

import java.util.Enumeration;
import java.util.Vector;
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.XMLLocator;
import org.apache.xerces.xni.XNIException;
import org.apache.xerces.xni.parser.XMLComponentManager;
import org.apache.xerces.xni.parser.XMLConfigurationException;
import org.cyberneko.html.HTMLElements;
import org.cyberneko.html.xercesbridge.XercesBridge;

public class NamespaceBinder
  extends DefaultFilter
{
  public static final String XHTML_1_0_URI = "http://www.w3.org/1999/xhtml";
  public static final String XML_URI = "http://www.w3.org/XML/1998/namespace";
  public static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
  protected static final String NAMESPACES = "http://xml.org/sax/features/namespaces";
  protected static final String OVERRIDE_NAMESPACES = "http://cyberneko.org/html/features/override-namespaces";
  protected static final String INSERT_NAMESPACES = "http://cyberneko.org/html/features/insert-namespaces";
  private static final String[] RECOGNIZED_FEATURES = { "http://xml.org/sax/features/namespaces", "http://cyberneko.org/html/features/override-namespaces", "http://cyberneko.org/html/features/insert-namespaces" };
  private static final Boolean[] FEATURE_DEFAULTS = { null, Boolean.FALSE, Boolean.FALSE };
  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 NAMESPACES_URI = "http://cyberneko.org/html/properties/namespaces-uri";
  private static final String[] RECOGNIZED_PROPERTIES = { "http://cyberneko.org/html/properties/names/elems", "http://cyberneko.org/html/properties/names/attrs", "http://cyberneko.org/html/properties/namespaces-uri" };
  private static final Object[] PROPERTY_DEFAULTS = { null, null, "http://www.w3.org/1999/xhtml" };
  protected static final short NAMES_NO_CHANGE = 0;
  protected static final short NAMES_UPPERCASE = 1;
  protected static final short NAMES_LOWERCASE = 2;
  protected boolean fNamespaces;
  protected boolean fNamespacePrefixes;
  protected boolean fOverrideNamespaces;
  protected boolean fInsertNamespaces;
  protected short fNamesElems;
  protected short fNamesAttrs;
  protected String fNamespacesURI;
  protected final NamespaceSupport fNamespaceContext;
  private final QName fQName;
  
  public NamespaceBinder()
  {
    fNamespaceContext = new NamespaceSupport();
    
    fQName = new QName();
  }
  
  public String[] getRecognizedFeatures()
  {
    return merge(super.getRecognizedFeatures(), RECOGNIZED_FEATURES);
  }
  
  public Boolean getFeatureDefault(String featureId)
  {
    for (int i = 0; i < RECOGNIZED_FEATURES.length; i++) {
      if (RECOGNIZED_FEATURES[i].equals(featureId)) {
        return FEATURE_DEFAULTS[i];
      }
    }
    return super.getFeatureDefault(featureId);
  }
  
  public String[] getRecognizedProperties()
  {
    return merge(super.getRecognizedProperties(), RECOGNIZED_PROPERTIES);
  }
  
  public Object getPropertyDefault(String propertyId)
  {
    for (int i = 0; i < RECOGNIZED_PROPERTIES.length; i++) {
      if (RECOGNIZED_PROPERTIES[i].equals(propertyId)) {
        return PROPERTY_DEFAULTS[i];
      }
    }
    return super.getPropertyDefault(propertyId);
  }
  
  public void reset(XMLComponentManager manager)
    throws XMLConfigurationException
  {
    super.reset(manager);
    
    fNamespaces = manager.getFeature("http://xml.org/sax/features/namespaces");
    fOverrideNamespaces = manager.getFeature("http://cyberneko.org/html/features/override-namespaces");
    fInsertNamespaces = manager.getFeature("http://cyberneko.org/html/features/insert-namespaces");
    
    fNamesElems = getNamesValue(String.valueOf(manager.getProperty("http://cyberneko.org/html/properties/names/elems")));
    fNamesAttrs = getNamesValue(String.valueOf(manager.getProperty("http://cyberneko.org/html/properties/names/attrs")));
    fNamespacesURI = String.valueOf(manager.getProperty("http://cyberneko.org/html/properties/namespaces-uri"));
    
    fNamespaceContext.reset();
  }
  
  public void startDocument(XMLLocator locator, String encoding, NamespaceContext nscontext, Augmentations augs)
    throws XNIException
  {
    super.startDocument(locator, encoding, fNamespaceContext, augs);
  }
  
  public void startElement(QName element, XMLAttributes attrs, Augmentations augs)
    throws XNIException
  {
    if (fNamespaces)
    {
      fNamespaceContext.pushContext();
      bindNamespaces(element, attrs);
      
      int dcount = fNamespaceContext.getDeclaredPrefixCount();
      if ((fDocumentHandler != null) && (dcount > 0)) {
        for (int i = 0; i < dcount; i++)
        {
          String prefix = fNamespaceContext.getDeclaredPrefixAt(i);
          String uri = fNamespaceContext.getURI(prefix);
          XercesBridge.getInstance().XMLDocumentHandler_startPrefixMapping(fDocumentHandler, prefix, uri, augs);
        }
      }
    }
    super.startElement(element, attrs, augs);
  }
  
  public void emptyElement(QName element, XMLAttributes attrs, Augmentations augs)
    throws XNIException
  {
    if (fNamespaces)
    {
      fNamespaceContext.pushContext();
      bindNamespaces(element, attrs);
      
      int dcount = fNamespaceContext.getDeclaredPrefixCount();
      if ((fDocumentHandler != null) && (dcount > 0)) {
        for (int i = 0; i < dcount; i++)
        {
          String prefix = fNamespaceContext.getDeclaredPrefixAt(i);
          String uri = fNamespaceContext.getURI(prefix);
          XercesBridge.getInstance().XMLDocumentHandler_startPrefixMapping(fDocumentHandler, prefix, uri, augs);
        }
      }
    }
    super.emptyElement(element, attrs, augs);
    if (fNamespaces)
    {
      int dcount = fNamespaceContext.getDeclaredPrefixCount();
      if ((fDocumentHandler != null) && (dcount > 0)) {
        for (int i = dcount - 1; i >= 0; i--)
        {
          String prefix = fNamespaceContext.getDeclaredPrefixAt(i);
          XercesBridge.getInstance().XMLDocumentHandler_endPrefixMapping(fDocumentHandler, prefix, augs);
        }
      }
      fNamespaceContext.popContext();
    }
  }
  
  public void endElement(QName element, Augmentations augs)
    throws XNIException
  {
    if (fNamespaces) {
      bindNamespaces(element, null);
    }
    super.endElement(element, augs);
    if (fNamespaces)
    {
      int dcount = fNamespaceContext.getDeclaredPrefixCount();
      if ((fDocumentHandler != null) && (dcount > 0)) {
        for (int i = dcount - 1; i >= 0; i--)
        {
          String prefix = fNamespaceContext.getDeclaredPrefixAt(i);
          XercesBridge.getInstance().XMLDocumentHandler_endPrefixMapping(fDocumentHandler, prefix, augs);
        }
      }
      fNamespaceContext.popContext();
    }
  }
  
  protected static void splitQName(QName qname)
  {
    int index = rawname.indexOf(':');
    if (index != -1)
    {
      prefix = rawname.substring(0, index);
      localpart = rawname.substring(index + 1);
    }
  }
  
  protected static final short getNamesValue(String value)
  {
    if (value.equals("lower")) {
      return 2;
    }
    if (value.equals("upper")) {
      return 1;
    }
    return 0;
  }
  
  protected static final String modifyName(String name, short mode)
  {
    switch (mode)
    {
    case 1: 
      return name.toUpperCase();
    case 2: 
      return name.toLowerCase();
    }
    return name;
  }
  
  protected void bindNamespaces(QName element, XMLAttributes attrs)
  {
    splitQName(element);
    
    int attrCount = attrs != null ? attrs.getLength() : 0;
    for (int i = attrCount - 1; i >= 0; i--)
    {
      attrs.getName(i, fQName);
      String aname = fQName.rawname;
      String ANAME = aname.toUpperCase();
      if ((ANAME.startsWith("XMLNS:")) || (ANAME.equals("XMLNS")))
      {
        int anamelen = aname.length();
        
        String aprefix = anamelen > 5 ? aname.substring(0, 5) : null;
        String alocal = anamelen > 5 ? aname.substring(6) : aname;
        String avalue = attrs.getValue(i);
        if (anamelen > 5)
        {
          aprefix = modifyName(aprefix, (short)2);
          alocal = modifyName(alocal, fNamesElems);
          aname = aprefix + ':' + alocal;
        }
        else
        {
          alocal = modifyName(alocal, (short)2);
          aname = alocal;
        }
        fQName.setValues(aprefix, alocal, aname, null);
        attrs.setName(i, fQName);
        
        String prefix = alocal != aname ? alocal : "";
        String uri = avalue.length() > 0 ? avalue : null;
        if ((fOverrideNamespaces) && (prefix.equals(prefix)) && (HTMLElements.getElement(localpart, null) != null)) {
          uri = fNamespacesURI;
        }
        fNamespaceContext.declarePrefix(prefix, uri);
      }
    }
    String prefix = prefix != null ? prefix : "";
    uri = fNamespaceContext.getURI(prefix);
    if ((uri != null) && (prefix == null)) {
      prefix = "";
    }
    if ((fInsertNamespaces) && (attrs != null) && (HTMLElements.getElement(localpart, null) != null)) {
      if ((prefix == null) || (fNamespaceContext.getURI(prefix) == null))
      {
        String xmlns = "xmlns" + (prefix != null ? ":" + prefix : "");
        
        fQName.setValues(null, xmlns, xmlns, null);
        attrs.addAttribute(fQName, "CDATA", fNamespacesURI);
        bindNamespaces(element, attrs);
        return;
      }
    }
    attrCount = attrs != null ? attrs.getLength() : 0;
    for (int i = 0; i < attrCount; i++)
    {
      attrs.getName(i, fQName);
      splitQName(fQName);
      prefix = !fQName.rawname.equals("xmlns") ? "" : fQName.prefix != null ? fQName.prefix : "xmlns";
      if (!prefix.equals("")) {
        fQName.uri = (prefix.equals("xml") ? "http://www.w3.org/XML/1998/namespace" : fNamespaceContext.getURI(prefix));
      }
      if ((prefix.equals("xmlns")) && (fQName.uri == null)) {
        fQName.uri = "http://www.w3.org/2000/xmlns/";
      }
      attrs.setName(i, fQName);
    }
  }
  
  public static class NamespaceSupport
    implements NamespaceContext
  {
    protected int fTop = 0;
    protected int[] fLevels = new int[10];
    protected Entry[] fEntries = new Entry[10];
    
    public NamespaceSupport()
    {
      pushContext();
      declarePrefix("xml", NamespaceContext.XML_URI);
      declarePrefix("xmlns", NamespaceContext.XMLNS_URI);
    }
    
    public String getURI(String prefix)
    {
      for (int i = fLevels[fTop] - 1; i >= 0; i--)
      {
        Entry entry = fEntries[i];
        if (prefix.equals(prefix)) {
          return uri;
        }
      }
      return null;
    }
    
    public int getDeclaredPrefixCount()
    {
      return fLevels[fTop] - fLevels[(fTop - 1)];
    }
    
    public String getDeclaredPrefixAt(int index)
    {
      return fEntries[(fLevels[(fTop - 1)] + index)].prefix;
    }
    
    public NamespaceContext getParentContext()
    {
      return this;
    }
    
    public void reset()
    {
      fLevels[(fTop = 1)] = fLevels[(fTop - 1)];
    }
    
    public void pushContext()
    {
      if (++fTop == fLevels.length)
      {
        int[] iarray = new int[fLevels.length + 10];
        System.arraycopy(fLevels, 0, iarray, 0, fLevels.length);
        fLevels = iarray;
      }
      fLevels[fTop] = fLevels[(fTop - 1)];
    }
    
    public void popContext()
    {
      if (fTop > 1) {
        fTop -= 1;
      }
    }
    
    public boolean declarePrefix(String prefix, String uri)
    {
      int count = getDeclaredPrefixCount();
      for (int i = 0; i < count; i++)
      {
        String dprefix = getDeclaredPrefixAt(i);
        if (dprefix.equals(prefix)) {
          return false;
        }
      }
      Entry entry = new Entry(prefix, uri);
      if (fLevels[fTop] == fEntries.length)
      {
        Entry[] earray = new Entry[fEntries.length + 10];
        System.arraycopy(fEntries, 0, earray, 0, fEntries.length);
        fEntries = earray;
      }
      int tmp114_111 = fTop; int[] tmp114_107 = fLevels; int tmp116_115 = tmp114_107[tmp114_111];tmp114_107[tmp114_111] = (tmp116_115 + 1);fEntries[tmp116_115] = entry;
      return true;
    }
    
    public String getPrefix(String uri)
    {
      for (int i = fLevels[fTop] - 1; i >= 0; i--)
      {
        Entry entry = fEntries[i];
        if (uri.equals(uri)) {
          return prefix;
        }
      }
      return null;
    }
    
    public Enumeration getAllPrefixes()
    {
      Vector prefixes = new Vector();
      for (int i = fLevels[1]; i < fLevels[fTop]; i++)
      {
        String prefix = fEntries[i].prefix;
        if (!prefixes.contains(prefix)) {
          prefixes.addElement(prefix);
        }
      }
      return prefixes.elements();
    }
    
    static class Entry
    {
      public String prefix;
      public String uri;
      
      public Entry(String prefix, String uri)
      {
        this.prefix = prefix;
        this.uri = uri;
      }
    }
  }
}

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

import org.apache.xerces.util.XMLChar;
import org.apache.xerces.util.XMLStringBuffer;
import org.apache.xerces.xni.Augmentations;
import org.apache.xerces.xni
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