org-openide-loaders

16:40:36.282 INFO  jd.cli.Main - Decompiling org-openide-loaders.jar
package org.netbeans.modules.openide.loaders;

class AWTTask$1 {}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.AWTTask.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.awt.EventQueue;
import java.util.concurrent.LinkedBlockingQueue;

final class AWTTask$Processor
  implements Runnable
{
  public void run()
  {
    assert (EventQueue.isDispatchThread());
    for (;;)
    {
      AWTTask localAWTTask = (AWTTask)AWTTask.PENDING.poll();
      if (localAWTTask == null) {
        return;
      }
      localAWTTask.run();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.AWTTask.Processor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.awt.EventQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.util.Mutex;
import org.openide.util.Task;

public final class AWTTask
  extends Task
{
  static final LinkedBlockingQueue<AWTTask> PENDING = new LinkedBlockingQueue();
  private static final Runnable PROCESSOR = new Processor(null);
  private boolean executed;
  
  public AWTTask(Runnable paramRunnable)
  {
    super(paramRunnable);
    PENDING.add(this);
    Mutex.EVENT.readAccess(PROCESSOR);
  }
  
  public void run()
  {
    if (!executed) {
      try
      {
        super.run();
      }
      catch (ThreadDeath localThreadDeath)
      {
        throw localThreadDeath;
      }
      catch (Throwable localThrowable)
      {
        Logger.getLogger("org.openide.awt.Toolbar").log(Level.WARNING, "Error in AWT task", localThrowable);
      }
      finally
      {
        executed = true;
      }
    }
  }
  
  public void waitFinished()
  {
    if (EventQueue.isDispatchThread()) {
      run();
    } else {
      super.waitFinished();
    }
  }
  
  public static final void flush()
  {
    PROCESSOR.run();
  }
  
  private static final class Processor
    implements Runnable
  {
    public void run()
    {
      assert (EventQueue.isDispatchThread());
      for (;;)
      {
        AWTTask localAWTTask = (AWTTask)AWTTask.PENDING.poll();
        if (localAWTTask == null) {
          return;
        }
        localAWTTask.run();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.AWTTask
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.io.IOException;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObject;
import org.openide.loaders.FolderInstance;
import org.openide.loaders.MultiDataObject;
import org.openide.nodes.CookieSet;

public abstract class DataObjectAccessor
{
  public static DataObjectAccessor DEFAULT;
  
  public abstract DataObject copyRename(DataObject paramDataObject, DataFolder paramDataFolder, String paramString1, String paramString2)
    throws IOException;
  
  public abstract CookieSet getCookieSet(MultiDataObject paramMultiDataObject);
  
  public abstract boolean isInstancesThread();
  
  public abstract void precreateInstances(FolderInstance paramFolderInstance);
  
  static
  {
    Class localClass = DataObject.class;
    try
    {
      Class.forName(localClass.getName(), true, localClass.getClassLoader());
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      if (!$assertionsDisabled) {
        throw new AssertionError(localClassNotFoundException);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.DataObjectAccessor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;
import org.netbeans.api.editor.mimelookup.MimeLookup;
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataFolder;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.util.Lookup;

public class DataObjectEncodingQueryImplementation
  extends FileEncodingQueryImplementation
{
  private static ThreadLocal<DataFolder> TARGET = new ThreadLocal();
  private static final Logger LOG = Logger.getLogger(DataObjectEncodingQueryImplementation.class.getName());
  private static final Map<String, Boolean> MIME_TYPE_CHECK_MAP = new HashMap();
  
  public static DataFolder enterIgnoreTargetFolder(DataFolder paramDataFolder)
  {
    DataFolder localDataFolder = (DataFolder)TARGET.get();
    TARGET.set(paramDataFolder);
    return localDataFolder;
  }
  
  public static void exitIgnoreTargetFolder(DataFolder paramDataFolder)
  {
    TARGET.set(paramDataFolder);
  }
  
  public Charset getEncoding(FileObject paramFileObject)
  {
    assert (paramFileObject != null);
    DataFolder localDataFolder = (DataFolder)TARGET.get();
    String str = paramFileObject.getMIMEType();
    FileEncodingQueryImplementation localFileEncodingQueryImplementation = (FileEncodingQueryImplementation)MimeLookup.getLookup(str).lookup(FileEncodingQueryImplementation.class);
    if (localFileEncodingQueryImplementation != null)
    {
      localObject = localFileEncodingQueryImplementation.getEncoding(paramFileObject);
      if (localObject != null) {
        return (Charset)localObject;
      }
    }
    if ((localDataFolder != null) && (localDataFolder.getPrimaryFile().equals(paramFileObject.getParent()))) {
      return null;
    }
    Object localObject = (Boolean)MIME_TYPE_CHECK_MAP.get(str);
    if ((localObject == null) || (((Boolean)localObject).booleanValue()) || ("content/unknown".equals(str)))
    {
      DataObject localDataObject;
      try
      {
        localDataObject = DataObject.find(paramFileObject);
      }
      catch (DataObjectNotFoundException localDataObjectNotFoundException)
      {
        LOG.warning("Invalid DataObject: " + FileUtil.getFileDisplayName(paramFileObject));
        return null;
      }
      localFileEncodingQueryImplementation = (FileEncodingQueryImplementation)localDataObject.getLookup().lookup(FileEncodingQueryImplementation.class);
      if (localFileEncodingQueryImplementation != null)
      {
        MIME_TYPE_CHECK_MAP.put(str, Boolean.TRUE);
        return localFileEncodingQueryImplementation.getEncoding(paramFileObject);
      }
      MIME_TYPE_CHECK_MAP.put(str, Boolean.FALSE);
    }
    return null;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.DataObjectEncodingQueryImplementation
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

class EntityCatalogImpl$1 {}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.EntityCatalogImpl.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.net.URL;
import java.util.Hashtable;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.cookies.InstanceCookie;
import org.openide.filesystems.FileObject;
import org.openide.loaders.XMLDataObject;
import org.openide.loaders.XMLDataObject.Processor;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.WeakListeners;
import org.openide.xml.EntityCatalog;
import org.openide.xml.XMLUtil;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

public class EntityCatalogImpl$RegistrationProcessor
  extends DefaultHandler
  implements XMLDataObject.Processor, InstanceCookie, Runnable, PropertyChangeListener
{
  private XMLDataObject peer;
  private Map<String, String> map;
  private RequestProcessor.Task parsingTask = EntityCatalogImpl.access$000().create(this);
  private EntityCatalogImpl instance = null;
  
  public void attachTo(XMLDataObject paramXMLDataObject)
  {
    if (paramXMLDataObject == peer) {
      return;
    }
    peer = paramXMLDataObject;
    peer.addPropertyChangeListener(WeakListeners.propertyChange(this, peer));
    parsingTask.schedule(0);
  }
  
  public void startElement(String paramString1, String paramString2, String paramString3, Attributes paramAttributes)
    throws SAXException
  {
    if ("public".equals(paramString3))
    {
      String str1 = paramAttributes.getValue("publicId");
      String str2 = paramAttributes.getValue("uri");
      if ((str1 != null) && (str2 != null)) {
        map.put(str1, str2);
      } else {
        throw new SAXException("invalid <public> element: missing publicId or uri");
      }
    }
  }
  
  public InputSource resolveEntity(String paramString1, String paramString2)
  {
    if ("-//NetBeans//Entity Mapping Registration 1.0//EN".equals(paramString1)) {
      return new InputSource(EntityCatalogImpl.class.getClassLoader().getResource("org/openide/xml/EntityCatalog.dtd").toExternalForm());
    }
    return null;
  }
  
  public void run()
  {
    map = new Hashtable();
    try
    {
      String str = peer.getPrimaryFile().getURL().toExternalForm();
      InputSource localInputSource = new InputSource(str);
      
      XMLReader localXMLReader = XMLUtil.createXMLReader(false);
      localXMLReader.setErrorHandler(this);
      localXMLReader.setContentHandler(this);
      localXMLReader.setEntityResolver(this);
      localXMLReader.parse(localInputSource);
    }
    catch (SAXException localSAXException)
    {
      Logger.getLogger(EntityCatalogImpl.class.getName()).log(Level.WARNING, null, localSAXException);
    }
    catch (IOException localIOException)
    {
      Logger.getLogger(EntityCatalogImpl.class.getName()).log(Level.WARNING, null, localIOException);
    }
  }
  
  public Class instanceClass()
    throws IOException, ClassNotFoundException
  {
    return EntityCatalog.class;
  }
  
  public Object instanceCreate()
    throws IOException, ClassNotFoundException
  {
    synchronized (this)
    {
      if (instance == null)
      {
        parsingTask.waitFinished();
        instance = new EntityCatalogImpl(map, null);
      }
    }
    return instance;
  }
  
  public String instanceName()
  {
    return "org.openide.xml.EntityCatalog";
  }
  
  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    synchronized (this)
    {
      if (instance == null) {
        return;
      }
    }
    if ("document".equals(paramPropertyChangeEvent.getPropertyName()))
    {
      run();
      EntityCatalogImpl.access$202(instance, map);
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.EntityCatalogImpl.RegistrationProcessor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.net.URL;
import java.util.Hashtable;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.cookies.InstanceCookie;
import org.openide.filesystems.FileObject;
import org.openide.loaders.XMLDataObject;
import org.openide.loaders.XMLDataObject.Processor;
import org.openide.util.RequestProcessor;
import org.openide.util.RequestProcessor.Task;
import org.openide.util.WeakListeners;
import org.openide.xml.EntityCatalog;
import org.openide.xml.XMLUtil;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;

public final class EntityCatalogImpl
  extends EntityCatalog
{
  private Map<String, String> id2uri;
  private static final RequestProcessor catalogRP = new RequestProcessor("EntityCatalog/parser");
  
  private EntityCatalogImpl(Map<String, String> paramMap)
  {
    id2uri = paramMap;
  }
  
  public InputSource resolveEntity(String paramString1, String paramString2)
  {
    if (paramString1 == null) {
      return null;
    }
    String str = (String)id2uri.get(paramString1);
    
    InputSource localInputSource = null;
    if (str != null) {
      localInputSource = new InputSource(str);
    }
    return localInputSource;
  }
  
  public static class RegistrationProcessor
    extends DefaultHandler
    implements XMLDataObject.Processor, InstanceCookie, Runnable, PropertyChangeListener
  {
    private XMLDataObject peer;
    private Map<String, String> map;
    private RequestProcessor.Task parsingTask = EntityCatalogImpl.catalogRP.create(this);
    private EntityCatalogImpl instance = null;
    
    public void attachTo(XMLDataObject paramXMLDataObject)
    {
      if (paramXMLDataObject == peer) {
        return;
      }
      peer = paramXMLDataObject;
      peer.addPropertyChangeListener(WeakListeners.propertyChange(this, peer));
      parsingTask.schedule(0);
    }
    
    public void startElement(String paramString1, String paramString2, String paramString3, Attributes paramAttributes)
      throws SAXException
    {
      if ("public".equals(paramString3))
      {
        String str1 = paramAttributes.getValue("publicId");
        String str2 = paramAttributes.getValue("uri");
        if ((str1 != null) && (str2 != null)) {
          map.put(str1, str2);
        } else {
          throw new SAXException("invalid <public> element: missing publicId or uri");
        }
      }
    }
    
    public InputSource resolveEntity(String paramString1, String paramString2)
    {
      if ("-//NetBeans//Entity Mapping Registration 1.0//EN".equals(paramString1)) {
        return new InputSource(EntityCatalogImpl.class.getClassLoader().getResource("org/openide/xml/EntityCatalog.dtd").toExternalForm());
      }
      return null;
    }
    
    public void run()
    {
      map = new Hashtable();
      try
      {
        String str = peer.getPrimaryFile().getURL().toExternalForm();
        InputSource localInputSource = new InputSource(str);
        
        XMLReader localXMLReader = XMLUtil.createXMLReader(false);
        localXMLReader.setErrorHandler(this);
        localXMLReader.setContentHandler(this);
        localXMLReader.setEntityResolver(this);
        localXMLReader.parse(localInputSource);
      }
      catch (SAXException localSAXException)
      {
        Logger.getLogger(EntityCatalogImpl.class.getName()).log(Level.WARNING, null, localSAXException);
      }
      catch (IOException localIOException)
      {
        Logger.getLogger(EntityCatalogImpl.class.getName()).log(Level.WARNING, null, localIOException);
      }
    }
    
    public Class instanceClass()
      throws IOException, ClassNotFoundException
    {
      return EntityCatalog.class;
    }
    
    public Object instanceCreate()
      throws IOException, ClassNotFoundException
    {
      synchronized (this)
      {
        if (instance == null)
        {
          parsingTask.waitFinished();
          instance = new EntityCatalogImpl(map, null);
        }
      }
      return instance;
    }
    
    public String instanceName()
    {
      return "org.openide.xml.EntityCatalog";
    }
    
    public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
    {
      synchronized (this)
      {
        if (instance == null) {
          return;
        }
      }
      if ("document".equals(paramPropertyChangeEvent.getPropertyName()))
      {
        run();
        instance.id2uri = map;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.EntityCatalogImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileSystem;
import org.openide.xml.XMLUtil;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;

class FileEntityResolver$DTDParser
  extends DefaultHandler
  implements LexicalHandler
{
  private String publicId = null;
  private FileObject src;
  
  public FileEntityResolver$DTDParser(FileObject paramFileObject)
  {
    src = paramFileObject;
  }
  
  public String getPublicId()
  {
    return publicId;
  }
  
  public void parse()
  {
    BufferedInputStream localBufferedInputStream = null;
    try
    {
      XMLReader localXMLReader = XMLUtil.createXMLReader(false, false);
      localXMLReader.setContentHandler(this);
      localXMLReader.setEntityResolver(this);
      localBufferedInputStream = new BufferedInputStream(src.getInputStream());
      InputSource localInputSource = new InputSource(localBufferedInputStream);
      try
      {
        localXMLReader.setFeature("http://xml.org/sax/features/validation", false);
      }
      catch (SAXException localSAXException1)
      {
        FileEntityResolver.ERR.warning("XML parser does not support validation feature.");
      }
      try
      {
        localXMLReader.setProperty("http://xml.org/sax/properties/lexical-handler", this);
      }
      catch (SAXException localSAXException2)
      {
        FileEntityResolver.ERR.warning("XML parser does not support lexical-handler feature.");
      }
      localXMLReader.parse(localInputSource); return;
    }
    catch (FileEntityResolver.StopSaxException localStopSaxException)
    {
      FileEntityResolver.ERR.log(Level.FINE, null, localStopSaxException);
    }
    catch (Exception localException)
    {
      if ("org.openide.util.lookup.AbstractLookup$ISE".equals(localException.getClass().getName())) {
        throw ((IllegalStateException)localException);
      }
      try
      {
        if ((src.getFileSystem().isDefault()) && (!src.getPath().startsWith("Windows2Local"))) {
          FileEntityResolver.ERR.log(Level.WARNING, null, new IOException("Parsing " + src + ": " + localException.getMessage()).initCause(localException));
        }
      }
      catch (FileStateInvalidException localFileStateInvalidException) {}
    }
    finally
    {
      try
      {
        if (localBufferedInputStream != null) {
          localBufferedInputStream.close();
        }
      }
      catch (IOException localIOException4)
      {
        FileEntityResolver.ERR.log(Level.WARNING, "Closing stream for " + src, localIOException4);
      }
    }
  }
  
  public InputSource resolveEntity(String paramString1, String paramString2)
  {
    InputSource localInputSource = new InputSource(new StringReader(""));
    localInputSource.setSystemId("StringReader");
    return localInputSource;
  }
  
  public void endDTD()
    throws SAXException
  {
    throw FileEntityResolver.access$000();
  }
  
  public void startDTD(String paramString1, String paramString2, String paramString3)
    throws SAXException
  {
    publicId = paramString2;
  }
  
  public void startEntity(String paramString)
    throws SAXException
  {}
  
  public void endEntity(String paramString)
    throws SAXException
  {}
  
  public void comment(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    throws SAXException
  {}
  
  public void startCDATA()
    throws SAXException
  {}
  
  public void endCDATA()
    throws SAXException
  {}
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.FileEntityResolver.DTDParser
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.filesystems.FileAttributeEvent;
import org.openide.filesystems.FileChangeListener;
import org.openide.filesystems.FileEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileRenameEvent;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Template;
import org.openide.util.WeakListeners;
import org.openide.util.lookup.ProxyLookup;

final class FileEntityResolver$Lkp
  extends ProxyLookup
  implements PropertyChangeListener, FileChangeListener
{
  private String id;
  private Reference<DataObject> xml;
  private volatile FileObject folder;
  private volatile DataObject obj;
  
  public FileEntityResolver$Lkp(String paramString, DataObject paramDataObject)
  {
    super(new Lookup[0]);
    id = paramString;
    xml = new WeakReference(paramDataObject);
  }
  
  protected void beforeLookup(Lookup.Template paramTemplate)
  {
    if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
      FileEntityResolver.ERR.fine("beforeLookup: " + paramTemplate.getType() + " for " + getXml());
    }
    if ((folder == null) && (obj == null)) {
      update();
    }
  }
  
  private void update()
  {
    if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
      FileEntityResolver.ERR.fine("update: " + id + " for " + getXml());
    }
    FileObject[] arrayOfFileObject = new FileObject[1];
    FileObject localFileObject = FileEntityResolver.access$100(id, arrayOfFileObject);
    if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
      FileEntityResolver.ERR.fine("fo: " + localFileObject + " for " + getXml());
    }
    DataObject localDataObject = null;
    if (localFileObject != null) {
      try
      {
        localDataObject = DataObject.find(localFileObject);
        if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
          FileEntityResolver.ERR.fine("object found: " + localDataObject + " for " + getXml());
        }
      }
      catch (DataObjectNotFoundException localDataObjectNotFoundException)
      {
        Exceptions.printStackTrace(localDataObjectNotFoundException);
      }
    }
    Lookup localLookup;
    if (localDataObject == obj)
    {
      if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
        FileEntityResolver.ERR.fine("same data object for " + getXml());
      }
      localLookup = FileEntityResolver.access$200(getXml(), localDataObject);
      if ((localDataObject != null) && (localLookup != null))
      {
        if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
          FileEntityResolver.ERR.fine("updating lookups for " + getXml());
        }
        setLookups(new Lookup[] { localLookup });
        if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
          FileEntityResolver.ERR.fine("updating lookups done for " + getXml());
        }
        return;
      }
    }
    else
    {
      localLookup = FileEntityResolver.access$200(getXml(), localDataObject);
      if ((localDataObject != null) && (localLookup != null))
      {
        if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
          FileEntityResolver.ERR.fine("change the lookup");
        }
        localDataObject.addPropertyChangeListener(WeakListeners.propertyChange(this, localDataObject));
        
        obj = localDataObject;
        
        setLookups(new Lookup[] { localLookup });
        if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
          FileEntityResolver.ERR.fine("change in lookup done for " + getXml());
        }
        if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
          FileEntityResolver.ERR.fine("data object updated to " + obj + " for " + getXml());
        }
        return;
      }
      obj = localDataObject;
      if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
        FileEntityResolver.ERR.fine("data object updated to " + obj + " for " + getXml());
      }
    }
    if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
      FileEntityResolver.ERR.fine("delegating to nobody for " + obj + " for " + getXml());
    }
    setLookups(new Lookup[0]);
    if (folder != arrayOfFileObject[0])
    {
      folder = arrayOfFileObject[0];
      arrayOfFileObject[0].addFileChangeListener(FileUtil.weakFileChangeListener(this, arrayOfFileObject[0]));
    }
  }
  
  public void fileDeleted(FileEvent paramFileEvent)
  {
    update();
  }
  
  public void fileFolderCreated(FileEvent paramFileEvent)
  {
    update();
  }
  
  public void fileDataCreated(FileEvent paramFileEvent)
  {
    update();
  }
  
  public void fileAttributeChanged(FileAttributeEvent paramFileAttributeEvent) {}
  
  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    String str = paramPropertyChangeEvent.getPropertyName();
    if (("cookie".equals(str)) || ("name".equals(str)) || ("valid".equals(str)) || ("primaryFile".equals(str))) {
      update();
    }
  }
  
  public void fileRenamed(FileRenameEvent paramFileRenameEvent)
  {
    update();
  }
  
  public void fileChanged(FileEvent paramFileEvent) {}
  
  private DataObject getXml()
  {
    return (DataObject)xml.get();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.FileEntityResolver.Lkp
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import org.xml.sax.SAXException;

class FileEntityResolver$StopSaxException
  extends SAXException
{
  public FileEntityResolver$StopSaxException()
  {
    super("STOP");
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.openide.loaders.FileEntityResolver.StopSaxException
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.openide.loaders;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.cookies.InstanceCookie;
import org.openide.filesystems.FileAttributeEvent;
import org.openide.filesystems.FileChangeListener;
import org.openide.filesystems.FileEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileRenameEvent;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileSystem;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.loaders.DataObjectNotFoundException;
import org.openide.loaders.Environment.Provider;
import org.openide.loaders.InstanceDataObject;
import org.openide.loaders.XMLDataObject;
import org.openide.loaders.XMLDataObject.Info;
import org.openide.loaders.XMLDataObject.Processor;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Template;
import org.openide.util.WeakListeners;
import org.openide.util.lookup.ProxyLookup;
import org.openide.xml.EntityCatalog;
import org.openide.xml.XMLUtil;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;

public final class FileEntityResolver
  extends EntityCatalog
  implements Environment.Provider
{
  private static final String ENTITY_PREFIX = "/xml/entities";
  private static final String LOOKUP_PREFIX = "/xml/lookups";
  static final Logger ERR = Logger.getLogger(FileEntityResolver.class.getName());
  private static Method method;
  
  public InputSource resolveEntity(String paramString1, String paramString2)
    throws IOException, SAXException
  {
    if (paramString1 == null) {
      return null;
    }
    String str = convertPublicId(paramString1);
    
    StringBuffer localStringBuffer = new StringBuffer(200);
    localStringBuffer.append("/xml/entities");
    localStringBuffer.append(str);
    
    FileObject localFileObject = FileUtil.getConfigFile(localStringBuffer.toString());
    if (localFileObject != null)
    {
      InputSource localInputSource = new InputSource(localFileObject.getInputStream());
      try
      {
        Object localObject = localFileObject.getAttribute("hint.originalPublicID");
        if ((localObject instanceof String)) {
          localInputSource.setPublicId((String)localObject);
        }
        URL localURL = localFileObject.getURL();
        localInputSource.setSystemId(localURL.toString());
      }
      catch (IOException localIOException) {}
      return localInputSource;
    }
    return null;
  }
  
  public Lookup getEnvironment(DataObject paramDataObject)
  {
    if ((paramDataObject instanceof XMLDataObject))
    {
      XMLDataObject localXMLDataObject = (XMLDataObject)paramDataObject;
      
      String str = null;
      try
      {
        DocumentType localDocumentType = localXMLDataObject.getDocument().getDoctype();
        if (localDocumentType != null) {
          str = localDocumentType.getPublicId();
        }
      }
      catch (IOException localIOException)
      {
        Exceptions.printStackTrace(localIOException);
        return null;
      }
      catch (SAXException localSAXException)
      {
        Exceptions.printStackTrace(localSAXException);
        return null;
      }
      if (str == null) {
        return null;
      }
      str = convertPublicId(str);
      
      return new Lkp(str, localXMLDataObject);
    }
    if ((paramDataObject instanceof InstanceDataObject)) {
      return getEnvForIDO((InstanceDataObject)paramDataObject);
    }
    return null;
  }
  
  private Lookup getEnvForIDO(InstanceDataObject paramInstanceDataObject)
  {
    DTDParser localDTDParser = new DTDParser(paramInstanceDataObject.getPrimaryFile());
    localDTDParser.parse();
    String str = localDTDParser.getPublicId();
    if (str == null) {
      return null;
    }
    str = convertPublicId(str);
    return new Lkp(str, paramInstanceDataObject);
  }
  
  private static Lookup findLookup(DataObject paramDataObject1, DataObject paramDataObject2)
  {
    if (paramDataObject2 == null) {
      return null;
    }
    try
    {
      InstanceCookie localInstanceCookie = (InstanceCookie)paramDataObject2.getCookie(InstanceCookie.class);
      if (localInstanceCookie != null)
      {
        Object localObject = localInstanceCookie.instanceCreate();
        if ((localObject instanceof Environment.Provider)) {
          return ((Environment.Provider)localObject).getEnvironment(paramDataObject1);
        }
        if (!(paramDataObject1 instanceof XMLDataObject)) {
          return null;
        }
        if ((localObject instanceof XMLDataObject.Processor))
        {
          XMLDataObject.Info localInfo = new XMLDataObject.Info();
          localInfo.addProcessorClass(localObject.getClass());
          localObject = localInfo;
        }
        if ((localObject instanceof XMLDataObject.Info)) {
          return createInfoLookup((XMLDataObject)paramDataObject1, (XMLDataObject.Info)localObject);
        }
      }
    }
    catch (IOException localIOException)
    {
      ERR.log(Level.INFO, "no environment for " + paramDataObject1, localIOException);
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      ERR.log(Level.INFO, "no environment for " + paramDataObject1, localClassNotFoundException);
    }
    return null;
  }
  
  private static Lookup createInfoLookup(XMLDataObject paramXMLDataObject, XMLDataObject.Info paramInfo)
  {
    synchronized (FileEntityResolver.class)
    {
      if (method == null) {
        try
        {
          Method localMethod = XMLDataObject.class.getDeclaredMethod("createInfoLookup", new Class[] { XMLDataObject.class, XMLDataObject.Info.class });
          
          localMethod.setAccessible(true);
          method = localMethod;
        }
        catch (Exception localException2)
        {
          Exceptions.printStackTrace(localException2);
          return null;
        }
      }
    }
    try
    {
      return (Lookup)method.invoke(null, new Object[] { paramXMLDataObject, paramInfo });
    }
    catch (Exception localException1)
    {
      Exceptions.printStackTrace(localException1);
    }
    return null;
  }
  
  private static String convertPublicId(String paramString)
  {
    char[] arrayOfChar = paramString.toCharArray();
    
    int i = 0;
    int j = 0;
    int k = 0;
    for (int m = 0; m < arrayOfChar.length; m++)
    {
      int n = arrayOfChar[m];
      switch (j)
      {
      case 0: 
        if ((n == 43) || (n == 45) || (n == 73) || (n == 83) || (n == 79)) {
          continue;
        }
        j = 1;
      case 1: 
        if (n == 47)
        {
          j = 2;
          i++;
          if (i == 3) {
            break label209;
          }
          arrayOfChar[(k++)] = '/';
        }
        break;
      case 2: 
        if (n == 47) {
          continue;
        }
        j = 1;
      }
      if (((n >= 65) && (n <= 90)) || ((n >= 97) && (n <= 122)) || ((n >= 48) && (n <= 57))) {
        arrayOfChar[(k++)] = n;
      } else {
        arrayOfChar[(k++)] = '_';
      }
    }
    label209:
    return new String(arrayOfChar, 0, k);
  }
  
  private static FileObject findObject(String paramString, FileObject[] paramArrayOfFileObject)
  {
    StringBuffer localStringBuffer = new StringBuffer(200);
    localStringBuffer.append("/xml/lookups");
    localStringBuffer.append(paramString);
    int i = localStringBuffer.length();
    
    localStringBuffer.append(".instance");
    
    String str = localStringBuffer.toString();
    int j = searchFolder(FileUtil.getConfigRoot(), str, paramArrayOfFileObject);
    if (j == -1) {
      return null;
    }
    FileObject localFileObject = paramArrayOfFileObject[0].getFileObject(str.substring(j));
    if (localFileObject == null)
    {
      localStringBuffer.setLength(i);
      localStringBuffer.append(".xml");
      
      localFileObject = paramArrayOfFileObject[0].getFileObject(localStringBuffer.toString().substring(j));
    }
    return localFileObject;
  }
  
  private static int searchFolder(FileObject paramFileObject, String paramString, FileObject[] paramArrayOfFileObject)
  {
    int i = 0;
    for (;;)
    {
      int j = paramString.indexOf('/', i);
      if (j == -1)
      {
        paramArrayOfFileObject[0] = paramFileObject;
        return i;
      }
      if (j == i)
      {
        i++;
      }
      else
      {
        FileObject localFileObject = paramFileObject.getFileObject(paramString.substring(i, j));
        if (localFileObject == null)
        {
          paramArrayOfFileObject[0] = paramFileObject;
          return -1;
        }
        i = j + 1;
        paramFileObject = localFileObject;
      }
    }
  }
  
  private static class StopSaxException
    extends SAXException
  {
    public StopSaxException()
    {
      super();
    }
  }
  
  private static final StopSaxException STOP = new StopSaxException();
  
  private static class DTDParser
    extends DefaultHandler
    implements LexicalHandler
  {
    private String publicId = null;
    private FileObject src;
    
    public DTDParser(FileObject paramFileObject)
    {
      src = paramFileObject;
    }
    
    public String getPublicId()
    {
      return publicId;
    }
    
    public void parse()
    {
      BufferedInputStream localBufferedInputStream = null;
      try
      {
        XMLReader localXMLReader = XMLUtil.createXMLReader(false, false);
        localXMLReader.setContentHandler(this);
        localXMLReader.setEntityResolver(this);
        localBufferedInputStream = new BufferedInputStream(src.getInputStream());
        InputSource localInputSource = new InputSource(localBufferedInputStream);
        try
        {
          localXMLReader.setFeature("http://xml.org/sax/features/validation", false);
        }
        catch (SAXException localSAXException1)
        {
          FileEntityResolver.ERR.warning("XML parser does not support validation feature.");
        }
        try
        {
          localXMLReader.setProperty("http://xml.org/sax/properties/lexical-handler", this);
        }
        catch (SAXException localSAXException2)
        {
          FileEntityResolver.ERR.warning("XML parser does not support lexical-handler feature.");
        }
        localXMLReader.parse(localInputSource); return;
      }
      catch (FileEntityResolver.StopSaxException localStopSaxException)
      {
        FileEntityResolver.ERR.log(Level.FINE, null, localStopSaxException);
      }
      catch (Exception localException)
      {
        if ("org.openide.util.lookup.AbstractLookup$ISE".equals(localException.getClass().getName())) {
          throw ((IllegalStateException)localException);
        }
        try
        {
          if ((src.getFileSystem().isDefault()) && (!src.getPath().startsWith("Windows2Local"))) {
            FileEntityResolver.ERR.log(Level.WARNING, null, new IOException("Parsing " + src + ": " + localException.getMessage()).initCause(localException));
          }
        }
        catch (FileStateInvalidException localFileStateInvalidException) {}
      }
      finally
      {
        try
        {
          if (localBufferedInputStream != null) {
            localBufferedInputStream.close();
          }
        }
        catch (IOException localIOException4)
        {
          FileEntityResolver.ERR.log(Level.WARNING, "Closing stream for " + src, localIOException4);
        }
      }
    }
    
    public InputSource resolveEntity(String paramString1, String paramString2)
    {
      InputSource localInputSource = new InputSource(new StringReader(""));
      localInputSource.setSystemId("StringReader");
      return localInputSource;
    }
    
    public void endDTD()
      throws SAXException
    {
      throw FileEntityResolver.STOP;
    }
    
    public void startDTD(String paramString1, String paramString2, String paramString3)
      throws SAXException
    {
      publicId = paramString2;
    }
    
    public void startEntity(String paramString)
      throws SAXException
    {}
    
    public void endEntity(String paramString)
      throws SAXException
    {}
    
    public void comment(char[] paramArrayOfChar, int paramInt1, int paramInt2)
      throws SAXException
    {}
    
    public void startCDATA()
      throws SAXException
    {}
    
    public void endCDATA()
      throws SAXException
    {}
  }
  
  private static final class Lkp
    extends ProxyLookup
    implements PropertyChangeListener, FileChangeListener
  {
    private String id;
    private Reference<DataObject> xml;
    private volatile FileObject folder;
    private volatile DataObject obj;
    
    public Lkp(String paramString, DataObject paramDataObject)
    {
      super();
      id = paramString;
      xml = new WeakReference(paramDataObject);
    }
    
    protected void beforeLookup(Lookup.Template paramTemplate)
    {
      if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
        FileEntityResolver.ERR.fine("beforeLookup: " + paramTemplate.getType() + " for " + getXml());
      }
      if ((folder == null) && (obj == null)) {
        update();
      }
    }
    
    private void update()
    {
      if (FileEntityResolver.ERR.isLoggable(Level.FINE)) {
        FileEntityResolver.ERR.fine("update: " + id + " for " + getXml());
      }
      File
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33

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