org-netbeans-modules-settings

16:40:15.302 INFO  jd.cli.Main - Decompiling org-netbeans-modules-settings.jar
package org.netbeans.api.settings;

import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.SOURCE)
@Target({java.lang.annotation.ElementType.TYPE})
@Documented
public @interface ConvertAsJavaBean
{
  boolean subclasses() default true;
}

/* Location:
 * Qualified Name:     org.netbeans.api.settings.ConvertAsJavaBean
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.api.settings;

import java.lang.annotation.Annotation;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.SOURCE)
@Target({java.lang.annotation.ElementType.TYPE})
public @interface ConvertAsProperties
{
  public static final String IGNORE_ALL_CHANGES = "all";
  
  String dtd();
  
  boolean autostore() default true;
  
  String[] ignoreChanges() default {};
}

/* Location:
 * Qualified Name:     org.netbeans.api.settings.ConvertAsProperties
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.api.settings;

import org.netbeans.modules.settings.Env;
import org.netbeans.modules.settings.convertors.XMLPropertiesConvertor;
import org.openide.filesystems.FileObject;

final class Factory
{
  private static Object properties(FileObject paramFileObject)
  {
    return XMLPropertiesConvertor.create(paramFileObject);
  }
  
  private static Object create(FileObject paramFileObject)
  {
    return Env.create(paramFileObject);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.api.settings.Factory
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.settings;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
import java.util.Enumeration;
import org.openide.filesystems.FileChangeListener;
import org.openide.filesystems.FileLock;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileSystem;

final class ContextProvider$FileObjectContext
  extends FileObject
{
  private static final String UNSUPPORTED = "The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.";
  private final FileObject fo;
  
  public ContextProvider$FileObjectContext(FileObject paramFileObject)
  {
    fo = paramFileObject;
  }
  
  public void addFileChangeListener(FileChangeListener paramFileChangeListener)
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public FileObject createData(String paramString1, String paramString2)
    throws IOException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public FileObject createFolder(String paramString)
    throws IOException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public void delete(FileLock paramFileLock)
    throws IOException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public Object getAttribute(String paramString)
  {
    return fo.getAttribute(paramString);
  }
  
  public Enumeration<String> getAttributes()
  {
    return fo.getAttributes();
  }
  
  public FileObject[] getChildren()
  {
    return new FileObject[0];
  }
  
  public String getExt()
  {
    return fo.getExt();
  }
  
  public FileObject getFileObject(String paramString1, String paramString2)
  {
    return null;
  }
  
  public FileSystem getFileSystem()
    throws FileStateInvalidException
  {
    return fo.getFileSystem();
  }
  
  public InputStream getInputStream()
    throws FileNotFoundException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public String getName()
  {
    return fo.getName();
  }
  
  public OutputStream getOutputStream(FileLock paramFileLock)
    throws IOException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public FileObject getParent()
  {
    return fo.getParent();
  }
  
  public long getSize()
  {
    return fo.getSize();
  }
  
  public boolean isData()
  {
    return true;
  }
  
  public boolean isFolder()
  {
    return false;
  }
  
  public boolean isReadOnly()
  {
    return fo.isReadOnly();
  }
  
  public boolean isRoot()
  {
    return false;
  }
  
  public boolean isValid()
  {
    return fo.isValid();
  }
  
  public Date lastModified()
  {
    return fo.lastModified();
  }
  
  public FileLock lock()
    throws IOException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public void removeFileChangeListener(FileChangeListener paramFileChangeListener)
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public void rename(FileLock paramFileLock, String paramString1, String paramString2)
    throws IOException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public void setAttribute(String paramString, Object paramObject)
    throws IOException
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
  
  public void setImportant(boolean paramBoolean)
  {
    throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.settings.ContextProvider.FileObjectContext
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.settings;

import java.io.IOException;
import java.io.Reader;
import org.openide.filesystems.FileObject;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Provider;
import org.openide.util.lookup.Lookups;

final class ContextProvider$ReaderProvider
  extends Reader
  implements Lookup.Provider
{
  private final Reader orig;
  private final FileObject src;
  private Lookup lookup;
  
  public ContextProvider$ReaderProvider(Reader paramReader, FileObject paramFileObject)
  {
    orig = paramReader;
    src = paramFileObject;
  }
  
  public void close()
    throws IOException
  {
    orig.close();
  }
  
  public int read(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    throws IOException
  {
    return orig.read(paramArrayOfChar, paramInt1, paramInt2);
  }
  
  public Lookup getLookup()
  {
    if (lookup == null) {
      lookup = Lookups.singleton(new ContextProvider.FileObjectContext(src));
    }
    return lookup;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.settings.ContextProvider.ReaderProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.settings;

import java.io.IOException;
import java.io.Writer;
import org.openide.filesystems.FileObject;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Provider;
import org.openide.util.lookup.Lookups;

final class ContextProvider$WriterProvider
  extends Writer
  implements Lookup.Provider
{
  private final Writer orig;
  private final FileObject src;
  private Lookup lookup;
  
  public ContextProvider$WriterProvider(Writer paramWriter, FileObject paramFileObject)
  {
    orig = paramWriter;
    src = paramFileObject;
  }
  
  public void close()
    throws IOException
  {
    orig.close();
  }
  
  public void flush()
    throws IOException
  {
    orig.flush();
  }
  
  public void write(char[] paramArrayOfChar, int paramInt1, int paramInt2)
    throws IOException
  {
    orig.write(paramArrayOfChar, paramInt1, paramInt2);
  }
  
  public Lookup getLookup()
  {
    if (lookup == null) {
      lookup = Lookups.singleton(new ContextProvider.FileObjectContext(src));
    }
    return lookup;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.settings.ContextProvider.WriterProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.settings;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.util.Date;
import java.util.Enumeration;
import org.openide.filesystems.FileChangeListener;
import org.openide.filesystems.FileLock;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileSystem;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Provider;
import org.openide.util.lookup.Lookups;

public final class ContextProvider
{
  public static Writer createWriterContextProvider(Writer paramWriter, FileObject paramFileObject)
  {
    return new WriterProvider(paramWriter, paramFileObject);
  }
  
  public static Reader createReaderContextProvider(Reader paramReader, FileObject paramFileObject)
  {
    return new ReaderProvider(paramReader, paramFileObject);
  }
  
  private static final class WriterProvider
    extends Writer
    implements Lookup.Provider
  {
    private final Writer orig;
    private final FileObject src;
    private Lookup lookup;
    
    public WriterProvider(Writer paramWriter, FileObject paramFileObject)
    {
      orig = paramWriter;
      src = paramFileObject;
    }
    
    public void close()
      throws IOException
    {
      orig.close();
    }
    
    public void flush()
      throws IOException
    {
      orig.flush();
    }
    
    public void write(char[] paramArrayOfChar, int paramInt1, int paramInt2)
      throws IOException
    {
      orig.write(paramArrayOfChar, paramInt1, paramInt2);
    }
    
    public Lookup getLookup()
    {
      if (lookup == null) {
        lookup = Lookups.singleton(new ContextProvider.FileObjectContext(src));
      }
      return lookup;
    }
  }
  
  private static final class ReaderProvider
    extends Reader
    implements Lookup.Provider
  {
    private final Reader orig;
    private final FileObject src;
    private Lookup lookup;
    
    public ReaderProvider(Reader paramReader, FileObject paramFileObject)
    {
      orig = paramReader;
      src = paramFileObject;
    }
    
    public void close()
      throws IOException
    {
      orig.close();
    }
    
    public int read(char[] paramArrayOfChar, int paramInt1, int paramInt2)
      throws IOException
    {
      return orig.read(paramArrayOfChar, paramInt1, paramInt2);
    }
    
    public Lookup getLookup()
    {
      if (lookup == null) {
        lookup = Lookups.singleton(new ContextProvider.FileObjectContext(src));
      }
      return lookup;
    }
  }
  
  private static final class FileObjectContext
    extends FileObject
  {
    private static final String UNSUPPORTED = "The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.";
    private final FileObject fo;
    
    public FileObjectContext(FileObject paramFileObject)
    {
      fo = paramFileObject;
    }
    
    public void addFileChangeListener(FileChangeListener paramFileChangeListener)
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public FileObject createData(String paramString1, String paramString2)
      throws IOException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public FileObject createFolder(String paramString)
      throws IOException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public void delete(FileLock paramFileLock)
      throws IOException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public Object getAttribute(String paramString)
    {
      return fo.getAttribute(paramString);
    }
    
    public Enumeration<String> getAttributes()
    {
      return fo.getAttributes();
    }
    
    public FileObject[] getChildren()
    {
      return new FileObject[0];
    }
    
    public String getExt()
    {
      return fo.getExt();
    }
    
    public FileObject getFileObject(String paramString1, String paramString2)
    {
      return null;
    }
    
    public FileSystem getFileSystem()
      throws FileStateInvalidException
    {
      return fo.getFileSystem();
    }
    
    public InputStream getInputStream()
      throws FileNotFoundException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public String getName()
    {
      return fo.getName();
    }
    
    public OutputStream getOutputStream(FileLock paramFileLock)
      throws IOException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public FileObject getParent()
    {
      return fo.getParent();
    }
    
    public long getSize()
    {
      return fo.getSize();
    }
    
    public boolean isData()
    {
      return true;
    }
    
    public boolean isFolder()
    {
      return false;
    }
    
    public boolean isReadOnly()
    {
      return fo.isReadOnly();
    }
    
    public boolean isRoot()
    {
      return false;
    }
    
    public boolean isValid()
    {
      return fo.isValid();
    }
    
    public Date lastModified()
    {
      return fo.lastModified();
    }
    
    public FileLock lock()
      throws IOException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public void removeFileChangeListener(FileChangeListener paramFileChangeListener)
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public void rename(FileLock paramFileLock, String paramString1, String paramString2)
      throws IOException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public void setAttribute(String paramString, Object paramObject)
      throws IOException
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
    
    public void setImportant(boolean paramBoolean)
    {
      throw new UnsupportedOperationException("The Restricted FileObject implementation allowing to get just read-only informations about name and location. It should prevent any manipulation with file or its content.");
    }
  }
}

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

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.loaders.Environment.Provider;
import org.openide.loaders.InstanceDataObject;
import org.openide.loaders.XMLDataObject;
import org.openide.util.Lookup;

public final class Env
  implements Environment.Provider
{
  public static final String EA_CONVERTOR = "settings.convertor";
  public static final String EA_PROVIDER_PATH = "settings.providerPath";
  public static final String EA_PUBLICID = "hint.originalPublicID";
  public static final String EA_INSTANCE_CLASS_NAME = "settings.instanceClass";
  public static final String EA_INSTANCE_OF = "settings.instanceOf";
  public static final String EA_INSTANCE_CREATE = "settings.instanceCreate";
  public static final String EA_SUBCLASSES = "settings.subclasses";
  private final FileObject providerFO;
  
  public static Environment.Provider create(FileObject paramFileObject)
  {
    return new Env(paramFileObject);
  }
  
  private Env(FileObject paramFileObject)
  {
    providerFO = paramFileObject;
  }
  
  public Lookup getEnvironment(DataObject paramDataObject)
  {
    boolean bool = false;
    if ((paramDataObject instanceof InstanceDataObject)) {
      bool = true;
    } else if ((paramDataObject instanceof XMLDataObject)) {
      bool = Boolean.TRUE.equals(paramDataObject.getPrimaryFile().getParent().getAttribute("recognizeXML"));
    }
    if (!bool) {
      return Lookup.EMPTY;
    }
    InstanceProvider localInstanceProvider = new InstanceProvider(paramDataObject, providerFO);
    return localInstanceProvider.getLookup();
  }
  
  public static Set<String> parseAttribute(Object paramObject)
  {
    if ((paramObject != null) && ((paramObject instanceof String)))
    {
      StringTokenizer localStringTokenizer = new StringTokenizer((String)paramObject, ",");
      
      HashSet localHashSet = new HashSet(10);
      while (localStringTokenizer.hasMoreTokens()) {
        localHashSet.add(localStringTokenizer.nextToken().trim());
      }
      return localHashSet;
    }
    return Collections.emptySet();
  }
  
  public static FileObject findProvider(Class paramClass)
    throws IOException
  {
    String str1 = "xml/memory/";
    FileObject localFileObject1 = FileUtil.getConfigFile(str1);
    if (localFileObject1 == null) {
      throw new FileNotFoundException("SFS/xml/memory/");
    }
    Class localClass = paramClass;
    while (localClass != null)
    {
      String str2 = localClass.getName().replace('.', '/');
      String str3 = 200 + str1 + str2;
      
      FileObject localFileObject2 = FileUtil.getConfigFile(str3);
      if (localFileObject2 != null)
      {
        String str4 = (String)localFileObject2.getAttribute("settings.providerPath");
        if (str4 != null)
        {
          if (localClass.equals(paramClass)) {
            return FileUtil.getConfigFile(str4);
          }
          Object localObject = localFileObject2.getAttribute("settings.subclasses");
          if ((localObject instanceof Boolean))
          {
            boolean bool = ((Boolean)localObject).booleanValue();
            if (bool) {
              return FileUtil.getConfigFile(str4);
            }
          }
        }
      }
      localClass = localClass.getSuperclass();
    }
    return null;
  }
  
  private static String xmlLookupsPrefix = "xml/lookups";
  private static String xmlEntitiesPrefix = "xml/entities";
  
  public static FileObject findEntityRegistration(FileObject paramFileObject)
  {
    String str1 = paramFileObject.getPath();
    int i = str1.lastIndexOf('.');
    if ((i != -1) && (i > str1.lastIndexOf('/'))) {
      str1 = str1.substring(0, i);
    }
    String str2 = xmlEntitiesPrefix + str1.substring(xmlLookupsPrefix.length(), str1.length());
    
    return FileUtil.getConfigFile(str2);
  }
}

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

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.ref.SoftReference;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.spi.settings.Convertor;
import org.openide.cookies.InstanceCookie.Of;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.Utilities;

final class InstanceProvider$InstanceCookieImpl
  implements InstanceCookie.Of
{
  private SoftReference<Object> cachedInstance;
  
  public InstanceProvider$InstanceCookieImpl(InstanceProvider paramInstanceProvider, Object paramObject)
  {
    setCachedInstance(paramObject);
  }
  
  public Class instanceClass()
    throws IOException, ClassNotFoundException
  {
    String str = InstanceProvider.access$000(this$0);
    if (str == null) {
      return instanceCreate().getClass();
    }
    return ((ClassLoader)Lookup.getDefault().lookup(ClassLoader.class)).loadClass(str);
  }
  
  public Object instanceCreate()
    throws IOException, ClassNotFoundException
  {
    Object localObject1;
    synchronized (this)
    {
      localObject1 = getCachedInstance();
      if (localObject1 != null) {
        return localObject1;
      }
    }
    Object localObject3;
    try
    {
      synchronized (this$0.READWRITE_LOCK)
      {
        localObject3 = ContextProvider.createReaderContextProvider(new InputStreamReader(InstanceProvider.access$100(this$0).getInputStream(), "UTF-8"), this$0.getFile());
        
        localObject1 = this$0.getConvertor().read((Reader)localObject3);
      }
    }
    catch (IOException ???)
    {
      throw ((IOException)Exceptions.attachLocalizedMessage((Throwable)???, this$0.toString()));
    }
    catch (ClassNotFoundException ???)
    {
      throw ((ClassNotFoundException)Exceptions.attachLocalizedMessage((Throwable)???, this$0.toString()));
    }
    synchronized (this)
    {
      localObject3 = getCachedInstance();
      if (localObject3 != null) {
        return localObject3;
      }
      setCachedInstance(localObject1);
    }
    InstanceProvider.access$200(this$0, localObject1);
    
    return localObject1;
  }
  
  public String instanceName()
  {
    String str = InstanceProvider.access$000(this$0);
    if (str != null) {
      return str;
    }
    Object localObject = null;
    try
    {
      return instanceClass().getName();
    }
    catch (IOException localIOException)
    {
      localObject = localIOException;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      localObject = localClassNotFoundException;
    }
    if ((localObject != null) && (!InstanceProvider.access$300(this$0)))
    {
      InstanceProvider.access$302(this$0, true);
      Exceptions.attachLocalizedMessage((Throwable)localObject, InstanceProvider.access$400(this$0).toString());
      Logger.getLogger(InstanceProvider.class.getName()).log(Level.WARNING, null, (Throwable)localObject);
    }
    return "Unknown";
  }
  
  public boolean instanceOf(Class<?> paramClass)
  {
    synchronized (this$0)
    {
      if (InstanceProvider.access$500(this$0) == null)
      {
        InstanceProvider.access$502(this$0, Env.parseAttribute(InstanceProvider.access$600(this$0).getAttribute("settings.instanceOf")));
        Iterator localIterator = InstanceProvider.access$500(this$0).iterator();
        InstanceProvider.access$502(this$0, new HashSet(InstanceProvider.access$500(this$0).size() * 5 / 4));
        while (localIterator.hasNext()) {
          InstanceProvider.access$500(this$0).add(Utilities.translate((String)localIterator.next()));
        }
      }
    }
    if (InstanceProvider.access$500(this$0).isEmpty())
    {
      ??? = null;
      try
      {
        return paramClass.isAssignableFrom(instanceClass());
      }
      catch (IOException localIOException)
      {
        ??? = localIOException;
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        ??? = localClassNotFoundException;
      }
      if ((??? != null) && (!InstanceProvider.access$300(this$0)))
      {
        InstanceProvider.access$302(this$0, true);
        Exceptions.attachLocalizedMessage((Throwable)???, InstanceProvider.access$400(this$0).toString());
        Logger.getLogger(InstanceProvider.class.getName()).log(Level.WARNING, null, (Throwable)???);
      }
      return false;
    }
    return InstanceProvider.access$500(this$0).contains(paramClass.getName());
  }
  
  public void setInstance(Object paramObject, boolean paramBoolean)
    throws IOException
  {
    InstanceProvider.access$700(this$0, paramObject);
    if (paramObject != null)
    {
      InstanceProvider.access$200(this$0, paramObject);
      if (paramBoolean) {
        this$0.getScheduledRequest().runAndWait();
      }
    }
  }
  
  private Object getCachedInstance()
  {
    return cachedInstance.get();
  }
  
  private void setCachedInstance(Object paramObject)
  {
    cachedInstance = new SoftReference(paramObject);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.settings.InstanceProvider.InstanceCookieImpl
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.settings;

import org.netbeans.modules.settings.convertors.SerialDataNode;
import org.openide.nodes.Node;
import org.openide.util.lookup.InstanceContent.Convertor;

final class InstanceProvider$NodeConvertor
  implements InstanceContent.Convertor<InstanceProvider, Node>
{
  public Node convert(InstanceProvider paramInstanceProvider)
  {
    return new SerialDataNode(paramInstanceProvider.getDataObject());
  }
  
  public Class<Node> type(InstanceProvider paramInstanceProvider)
  {
    return Node.class;
  }
  
  public String id(InstanceProvider paramInstanceProvider)
  {
    return paramInstanceProvider.toString();
  }
  
  public String displayName(InstanceProvider paramInstanceProvider)
  {
    return paramInstanceProvider.toString();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.settings.InstanceProvider.NodeConvertor
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.settings;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.lang.ref.SoftReference;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.modules.settings.convertors.SerialDataNode;
import org.netbeans.spi.settings.Convertor;
import org.openide.cookies.InstanceCookie;
import org.openide.cookies.InstanceCookie.Of;
import org.openide.cookies.SaveCookie;
import org.openide.filesystems.FileChangeAdapter;
import org.openide.filesystems.FileEvent;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileSystem.AtomicAction;
import org.openide.filesystems.FileUtil;
import org.openide.loaders.DataObject;
import org.openide.nodes.Node;
import org.openide.util.Exceptions;
import org.openide.util.Lookup;
import org.openide.util.Utilities;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
import org.openide.util.lookup.InstanceContent.Convertor;

final class InstanceProvider
  extends FileChangeAdapter
  implements PropertyChangeListener, FileSystem.AtomicAction
{
  private static final Logger LOG = Logger.getLogger(InstanceProvider.class.getName());
  private final InstanceContent lkpContent;
  private final Lookup lookup;
  private final DataObject dobj;
  private final FileObject settingFO;
  private final FileObject providerFO;
  private final NodeConvertor node;
  private SaveSupport saver;
  private SaveCookie scCache;
  private boolean wasReportedProblem = false;
  private Set<String> instanceOfSet;
  private String instanceClassName;
  final Object READWRITE_LOCK = new Object();
  private Convertor convertor;
  private ScheduledRequest request;
  
  public InstanceProvider(DataObject paramDataObject, FileObject paramFileObject)
  {
    settingFO = paramDataObject.getPrimaryFile();
    providerFO = paramFileObject;
    dobj = paramDataObject;
    
    settingFO.addFileChangeListener(FileUtil.weakFileChangeListener(this, settingFO));
    
    lkpContent = new InstanceContent();
    lkpContent.add(createInstance(null));
    node = new NodeConvertor();
    lkpContent.add(this, node);
    lookup = new AbstractLookup(lkpContent);
  }
  
  public Lookup getLookup()
  {
    return lookup;
  }
  
  FileObject getProvider()
  {
    return providerFO;
  }
  
  FileObject getFile()
  {
    return settingFO;
  }
  
  DataObject getDataObject()
  {
    return dobj;
  }
  
  public void propertyChange(PropertyChangeEvent paramPropertyChangeEvent)
  {
    if (paramPropertyChangeEvent == null) {
      return;
    }
    String str = paramPropertyChangeEvent.getPropertyName();
    if (str == null) {
      return;
    }
    if (str == "savecookie")
    {
      provideSaveCookie();
    }
    else if (str == "fileChanged")
    {
      synchronized (this)
      {
        instanceOfSet = null;
      }
      instanceCookieChanged(null);
    }
  }
  
  public void fileChanged(FileEvent paramFileEvent)
  {
    if ((saver != null) && (paramFileEvent.firedFrom((FileSystem.AtomicAction)saver.getSaveCookie()))) {
      return;
    }
    propertyChange(new PropertyChangeEvent(this, "fileChanged", null, null));
  }
  
  public void fileDeleted(FileEvent paramFileEvent)
  {
    if ((saver != null) && (paramFileEvent.firedFrom((FileSystem.AtomicAction)saver.getSaveCookie()))) {
      return;
    }
    releaseInstance();
  }
  
  private synchronized void attachToInstance(Object paramObject)
  {
    if (saver != null)
    {
      saver.removePropertyChangeListener(this);
      getScheduledRequest().forceToFinish();
    }
    saver = createSaveSupport(paramObject);
    saver.addPropertyChangeListener(this);
  }
  
  private InstanceCookie.Of createInstance(Object paramObject)
  {
    return new InstanceCookieImpl(paramObject);
  }
  
  private SaveSupport createSaveSupport(Object paramObject)
  {
    return new SaveSupport(this, paramObject);
  }
  
  private void provideSaveCookie()
  {
    SaveCookie localSaveCookie = saver.getSaveCookie();
    if (scCache != null)
    {
      if (!saver.isChanged())
      {
        if (LOG.isLoggable(Level.FINE)) {
          LOG.fine("remove save cookie: " + dobj);
        }
        lkpContent.remove(scCache);
        scCache = null;
      }
    }
    else if (saver.isChanged())
    {
      scCache = localSaveCookie;
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("add save cookie: " + dobj + " cookie: " + localSaveCookie);
      }
      lkpContent.add(localSaveCookie);
      return;
    }
  }
  
  private void releaseInstance()
  {
    SaveSupport localSaveSupport = saver;
    if (localSaveSupport != null) {
      localSaveSupport.removePropertyChangeListener(this);
    }
    if (scCache != null)
    {
      if (LOG.isLoggable(Level.FINE)) {
        LOG.fine("release instance and remove save cookie: " + dobj);
      }
      lkpContent.remove(scCache);
      getScheduledRequest().cancel();
      scCache = null;
    }
    lkpContent.remove(this, node);
  }
  
  private void instanceCookieChanged(Object paramObject)
  {
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("instanceCookieChanged: " + dobj + " inst: " + paramObject);
    }
    releaseInstance();
    
    lkpContent.add(this, node);
    
    Object localObject = lookup.lookup(InstanceCookie.class);
    lkpContent.remove(localObject);
    
    InstanceCookie.Of localOf = createInstance(paramObject);
    lkpContent.add(localOf);
    if (LOG.isLoggable(Level.FINE)) {
      LOG.fine("cookie replaced: " + dobj + " old: " + localObject + " new: " + localOf);
    }
  }
  
  Convertor getConvertor()
    throws IOException
  {
    if (convertor == null)
    {
      Object localObject = providerFO.getAttribute("settings.convertor");
      if ((localObject == null) || (!(localObject instanceof Convertor))) {
        throw new IOException("cannot create convertor: " + localObject + ", provider:" + providerFO);
      }
      convertor = ((Convertor)localObject);
    }
    return convertor;
  }
  
  private synchronized String getInstanceClassName()
  {
    if (instanceClassName == null)
    {
      Object localObject = providerFO.getAttribute("settings.instanceClass");
      if ((localObject != null) && ((localObject instanceof String))) {
        instanceClassName = Utilities.translate((String)localObject);
      } else {
        instanceClassName = null;
      }
    }
    return instanceClassName;
  }
  
  public String toString()
  {
    return getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)) + '[' + getDataObject() + ", " + getProvider() + ']';
  }
  
  public void run()
    throws IOException
  {
    saver.writeDown();
  }
  
  synchronized ScheduledRequest getScheduledRequest()
  {
    if (request == null) {
      request = new ScheduledRequest(settingFO, this);
    }
    return request;
  }
  
  final class InstanceCookieImpl
    implements InstanceCookie.Of
  {
    private SoftReference<Object> cachedInstance;
    
    public InstanceCookieImpl(Object paramObject)
    {
      setCachedInstance(paramObject);
    }
    
    public Class instanceClass()
      throws IOException, ClassNotFoundException
    {
      String str = InstanceProvider.this.getInstanceClassName();
      if (str == null) {
        return instanceCreate().getClass();
      }
      return ((ClassLoader)Lookup.getDefault().lookup(ClassLoader.class)).loadClass(str);
    }
    
    public Object instanceCreate()
      throws IOException, ClassNotFoundException
    {
      Object localObject1;
      synchronized (this)
      {
        localObject1 = getCachedInstance();
        if (localObject1 != null) {
          return localObject1;
        }
      }
      Object localObject3;
      try
      {
        synchronized (READWRITE_LOCK)
        {
          localObject3 = ContextProvider.createReaderContextProvider(new InputStreamReader(settingFO.getInputStream(), "UTF-8"), getFile());
          
          localObject1 = getConvertor().read((Reader)localObject3);
        }
      }
      catch (IOException ???)
      {
        throw ((IOException)Exceptions.attachLocalizedMessage((Throwable)???, toString()));
      }
      catch (ClassNotFoundException ???)
      {
        throw ((ClassNotFoundException)Exceptions.attachLocalizedMessage((Throwable)???, toString()));
      }
      synchronized (this)
      {
        localObject3 = getCachedInstance();
        if (localObject3 != null) {
          return localObject3;
        }
        setCachedInstance(localObject1);
      }
      InstanceProvider.this.attachToInstance(localObject1);
      
      return localObject1;
    }
    
    public String instanceName()
    {
      String str = InstanceProvider.this.getInstanceClassName();
      if (str != null) {
        return str;
      }
      Object localObject = null;
      try
      {
        return instanceClass().getName();
      }
      catch (IOException localIOException)
      {
        localObject = localIOException;
      }
      catch (ClassNotFoundException localClassNotFoundException)
      {
        localObject = localClassNotFoundException;
      }
      if ((localObject != null) && (!wasReportedProblem))
      {
        wasReportedProblem = true;
        Exceptions.attachLocalizedMessage((Throwable)localObject, dobj.toString());
        Logger.getLogger(InstanceProvider.class.getName()).log(Level.WARNING, null, (Throwable)localObject);
      }
      return "Unknown";
    }
    
    public boolean instanceOf(Class<?> paramClass)
    {
      synchronized (InstanceProvider.this)
      {
        if (instanceOfSet == null)
        {
          instanceOfSet = Env.parseAttribute(providerFO.getAttribute("settings.instanceOf"));
          Iterator localIterator = instanceOfSet.iterator();
          instanceOfSet = new HashSet(instanceOfSet.size() * 5 / 4);
          while (localIterator.hasNext()) {
            instanceOfSet.add(Utilities.translate((String)localIterator.next()));
          }
        }
      }
      if (instanceOfSet.isEmpty())
      {
        ??? = null;
        try
        {
          return paramClass.isAssignableFrom(instanceClass());
        }
        catch (IOException localIOException)
        {
          ??? = localIOException;
        }
        catch (ClassNotFoundException localClassNotFoundException)
        {
          ??? = localClassNotFoundException;
        }
        if ((??? != null) && (!wasReportedProblem))
        {
          wasReportedProblem = true;
          Exceptions.attachLocalizedMessage((Throwable)???, dobj.toString());
          Logger.getLogger(InstanceProvider.class.getName()).log(Level.WARNING, null, (Throwable)???);
        }
        return false;
      }
      return instanceOfSet.contains(paramClass.getName());
    }
    
    public void setInstance(Object paramObject, boolean paramBoolean)
      throws IOException
    {
      InstanceProvider.this.instanceCookieChanged(paramObject);
      if (paramObject != null)
      {
        InstanceProvider.this.attachToInstance(paramObject);
        if (paramBoolean) {
          getScheduledRequest().runAndWait();
        }
      }
    }
    
    private Object getCachedInstance()
    {
      return cachedInstance.get();
    }
    
    private void setCachedInstance(Object paramObject)
    {
      cachedInstance = new SoftReference(paramObject);
    }
  }
  
  private static final class NodeConvertor
    implements InstanceContent.Convertor<InstanceProvider, Node>
  {
    public Node convert(
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