org-netbeans-modules-queries

16:40:13.212 INFO  jd.cli.Main - Decompiling org-netbeans-modules-queries.jar
package org.netbeans.api.fileinfo;

import org.openide.filesystems.FileObject;

public abstract interface NonRecursiveFolder
{
  public abstract FileObject getFolder();
}

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

import java.io.File;
import org.netbeans.spi.queries.CollocationQueryImplementation;
import org.openide.filesystems.FileUtil;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Result;

public final class CollocationQuery
{
  private static final Lookup.Result<CollocationQueryImplementation> implementations = Lookup.getDefault().lookupResult(CollocationQueryImplementation.class);
  
  public static boolean areCollocated(File paramFile1, File paramFile2)
  {
    if (!paramFile1.equals(FileUtil.normalizeFile(paramFile1))) {
      throw new IllegalArgumentException("Parameter file1 was not normalized. Was " + paramFile1 + " instead of " + FileUtil.normalizeFile(paramFile1));
    }
    if (!paramFile2.equals(FileUtil.normalizeFile(paramFile2))) {
      throw new IllegalArgumentException("Parameter file2 was not normalized. Was " + paramFile2 + " instead of " + FileUtil.normalizeFile(paramFile2));
    }
    for (CollocationQueryImplementation localCollocationQueryImplementation : implementations.allInstances()) {
      if (localCollocationQueryImplementation.areCollocated(paramFile1, paramFile2)) {
        return true;
      }
    }
    return false;
  }
  
  public static File findRoot(File paramFile)
  {
    if (!paramFile.equals(FileUtil.normalizeFile(paramFile))) {
      throw new IllegalArgumentException("Parameter file was not normalized. Was " + paramFile + " instead of " + FileUtil.normalizeFile(paramFile));
    }
    for (CollocationQueryImplementation localCollocationQueryImplementation : implementations.allInstances())
    {
      File localFile = localCollocationQueryImplementation.findRoot(paramFile);
      if (localFile != null) {
        return localFile;
      }
    }
    return null;
  }
}

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

import javax.swing.event.ChangeListener;

public abstract interface FileBuiltQuery$Status
{
  public abstract boolean isBuilt();
  
  public abstract void addChangeListener(ChangeListener paramChangeListener);
  
  public abstract void removeChangeListener(ChangeListener paramChangeListener);
}

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

import javax.swing.event.ChangeListener;
import org.netbeans.spi.queries.FileBuiltQueryImplementation;
import org.openide.filesystems.FileObject;
import org.openide.util.Lookup;
import org.openide.util.Lookup.Result;

public final class FileBuiltQuery
{
  private static final Lookup.Result<FileBuiltQueryImplementation> implementations = Lookup.getDefault().lookupResult(FileBuiltQueryImplementation.class);
  
  public static Status getStatus(FileObject paramFileObject)
  {
    if (!paramFileObject.isValid()) {
      return null;
    }
    for (FileBuiltQueryImplementation localFileBuiltQueryImplementation : implementations.allInstances())
    {
      Status localStatus = localFileBuiltQueryImplementation.getStatus(paramFileObject);
      if (localStatus != null) {
        return localStatus;
      }
    }
    return null;
  }
  
  public static abstract interface Status
  {
    public abstract boolean isBuilt();
    
    public abstract void addChangeListener(ChangeListener paramChangeListener);
    
    public abstract void removeChangeListener(ChangeListener paramChangeListener);
  }
}

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

class FileEncodingQuery$1 {}

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

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.modules.queries.UnknownEncoding;

class FileEncodingQuery$ProxyCharset$ProxyDecoder
  extends CharsetDecoder
{
  private CharsetDecoder currentDecoder;
  private ByteBuffer buffer = ByteBuffer.allocate(4096);
  private ByteBuffer remainder;
  private CodingErrorAction malformedInputAction;
  private CodingErrorAction unmappableCharAction;
  private String replace;
  private boolean initialized;
  private CharBuffer lastCharBuffer;
  
  private FileEncodingQuery$ProxyCharset$ProxyDecoder(FileEncodingQuery.ProxyCharset paramProxyCharset, CharsetDecoder paramCharsetDecoder)
  {
    super(paramProxyCharset, paramCharsetDecoder.averageCharsPerByte(), paramCharsetDecoder.maxCharsPerByte());
    currentDecoder = paramCharsetDecoder;
    initialized = true;
  }
  
  protected CoderResult decodeLoop(ByteBuffer paramByteBuffer, CharBuffer paramCharBuffer)
  {
    lastCharBuffer = paramCharBuffer;
    if (buffer == null)
    {
      if (remainder != null)
      {
        ByteBuffer localByteBuffer = ByteBuffer.allocate(remainder.remaining() + paramByteBuffer.remaining());
        localByteBuffer.put(remainder);
        localByteBuffer.put(paramByteBuffer);
        localByteBuffer.flip();
        CoderResult localCoderResult = currentDecoder.decode(localByteBuffer, paramCharBuffer, false);
        if (localByteBuffer.hasRemaining()) {
          remainder = localByteBuffer;
        } else {
          remainder = null;
        }
        return localCoderResult;
      }
      return currentDecoder.decode(paramByteBuffer, paramCharBuffer, false);
    }
    if (buffer.remaining() == 0) {
      return decodeHead(paramByteBuffer, paramCharBuffer, false);
    }
    if (buffer.remaining() < paramByteBuffer.remaining())
    {
      int i = paramByteBuffer.limit();
      paramByteBuffer.limit(paramByteBuffer.position() + buffer.remaining());
      buffer.put(paramByteBuffer);
      paramByteBuffer.limit(i);
      return decodeHead(paramByteBuffer, paramCharBuffer, false);
    }
    buffer.put(paramByteBuffer);
    return CoderResult.UNDERFLOW;
  }
  
  private CoderResult decodeHead(ByteBuffer paramByteBuffer, CharBuffer paramCharBuffer, boolean paramBoolean)
  {
    buffer.flip();
    CoderResult localCoderResult = null;
    for (int i = 0; i < FileEncodingQuery.ProxyCharset.access$300(this$0).size(); i++)
    {
      currentDecoder = ((Charset)FileEncodingQuery.ProxyCharset.access$300(this$0).get(i)).newDecoder();
      if (malformedInputAction != null) {
        currentDecoder.onMalformedInput(malformedInputAction);
      }
      if (unmappableCharAction != null) {
        currentDecoder.onUnmappableCharacter(unmappableCharAction);
      }
      if (replace != null) {
        currentDecoder.replaceWith(replace);
      }
      int j = paramCharBuffer.position();
      try
      {
        ByteBuffer localByteBuffer = buffer.asReadOnlyBuffer();
        localCoderResult = currentDecoder.decode(localByteBuffer, paramCharBuffer, paramByteBuffer == null);
        if (localByteBuffer.hasRemaining())
        {
          if (paramBoolean) {
            currentDecoder.flush(paramCharBuffer);
          }
          FileEncodingQuery.access$400().log(Level.FINEST, "decoder-selected", currentDecoder);
          remainder = localByteBuffer;
          buffer = null;
          return localCoderResult;
        }
        if (paramByteBuffer != null) {
          localCoderResult = currentDecoder.decode(paramByteBuffer, paramCharBuffer, false);
        }
        if (paramBoolean) {
          localCoderResult = currentDecoder.flush(paramCharBuffer);
        }
        FileEncodingQuery.access$400().log(Level.FINEST, "decoder-selected", currentDecoder);
        buffer = null;
        return localCoderResult;
      }
      catch (UnknownEncoding localUnknownEncoding)
      {
        if (j != paramCharBuffer.position())
        {
          buffer = null;
          return localCoderResult;
        }
      }
    }
    buffer = null;
    assert (localCoderResult != null);
    return localCoderResult;
  }
  
  protected CoderResult implFlush(CharBuffer paramCharBuffer)
  {
    lastCharBuffer = null;
    if (buffer != null) {
      return decodeHead(null, paramCharBuffer, true);
    }
    currentDecoder.decode(FileEncodingQuery.ProxyCharset.access$500(), paramCharBuffer, true);
    return currentDecoder.flush(paramCharBuffer);
  }
  
  protected void implReset()
  {
    if (lastCharBuffer != null) {
      implFlush(lastCharBuffer);
    }
    currentDecoder.reset();
  }
  
  protected void implOnMalformedInput(CodingErrorAction paramCodingErrorAction)
  {
    if ((buffer != null) || (!initialized)) {
      malformedInputAction = paramCodingErrorAction;
    } else {
      currentDecoder.onMalformedInput(paramCodingErrorAction);
    }
  }
  
  protected void implOnUnmappableCharacter(CodingErrorAction paramCodingErrorAction)
  {
    if ((buffer != null) || (!initialized)) {
      unmappableCharAction = paramCodingErrorAction;
    } else {
      currentDecoder.onUnmappableCharacter(paramCodingErrorAction);
    }
  }
  
  protected void implReplaceWith(String paramString)
  {
    if ((buffer != null) || (!initialized)) {
      replace = paramString;
    } else {
      currentDecoder.replaceWith(paramString);
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.api.queries.FileEncodingQuery.ProxyCharset.ProxyDecoder
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.api.queries;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.modules.queries.UnknownEncoding;

class FileEncodingQuery$ProxyCharset$ProxyEncoder
  extends CharsetEncoder
{
  private CharsetEncoder currentEncoder;
  private CharBuffer buffer = CharBuffer.allocate(4096);
  private CharBuffer remainder;
  private CodingErrorAction malformedInputAction;
  private CodingErrorAction unmappableCharAction;
  private byte[] replace;
  private boolean initialized;
  private ByteBuffer lastByteBuffer;
  
  private FileEncodingQuery$ProxyCharset$ProxyEncoder(FileEncodingQuery.ProxyCharset paramProxyCharset, CharsetEncoder paramCharsetEncoder)
  {
    super(paramProxyCharset, paramCharsetEncoder.averageBytesPerChar(), paramCharsetEncoder.maxBytesPerChar(), paramCharsetEncoder.replacement());
    currentEncoder = paramCharsetEncoder;
    initialized = true;
  }
  
  protected CoderResult encodeLoop(CharBuffer paramCharBuffer, ByteBuffer paramByteBuffer)
  {
    lastByteBuffer = paramByteBuffer;
    CoderResult localCoderResult1;
    if (buffer == null)
    {
      if (remainder != null)
      {
        localCoderResult1 = currentEncoder.encode(remainder, paramByteBuffer, false);
        if (!remainder.hasRemaining()) {
          remainder = null;
        }
      }
      localCoderResult1 = currentEncoder.encode(paramCharBuffer, paramByteBuffer, false);
      return localCoderResult1;
    }
    if ((buffer.remaining() == 0) || ((buffer.position() > 0) && (paramCharBuffer.limit() == 0)))
    {
      localCoderResult1 = encodeHead(paramCharBuffer, paramByteBuffer, false);
      return localCoderResult1;
    }
    if (buffer.remaining() < paramCharBuffer.remaining())
    {
      int i = paramCharBuffer.limit();
      paramCharBuffer.limit(paramCharBuffer.position() + buffer.remaining());
      buffer.put(paramCharBuffer);
      paramCharBuffer.limit(i);
      CoderResult localCoderResult2 = encodeHead(paramCharBuffer, paramByteBuffer, false);
      return localCoderResult2;
    }
    buffer.put(paramCharBuffer);
    return CoderResult.UNDERFLOW;
  }
  
  private CoderResult encodeHead(CharBuffer paramCharBuffer, ByteBuffer paramByteBuffer, boolean paramBoolean)
  {
    buffer.flip();
    CoderResult localCoderResult = null;
    for (int i = 0; i < FileEncodingQuery.ProxyCharset.access$300(this$0).size(); i++)
    {
      currentEncoder = ((Charset)FileEncodingQuery.ProxyCharset.access$300(this$0).get(i)).newEncoder();
      if (malformedInputAction != null) {
        currentEncoder.onMalformedInput(malformedInputAction);
      }
      if (unmappableCharAction != null) {
        currentEncoder.onUnmappableCharacter(unmappableCharAction);
      }
      if (replace != null) {
        currentEncoder.replaceWith(replace);
      }
      int j = paramByteBuffer.position();
      try
      {
        CharBuffer localCharBuffer = buffer.asReadOnlyBuffer();
        localCoderResult = currentEncoder.encode(localCharBuffer, paramByteBuffer, paramCharBuffer == null);
        if (localCoderResult.isOverflow())
        {
          if (paramBoolean) {
            currentEncoder.flush(paramByteBuffer);
          }
          FileEncodingQuery.access$400().log(Level.FINEST, "encoder-selected", currentEncoder);
          remainder = localCharBuffer;
          buffer = null;
          return localCoderResult;
        }
        if (paramCharBuffer != null) {
          localCoderResult = currentEncoder.encode(paramCharBuffer, paramByteBuffer, false);
        }
        if (paramBoolean) {
          localCoderResult = currentEncoder.flush(paramByteBuffer);
        }
        FileEncodingQuery.access$400().log(Level.FINEST, "encoder-selected", currentEncoder);
        buffer = null;
        return localCoderResult;
      }
      catch (UnknownEncoding localUnknownEncoding)
      {
        if (j != paramByteBuffer.position())
        {
          buffer = null;
          return localCoderResult;
        }
      }
    }
    buffer = null;
    assert (localCoderResult != null);
    return localCoderResult;
  }
  
  protected CoderResult implFlush(ByteBuffer paramByteBuffer)
  {
    lastByteBuffer = null;
    if (buffer != null) {
      return encodeHead(null, paramByteBuffer, true);
    }
    currentEncoder.encode(FileEncodingQuery.ProxyCharset.access$600(), paramByteBuffer, true);
    return currentEncoder.flush(paramByteBuffer);
  }
  
  protected void implReset()
  {
    if (lastByteBuffer != null) {
      implFlush(lastByteBuffer);
    }
    currentEncoder.reset();
  }
  
  protected void implOnMalformedInput(CodingErrorAction paramCodingErrorAction)
  {
    if ((buffer != null) || (!initialized)) {
      malformedInputAction = paramCodingErrorAction;
    } else {
      currentEncoder.onMalformedInput(paramCodingErrorAction);
    }
  }
  
  protected void implOnUnmappableCharacter(CodingErrorAction paramCodingErrorAction)
  {
    if ((buffer != null) || (!initialized)) {
      unmappableCharAction = paramCodingErrorAction;
    } else {
      currentEncoder.onUnmappableCharacter(paramCodingErrorAction);
    }
  }
  
  protected void implReplaceWith(byte[] paramArrayOfByte)
  {
    if ((buffer != null) || (!initialized)) {
      replace = paramArrayOfByte;
    } else {
      currentEncoder.replaceWith(paramArrayOfByte);
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.api.queries.FileEncodingQuery.ProxyCharset.ProxyEncoder
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.api.queries;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.modules.queries.UnknownEncoding;

class FileEncodingQuery$ProxyCharset
  extends Charset
{
  private static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.allocate(0);
  private static final CharBuffer EMPTY_CHAR_BUFFER = CharBuffer.allocate(0);
  private final List<? extends Charset> delegates;
  
  private FileEncodingQuery$ProxyCharset(List<? extends Charset> paramList)
  {
    super(((Charset)paramList.get(0)).name(), (String[])((Charset)paramList.get(0)).aliases().toArray(new String[((Charset)paramList.get(0)).aliases().size()]));
    delegates = paramList;
  }
  
  public boolean contains(Charset paramCharset)
  {
    return ((Charset)delegates.get(0)).contains(paramCharset);
  }
  
  public CharsetDecoder newDecoder()
  {
    return new ProxyDecoder(((Charset)delegates.get(0)).newDecoder(), null);
  }
  
  public CharsetEncoder newEncoder()
  {
    return new ProxyEncoder(((Charset)delegates.get(0)).newEncoder(), null);
  }
  
  private class ProxyDecoder
    extends CharsetDecoder
  {
    private CharsetDecoder currentDecoder;
    private ByteBuffer buffer = ByteBuffer.allocate(4096);
    private ByteBuffer remainder;
    private CodingErrorAction malformedInputAction;
    private CodingErrorAction unmappableCharAction;
    private String replace;
    private boolean initialized;
    private CharBuffer lastCharBuffer;
    
    private ProxyDecoder(CharsetDecoder paramCharsetDecoder)
    {
      super(paramCharsetDecoder.averageCharsPerByte(), paramCharsetDecoder.maxCharsPerByte());
      currentDecoder = paramCharsetDecoder;
      initialized = true;
    }
    
    protected CoderResult decodeLoop(ByteBuffer paramByteBuffer, CharBuffer paramCharBuffer)
    {
      lastCharBuffer = paramCharBuffer;
      if (buffer == null)
      {
        if (remainder != null)
        {
          ByteBuffer localByteBuffer = ByteBuffer.allocate(remainder.remaining() + paramByteBuffer.remaining());
          localByteBuffer.put(remainder);
          localByteBuffer.put(paramByteBuffer);
          localByteBuffer.flip();
          CoderResult localCoderResult = currentDecoder.decode(localByteBuffer, paramCharBuffer, false);
          if (localByteBuffer.hasRemaining()) {
            remainder = localByteBuffer;
          } else {
            remainder = null;
          }
          return localCoderResult;
        }
        return currentDecoder.decode(paramByteBuffer, paramCharBuffer, false);
      }
      if (buffer.remaining() == 0) {
        return decodeHead(paramByteBuffer, paramCharBuffer, false);
      }
      if (buffer.remaining() < paramByteBuffer.remaining())
      {
        int i = paramByteBuffer.limit();
        paramByteBuffer.limit(paramByteBuffer.position() + buffer.remaining());
        buffer.put(paramByteBuffer);
        paramByteBuffer.limit(i);
        return decodeHead(paramByteBuffer, paramCharBuffer, false);
      }
      buffer.put(paramByteBuffer);
      return CoderResult.UNDERFLOW;
    }
    
    private CoderResult decodeHead(ByteBuffer paramByteBuffer, CharBuffer paramCharBuffer, boolean paramBoolean)
    {
      buffer.flip();
      CoderResult localCoderResult = null;
      for (int i = 0; i < delegates.size(); i++)
      {
        currentDecoder = ((Charset)delegates.get(i)).newDecoder();
        if (malformedInputAction != null) {
          currentDecoder.onMalformedInput(malformedInputAction);
        }
        if (unmappableCharAction != null) {
          currentDecoder.onUnmappableCharacter(unmappableCharAction);
        }
        if (replace != null) {
          currentDecoder.replaceWith(replace);
        }
        int j = paramCharBuffer.position();
        try
        {
          ByteBuffer localByteBuffer = buffer.asReadOnlyBuffer();
          localCoderResult = currentDecoder.decode(localByteBuffer, paramCharBuffer, paramByteBuffer == null);
          if (localByteBuffer.hasRemaining())
          {
            if (paramBoolean) {
              currentDecoder.flush(paramCharBuffer);
            }
            FileEncodingQuery.access$400().log(Level.FINEST, "decoder-selected", currentDecoder);
            remainder = localByteBuffer;
            buffer = null;
            return localCoderResult;
          }
          if (paramByteBuffer != null) {
            localCoderResult = currentDecoder.decode(paramByteBuffer, paramCharBuffer, false);
          }
          if (paramBoolean) {
            localCoderResult = currentDecoder.flush(paramCharBuffer);
          }
          FileEncodingQuery.access$400().log(Level.FINEST, "decoder-selected", currentDecoder);
          buffer = null;
          return localCoderResult;
        }
        catch (UnknownEncoding localUnknownEncoding)
        {
          if (j != paramCharBuffer.position())
          {
            buffer = null;
            return localCoderResult;
          }
        }
      }
      buffer = null;
      assert (localCoderResult != null);
      return localCoderResult;
    }
    
    protected CoderResult implFlush(CharBuffer paramCharBuffer)
    {
      lastCharBuffer = null;
      if (buffer != null) {
        return decodeHead(null, paramCharBuffer, true);
      }
      currentDecoder.decode(FileEncodingQuery.ProxyCharset.EMPTY_BYTE_BUFFER, paramCharBuffer, true);
      return currentDecoder.flush(paramCharBuffer);
    }
    
    protected void implReset()
    {
      if (lastCharBuffer != null) {
        implFlush(lastCharBuffer);
      }
      currentDecoder.reset();
    }
    
    protected void implOnMalformedInput(CodingErrorAction paramCodingErrorAction)
    {
      if ((buffer != null) || (!initialized)) {
        malformedInputAction = paramCodingErrorAction;
      } else {
        currentDecoder.onMalformedInput(paramCodingErrorAction);
      }
    }
    
    protected void implOnUnmappableCharacter(CodingErrorAction paramCodingErrorAction)
    {
      if ((buffer != null) || (!initialized)) {
        unmappableCharAction = paramCodingErrorAction;
      } else {
        currentDecoder.onUnmappableCharacter(paramCodingErrorAction);
      }
    }
    
    protected void implReplaceWith(String paramString)
    {
      if ((buffer != null) || (!initialized)) {
        replace = paramString;
      } else {
        currentDecoder.replaceWith(paramString);
      }
    }
  }
  
  private class ProxyEncoder
    extends CharsetEncoder
  {
    private CharsetEncoder currentEncoder;
    private CharBuffer buffer = CharBuffer.allocate(4096);
    private CharBuffer remainder;
    private CodingErrorAction malformedInputAction;
    private CodingErrorAction unmappableCharAction;
    private byte[] replace;
    private boolean initialized;
    private ByteBuffer lastByteBuffer;
    
    private ProxyEncoder(CharsetEncoder paramCharsetEncoder)
    {
      super(paramCharsetEncoder.averageBytesPerChar(), paramCharsetEncoder.maxBytesPerChar(), paramCharsetEncoder.replacement());
      currentEncoder = paramCharsetEncoder;
      initialized = true;
    }
    
    protected CoderResult encodeLoop(CharBuffer paramCharBuffer, ByteBuffer paramByteBuffer)
    {
      lastByteBuffer = paramByteBuffer;
      CoderResult localCoderResult1;
      if (buffer == null)
      {
        if (remainder != null)
        {
          localCoderResult1 = currentEncoder.encode(remainder, paramByteBuffer, false);
          if (!remainder.hasRemaining()) {
            remainder = null;
          }
        }
        localCoderResult1 = currentEncoder.encode(paramCharBuffer, paramByteBuffer, false);
        return localCoderResult1;
      }
      if ((buffer.remaining() == 0) || ((buffer.position() > 0) && (paramCharBuffer.limit() == 0)))
      {
        localCoderResult1 = encodeHead(paramCharBuffer, paramByteBuffer, false);
        return localCoderResult1;
      }
      if (buffer.remaining() < paramCharBuffer.remaining())
      {
        int i = paramCharBuffer.limit();
        paramCharBuffer.limit(paramCharBuffer.position() + buffer.remaining());
        buffer.put(paramCharBuffer);
        paramCharBuffer.limit(i);
        CoderResult localCoderResult2 = encodeHead(paramCharBuffer, paramByteBuffer, false);
        return localCoderResult2;
      }
      buffer.put(paramCharBuffer);
      return CoderResult.UNDERFLOW;
    }
    
    private CoderResult encodeHead(CharBuffer paramCharBuffer, ByteBuffer paramByteBuffer, boolean paramBoolean)
    {
      buffer.flip();
      CoderResult localCoderResult = null;
      for (int i = 0; i < delegates.size(); i++)
      {
        currentEncoder = ((Charset)delegates.get(i)).newEncoder();
        if (malformedInputAction != null) {
          currentEncoder.onMalformedInput(malformedInputAction);
        }
        if (unmappableCharAction != null) {
          currentEncoder.onUnmappableCharacter(unmappableCharAction);
        }
        if (replace != null) {
          currentEncoder.replaceWith(replace);
        }
        int j = paramByteBuffer.position();
        try
        {
          CharBuffer localCharBuffer = buffer.asReadOnlyBuffer();
          localCoderResult = currentEncoder.encode(localCharBuffer, paramByteBuffer, paramCharBuffer == null);
          if (localCoderResult.isOverflow())
          {
            if (paramBoolean) {
              currentEncoder.flush(paramByteBuffer);
            }
            FileEncodingQuery.access$400().log(Level.FINEST, "encoder-selected", currentEncoder);
            remainder = localCharBuffer;
            buffer = null;
            return localCoderResult;
          }
          if (paramCharBuffer != null) {
            localCoderResult = currentEncoder.encode(paramCharBuffer, paramByteBuffer, false);
          }
          if (paramBoolean) {
            localCoderResult = currentEncoder.flush(paramByteBuffer);
          }
          FileEncodingQuery.access$400().log(Level.FINEST, "encoder-selected", currentEncoder);
          buffer = null;
          return localCoderResult;
        }
        catch (UnknownEncoding localUnknownEncoding)
        {
          if (j != paramByteBuffer.position())
          {
            buffer = null;
            return localCoderResult;
          }
        }
      }
      buffer = null;
      assert (localCoderResult != null);
      return localCoderResult;
    }
    
    protected CoderResult implFlush(ByteBuffer paramByteBuffer)
    {
      lastByteBuffer = null;
      if (buffer != null) {
        return encodeHead(null, paramByteBuffer, true);
      }
      currentEncoder.encode(FileEncodingQuery.ProxyCharset.EMPTY_CHAR_BUFFER, paramByteBuffer, true);
      return currentEncoder.flush(paramByteBuffer);
    }
    
    protected void implReset()
    {
      if (lastByteBuffer != null) {
        implFlush(lastByteBuffer);
      }
      currentEncoder.reset();
    }
    
    protected void implOnMalformedInput(CodingErrorAction paramCodingErrorAction)
    {
      if ((buffer != null) || (!initialized)) {
        malformedInputAction = paramCodingErrorAction;
      } else {
        currentEncoder.onMalformedInput(paramCodingErrorAction);
      }
    }
    
    protected void implOnUnmappableCharacter(CodingErrorAction paramCodingErrorAction)
    {
      if ((buffer != null) || (!initialized)) {
        unmappableCharAction = paramCodingErrorAction;
      } else {
        currentEncoder.onUnmappableCharacter(paramCodingErrorAction);
      }
    }
    
    protected void implReplaceWith(byte[] paramArrayOfByte)
    {
      if ((buffer != null) || (!initialized)) {
        replace = paramArrayOfByte;
      } else {
        currentEncoder.replaceWith(paramArrayOfByte);
      }
    }
  }
}

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

import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
import java.nio.charset.CodingErrorAction;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import org.netbeans.modules.queries.UnknownEncoding;
import org.netbeans.spi.queries.FileEncodingQueryImplementation;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileStateInvalidException;
import org.openide.filesystems.FileSystem;
import org.openide.util.Lookup;
import org.openide.util.NbPreferences;

public class FileEncodingQuery
{
  private static final int BUFSIZ = 4096;
  private static final String DEFAULT_ENCODING = "default-encoding";
  private static final String UTF_8 = "UTF-8";
  private static final Logger LOG = Logger.getLogger(FileEncodingQuery.class.getName());
  static final String ENCODER_SELECTED = "encoder-selected";
  static final String DECODER_SELECTED = "decoder-selected";
  
  public static Charset getEncoding(FileObject paramFileObject)
  {
    if (paramFileObject == null) {
      throw new IllegalArgumentException();
    }
    ArrayList localArrayList = new ArrayList();
    for (FileEncodingQueryImplementation localFileEncodingQueryImplementation : Lookup.getDefault().lookupAll(FileEncodingQueryImplementation.class))
    {
      Charset localCharset = localFileEncodingQueryImplementation.getEncoding(paramFileObject);
      if (localCharset != null)
      {
        LOG.log(Level.FINE, "{0}: received encoding {1} from {2}", new Object[] { paramFileObject, localCharset, localFileEncodingQueryImplementation });
        localArrayList.add(localCharset);
      }
      else
      {
        LOG.log(Level.FINER, "{0}: received no encoding from {1}", new Object[] { paramFileObject, localFileEncodingQueryImplementation });
      }
    }
    try
    {
      if (paramFileObject.getFileSystem().isDefault()) {
        localArrayList.add(Charset.forName("UTF-8"));
      } else {
        localArrayList.add(Charset.defaultCharset());
      }
    }
    catch (FileStateInvalidException localFileStateInvalidException)
    {
      localArrayList.add(Charset.defaultCharset());
    }
    LOG.log(Level.FINE, "{0}: using encodings {1}", new Object[] { paramFileObject, localArrayList });
    return new ProxyCharset(localArrayList, null);
  }
  
  public static Charset getDefaultEncoding()
  {
    Preferences localPreferences = NbPreferences.forModule(FileEncodingQuery.class);
    String str = localPreferences.get("default-encoding", "UTF-8");
    return Charset.forName(str);
  }
  
  public static void setDefaultEncoding(Charset paramCharset)
  {
    if (paramCharset == null) {
      throw new IllegalArgumentException();
    }
    Preferences localPreferences = NbPreferences.forModule(FileEncodingQuery.class);
    localPreferences.put("default-encoding", paramCharset.name());
  }
  
  private static class ProxyCharset
    extends Charset
  {
    private static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.allocate(0);
    private static final CharBuffer EMPTY_CHAR_BUFFER = CharBuffer.allocate(0);
    private final List<? extends Charset> delegates;
    
    private ProxyCharset(List<? extends Charset> paramList)
    {
      super((String[])((Charset)paramList.get(0)).aliases().toArray(new String[((Charset)paramList.get(0)).aliases().size()]));
      delegates = paramList;
    }
    
    public boolean contains(Charset paramCharset)
    {
      return ((Charset)delegates.get(0)).contains(paramCharset);
    }
    
    public CharsetDecoder newDecoder()
    {
      return new ProxyDecoder(((Charset)delegates.get(0)).newDecoder(), null);
    }
    
    public CharsetEncoder newEncoder()
    {
      return new ProxyEncoder(((Charset)delegates.get(0)).newEncoder(), null);
    }
    
    private class ProxyDecoder
      extends CharsetDecoder
    {
      private CharsetDecoder currentDecoder;
      private ByteBuffer buffer = ByteBuffer.allocate(4096);
      private ByteBuffer remainder;
      private CodingErrorAction malformedInputAction;
      private CodingErrorAction unmappableCharAction;
      private String replace;
      private boolean initialized;
      private CharBuffer lastCharBuffer;
      
      private ProxyDecoder(CharsetDecoder paramCharsetDecoder)
      {
        super(paramCharsetDecoder.averageCharsPerByte(), paramCharsetDecoder.maxCharsPerByte());
        currentDecoder = paramCharsetDecoder;
        initialized = true;
      }
      
      protected CoderResult decodeLoop(ByteBuffer paramByteBuffer, CharBuffer paramCharBuffer)
      {
        lastCharBuffer = paramCharBuffer;
        if (buffer == null)
        {
          if (remainder != null)
          {
            ByteBuffer localByteBuffer = ByteBuffer.allocate(remainder.remaining() + paramByteBuffer.remaining());
            localByteBuffer.put(remainder);
            localByteBuffer.put(paramByteBuffer);
            localByteBuffer.flip();
            CoderResult localCoderResult = currentDecoder.decode(localByteBuffer, paramCharBuffer, false);
            if (localByteBuffer.hasRemaining()) {
              remainder = localByteBuffer;
            } else {
              remainder = null;
            }
            return localCoderResult;
          }
          return currentDecoder.decode(paramByteBuffer, paramCharBuffer, false);
        }
        if (buffer.remaining() == 0) {
          return decodeHead(paramByteBuffer, paramCharBuffer, false);
        }
        if (buffer.remaining() < paramByteBuffer.remaining())
        {
          int i = paramByteBuffer.limit();
          paramByteBuffer.limit(paramByteBuffer.position() + buffer.remaining());
          buffer.put(paramByteBuffer);
          paramByteBuffer.limit(i);
          return decodeHead(paramByteBuffer, paramCharBuffer, false);
        }
        buffer.put(paramByteBuffer);
        return CoderResult.UNDERFLOW;
      }
      
      private CoderResult decodeHead(ByteBuffer paramByteBuffer, CharBuffer paramCharBuffer, boolean paramBoolean)
      {
        buffer.flip();
        CoderResult localCoderResult = null;
        for (int i = 0; i < delegates.size(); i++)
        {
          currentDecoder = ((Charset)delegates.get(i)).newDecoder();
          if (malformedInputAction != null) {
            currentDecoder.onMalformedInput(malformedInputAction);
          }
          if (unmappableCharAction != null) {
            currentDecoder.onUnmappableCharacter(unmappableCharAction);
          }
          if (replace != null) {
            currentDecoder.replaceWith(replace);
          }
          int j = paramCharBuffer.position();
          try
          {
            ByteBuffer localByteBuffer = buffer.asReadOnlyBuffer();
            localCoderResult = currentDecoder.decode(localByteBuffer, paramCharBuffer, paramByteBuffer == null);
            if (localByteBuffer.hasRemaining())
            {
              if (paramBoolean) {
                currentDecoder.flush(paramCharBuffer);
              }
              FileEncodingQuery.LOG.log(Level.FINEST, "decoder-selected", currentDecoder);
              remainder = localByteBuffer;
              buffer = null;
              return localCoderResult;
            }
            if (paramByteBuffer != null) {
              localCoderResult = currentDecoder.decode(paramByteBuffer, paramCharBuffer, false);
            }
            if (paramBoolean) {
              localCoderResult = currentDecoder.flush(paramCharBuffer);
            }
            FileEncodingQuery.LOG.log(Level.FINEST, "decoder-selected", currentDecoder);
            buffer = null;
            return localCoderResult;
          }
          catch (UnknownEncoding localUnknownEncoding)
          {
            if (j != paramCharBuffer.position())
            {
              buffer = null;
              return localCoderResult;
            }
          }
        }
        buffer = null;
        assert (localCoderResult != null);
        return localCoderResult;
      }
      
      protected CoderResult implFlush(CharBuffer paramCharBuffer)
      {
        lastCharBuffer = null;
        if (buffer != null) {
          return decodeHead(null, paramCharBuffer, true);
        }
        currentDecoder.decode(FileEncodingQuery.ProxyCharset.EMPTY_BYTE_BUFFER, paramCharBuffer, true);
        return currentDecoder.flush(paramCharBuffer);
      }
      
      protected void implReset()
      {
        if (lastCharBuffer != null) {
          implFlush(lastCharBuffer);
        }
        currentDecoder.reset();
      }
      
      protected void implOnMalformedInput(CodingErrorAction paramCodingErrorAction)
      {
        if ((buffer != null) || (!initialized)) {
          malformedInputAction = paramCodingErrorAction;
        } else {
          currentDecoder.onMalformedInput(paramCodingErrorAction);
        }
      }
      
      protected void implOnUnmappableCharacter(CodingErrorAction paramCodingErrorAction)
      {
        if ((buffer != null) || (!initialized)) {
          unmappableCharAction = paramCodingErrorAction;
        } else {
          currentDecoder.onUnmappableCharacter(paramCodingErrorAction);
        }
      }
      
      protected void implReplaceWith(String paramString)
      {
        if ((buffer != null) || (!initialized)) {
          replace = paramString;
        } else {
          currentDecoder.replaceWith(paramString);
        }
      }
    }
    
    private class ProxyEncoder
      extends CharsetEncoder
    {
      private CharsetEncoder currentEncoder;
      private CharBuffer buffer = CharBuffer.allocate(4096);
      private CharBuffer remainder;
      private CodingErrorAction malformedInputAction;
      private CodingErrorAction unmappableCharAction;
      private byte[] replace;
      private boolean initialized;
      private ByteBuffer lastByteBuffer;
      
      private ProxyEncoder(CharsetEncoder paramCharsetEncoder)
      {
        super(paramCharsetEncoder.averageBytesPerChar(), paramCharsetEncoder.maxBytesPerChar(), paramCharsetEncoder.replacement());
        currentEncoder = paramCharsetEncoder;
        initialized = true;
      }
      
      protected CoderResult encodeLoop(CharBuffer paramCharBuffer, ByteBuffer paramByteBuffer)
      {
        lastByteBuffer = paramByteBuffer;
        CoderResult localCoderResult1;
        if (buffer == null)
        {
          if (remainder != null)
          {
            localCoderResult1 = currentEncoder.encode(remainder, paramByteBuffer, false);
            if (!remainder.hasRemaining()) {
              remainder = null;
            }
          }
          localCoderResult1 = currentEncoder.encode(paramCharBuffer, paramByteBuffer, false);
          return localCoderResult1;
        }
        if ((buffer.remaining() == 0) || ((buffer.position() > 0) && (paramCharBuffer.limit() == 0)))
        {
          localCoderResult1 = encodeHead(paramCharBuffer, paramByteBuffer, false);
          return localCoderResult1;
        }
        if (buffer.remaining() < paramCharBuffer.remaining())
        {
          int i = paramCharBuffer.limit();
          paramCharBuffer.limit(paramCharBuffer.position() + buffer.remaining());
          buffer.put(paramCharBuffer);
          paramCharBuffer.limit(i);
          CoderResult localCoderResult2 = encodeHead(paramCharBuffer, paramByteBuffer, false);
          return localCoderResult2;
        }
        buffer.put(paramCharBuffer);
        return CoderResult.UNDERFLOW;
      }
      
      private CoderResult encodeHead(CharBuffer paramCharBuffer, ByteBuffer paramByteBuffer, boolean paramBoolean)
      {
        buffer.flip();
        CoderResult localCoderResult = null;
        for (int i = 0; i < delegates.size(); i++)
        {
          currentE
1 2

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