lucene-core-2.9.4-dev

n");
  public static final boolean JAVA_1_1 = JAVA_VERSION.startsWith("1.1.");
  public static final boolean JAVA_1_2 = JAVA_VERSION.startsWith("1.2.");
  public static final boolean JAVA_1_3 = JAVA_VERSION.startsWith("1.3.");
  public static final String OS_NAME = System.getProperty("os.name");
  public static final boolean LINUX = OS_NAME.startsWith("Linux");
  public static final boolean WINDOWS = OS_NAME.startsWith("Windows");
  public static final boolean SUN_OS = OS_NAME.startsWith("SunOS");
  public static final String OS_ARCH = System.getProperty("os.arch");
  public static final String OS_VERSION = System.getProperty("os.version");
  public static final String JAVA_VENDOR = System.getProperty("java.vendor");
  public static final boolean JRE_IS_64BIT;
  public static final String LUCENE_MAIN_VERSION;
  public static final String LUCENE_VERSION;
  
  private static String ident(String s)
  {
    return s.toString();
  }
  
  static
  {
    String x = System.getProperty("sun.arch.data.model");
    if (x != null) {
      JRE_IS_64BIT = x.indexOf("64") != -1;
    } else if ((OS_ARCH != null) && (OS_ARCH.indexOf("64") != -1)) {
      JRE_IS_64BIT = true;
    } else {
      JRE_IS_64BIT = false;
    }
    LUCENE_MAIN_VERSION = ident("2.9.4");
    
    Package pkg = LucenePackage.get();
    String v = pkg == null ? null : pkg.getImplementationVersion();
    if (v == null) {
      v = LUCENE_MAIN_VERSION + "-dev";
    } else if (v.indexOf(LUCENE_MAIN_VERSION) == -1) {
      v = v + " [" + LUCENE_MAIN_VERSION + "]";
    }
    LUCENE_VERSION = ident(v);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.Constants
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

import java.util.BitSet;
import org.apache.lucene.search.DocIdSetIterator;

class DocIdBitSet$DocIdBitSetIterator
  extends DocIdSetIterator
{
  private int docId;
  private BitSet bitSet;
  
  DocIdBitSet$DocIdBitSetIterator(BitSet bitSet)
  {
    this.bitSet = bitSet;
    docId = -1;
  }
  
  /**
   * @deprecated
   */
  public int doc()
  {
    assert (docId != -1);
    return docId;
  }
  
  public int docID()
  {
    return docId;
  }
  
  /**
   * @deprecated
   */
  public boolean next()
  {
    return nextDoc() != Integer.MAX_VALUE;
  }
  
  public int nextDoc()
  {
    int d = bitSet.nextSetBit(docId + 1);
    
    docId = (d == -1 ? Integer.MAX_VALUE : d);
    return docId;
  }
  
  /**
   * @deprecated
   */
  public boolean skipTo(int skipDocNr)
  {
    return advance(skipDocNr) != Integer.MAX_VALUE;
  }
  
  public int advance(int target)
  {
    int d = bitSet.nextSetBit(target);
    
    docId = (d == -1 ? Integer.MAX_VALUE : d);
    return docId;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.DocIdBitSet.DocIdBitSetIterator
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

import java.util.BitSet;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;

public class DocIdBitSet
  extends DocIdSet
{
  private BitSet bitSet;
  
  public DocIdBitSet(BitSet bitSet)
  {
    this.bitSet = bitSet;
  }
  
  public DocIdSetIterator iterator()
  {
    return new DocIdBitSetIterator(bitSet);
  }
  
  public boolean isCacheable()
  {
    return true;
  }
  
  public BitSet getBitSet()
  {
    return bitSet;
  }
  
  private static class DocIdBitSetIterator
    extends DocIdSetIterator
  {
    private int docId;
    private BitSet bitSet;
    
    DocIdBitSetIterator(BitSet bitSet)
    {
      this.bitSet = bitSet;
      docId = -1;
    }
    
    /**
     * @deprecated
     */
    public int doc()
    {
      assert (docId != -1);
      return docId;
    }
    
    public int docID()
    {
      return docId;
    }
    
    /**
     * @deprecated
     */
    public boolean next()
    {
      return nextDoc() != Integer.MAX_VALUE;
    }
    
    public int nextDoc()
    {
      int d = bitSet.nextSetBit(docId + 1);
      
      docId = (d == -1 ? Integer.MAX_VALUE : d);
      return docId;
    }
    
    /**
     * @deprecated
     */
    public boolean skipTo(int skipDocNr)
    {
      return advance(skipDocNr) != Integer.MAX_VALUE;
    }
    
    public int advance(int target)
    {
      int d = bitSet.nextSetBit(target);
      
      docId = (d == -1 ? Integer.MAX_VALUE : d);
      return docId;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.DocIdBitSet
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

import org.apache.lucene.search.FieldCache.CacheEntry;

public final class FieldCacheSanityChecker$Insanity
{
  private final FieldCacheSanityChecker.InsanityType type;
  private final String msg;
  private final FieldCache.CacheEntry[] entries;
  
  public FieldCacheSanityChecker$Insanity(FieldCacheSanityChecker.InsanityType type, String msg, FieldCache.CacheEntry[] entries)
  {
    if (null == type) {
      throw new IllegalArgumentException("Insanity requires non-null InsanityType");
    }
    if ((null == entries) || (0 == entries.length)) {
      throw new IllegalArgumentException("Insanity requires non-null/non-empty CacheEntry[]");
    }
    this.type = type;
    this.msg = msg;
    this.entries = entries;
  }
  
  public FieldCacheSanityChecker.InsanityType getType()
  {
    return type;
  }
  
  public String getMsg()
  {
    return msg;
  }
  
  public FieldCache.CacheEntry[] getCacheEntries()
  {
    return entries;
  }
  
  public String toString()
  {
    StringBuffer buf = new StringBuffer();
    buf.append(getType()).append(": ");
    
    String m = getMsg();
    if (null != m) {
      buf.append(m);
    }
    buf.append('\n');
    
    FieldCache.CacheEntry[] ce = getCacheEntries();
    for (int i = 0; i < ce.length; i++) {
      buf.append('\t').append(ce[i].toString()).append('\n');
    }
    return buf.toString();
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.FieldCacheSanityChecker.Insanity
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

public final class FieldCacheSanityChecker$InsanityType
{
  private final String label;
  
  private FieldCacheSanityChecker$InsanityType(String label)
  {
    this.label = label;
  }
  
  public String toString()
  {
    return label;
  }
  
  public static final InsanityType SUBREADER = new InsanityType("SUBREADER");
  public static final InsanityType VALUEMISMATCH = new InsanityType("VALUEMISMATCH");
  public static final InsanityType EXPECTED = new InsanityType("EXPECTED");
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.FieldCacheSanityChecker.InsanityType
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

final class FieldCacheSanityChecker$ReaderField
{
  public final Object readerKey;
  public final String fieldName;
  
  public FieldCacheSanityChecker$ReaderField(Object readerKey, String fieldName)
  {
    this.readerKey = readerKey;
    this.fieldName = fieldName;
  }
  
  public int hashCode()
  {
    return System.identityHashCode(readerKey) * fieldName.hashCode();
  }
  
  public boolean equals(Object that)
  {
    if (!(that instanceof ReaderField)) {
      return false;
    }
    ReaderField other = (ReaderField)that;
    return (readerKey == readerKey) && (fieldName.equals(fieldName));
  }
  
  public String toString()
  {
    return readerKey.toString() + "+" + fieldName;
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.FieldCacheSanityChecker.ReaderField
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.search.FieldCache;
import org.apache.lucene.search.FieldCache.CacheEntry;
import org.apache.lucene.search.FieldCache.CreationPlaceholder;

public final class FieldCacheSanityChecker
{
  private RamUsageEstimator ramCalc = null;
  
  public void setRamUsageEstimator(RamUsageEstimator r)
  {
    ramCalc = r;
  }
  
  public static Insanity[] checkSanity(FieldCache cache)
  {
    return checkSanity(cache.getCacheEntries());
  }
  
  public static Insanity[] checkSanity(FieldCache.CacheEntry[] cacheEntries)
  {
    FieldCacheSanityChecker sanityChecker = new FieldCacheSanityChecker();
    
    sanityChecker.setRamUsageEstimator(new RamUsageEstimator(false));
    return sanityChecker.check(cacheEntries);
  }
  
  public Insanity[] check(FieldCache.CacheEntry[] cacheEntries)
  {
    if ((null == cacheEntries) || (0 == cacheEntries.length)) {
      return new Insanity[0];
    }
    if (null != ramCalc) {
      for (int i = 0; i < cacheEntries.length; i++) {
        cacheEntries[i].estimateSize(ramCalc);
      }
    }
    MapOfSets valIdToItems = new MapOfSets(new HashMap(17));
    
    MapOfSets readerFieldToValIds = new MapOfSets(new HashMap(17));
    
    Set valMismatchKeys = new HashSet();
    for (int i = 0; i < cacheEntries.length; i++)
    {
      FieldCache.CacheEntry item = cacheEntries[i];
      Object val = item.getValue();
      if (!(val instanceof FieldCache.CreationPlaceholder))
      {
        ReaderField rf = new ReaderField(item.getReaderKey(), item.getFieldName());
        
        Integer valId = new Integer(System.identityHashCode(val));
        
        valIdToItems.put(valId, item);
        if (1 < readerFieldToValIds.put(rf, valId)) {
          valMismatchKeys.add(rf);
        }
      }
    }
    List insanity = new ArrayList(valMismatchKeys.size() * 3);
    
    insanity.addAll(checkValueMismatch(valIdToItems, readerFieldToValIds, valMismatchKeys));
    
    insanity.addAll(checkSubreaders(valIdToItems, readerFieldToValIds));
    
    return (Insanity[])insanity.toArray(new Insanity[insanity.size()]);
  }
  
  private Collection checkValueMismatch(MapOfSets valIdToItems, MapOfSets readerFieldToValIds, Set valMismatchKeys)
  {
    List insanity = new ArrayList(valMismatchKeys.size() * 3);
    if (!valMismatchKeys.isEmpty())
    {
      Map rfMap = readerFieldToValIds.getMap();
      Map valMap = valIdToItems.getMap();
      Iterator mismatchIter = valMismatchKeys.iterator();
      while (mismatchIter.hasNext())
      {
        ReaderField rf = (ReaderField)mismatchIter.next();
        List badEntries = new ArrayList(valMismatchKeys.size() * 2);
        Iterator valIter = ((Set)rfMap.get(rf)).iterator();
        while (valIter.hasNext())
        {
          Iterator entriesIter = ((Set)valMap.get(valIter.next())).iterator();
          while (entriesIter.hasNext()) {
            badEntries.add(entriesIter.next());
          }
        }
        FieldCache.CacheEntry[] badness = new FieldCache.CacheEntry[badEntries.size()];
        badness = (FieldCache.CacheEntry[])badEntries.toArray(badness);
        
        insanity.add(new Insanity(InsanityType.VALUEMISMATCH, "Multiple distinct value objects for " + rf.toString(), badness));
      }
    }
    return insanity;
  }
  
  private Collection checkSubreaders(MapOfSets valIdToItems, MapOfSets readerFieldToValIds)
  {
    List insanity = new ArrayList(23);
    
    Map badChildren = new HashMap(17);
    MapOfSets badKids = new MapOfSets(badChildren);
    
    Map viToItemSets = valIdToItems.getMap();
    Map rfToValIdSets = readerFieldToValIds.getMap();
    
    Set seen = new HashSet(17);
    
    Set readerFields = rfToValIdSets.keySet();
    Iterator rfIter = readerFields.iterator();
    while (rfIter.hasNext())
    {
      ReaderField rf = (ReaderField)rfIter.next();
      if (!seen.contains(rf))
      {
        List kids = getAllDecendentReaderKeys(readerKey);
        for (int i = 0; i < kids.size(); i++)
        {
          ReaderField kid = new ReaderField(kids.get(i), fieldName);
          if (badChildren.containsKey(kid))
          {
            badKids.put(rf, kid);
            badKids.putAll(rf, (Collection)badChildren.get(kid));
            badChildren.remove(kid);
          }
          else if (rfToValIdSets.containsKey(kid))
          {
            badKids.put(rf, kid);
          }
          seen.add(kid);
        }
        seen.add(rf);
      }
    }
    Iterator parentsIter = badChildren.keySet().iterator();
    while (parentsIter.hasNext())
    {
      ReaderField parent = (ReaderField)parentsIter.next();
      Set kids = (Set)badChildren.get(parent);
      
      List badEntries = new ArrayList(kids.size() * 2);
      
      Iterator valIter = ((Set)rfToValIdSets.get(parent)).iterator();
      while (valIter.hasNext()) {
        badEntries.addAll((Set)viToItemSets.get(valIter.next()));
      }
      Iterator kidsIter = kids.iterator();
      while (kidsIter.hasNext())
      {
        ReaderField kid = (ReaderField)kidsIter.next();
        Iterator valIter = ((Set)rfToValIdSets.get(kid)).iterator();
        while (valIter.hasNext()) {
          badEntries.addAll((Set)viToItemSets.get(valIter.next()));
        }
      }
      FieldCache.CacheEntry[] badness = new FieldCache.CacheEntry[badEntries.size()];
      badness = (FieldCache.CacheEntry[])badEntries.toArray(badness);
      
      insanity.add(new Insanity(InsanityType.SUBREADER, "Found caches for decendents of " + parent.toString(), badness));
    }
    return insanity;
  }
  
  private List getAllDecendentReaderKeys(Object seed)
  {
    List all = new ArrayList(17);
    all.add(seed);
    for (int i = 0; i < all.size(); i++)
    {
      Object obj = all.get(i);
      if ((obj instanceof IndexReader))
      {
        IndexReader[] subs = ((IndexReader)obj).getSequentialSubReaders();
        for (int j = 0; (null != subs) && (j < subs.length); j++) {
          all.add(subs[j].getFieldCacheKey());
        }
      }
    }
    return all.subList(1, all.size());
  }
  
  private static final class ReaderField
  {
    public final Object readerKey;
    public final String fieldName;
    
    public ReaderField(Object readerKey, String fieldName)
    {
      this.readerKey = readerKey;
      this.fieldName = fieldName;
    }
    
    public int hashCode()
    {
      return System.identityHashCode(readerKey) * fieldName.hashCode();
    }
    
    public boolean equals(Object that)
    {
      if (!(that instanceof ReaderField)) {
        return false;
      }
      ReaderField other = (ReaderField)that;
      return (readerKey == readerKey) && (fieldName.equals(fieldName));
    }
    
    public String toString()
    {
      return readerKey.toString() + "+" + fieldName;
    }
  }
  
  public static final class Insanity
  {
    private final FieldCacheSanityChecker.InsanityType type;
    private final String msg;
    private final FieldCache.CacheEntry[] entries;
    
    public Insanity(FieldCacheSanityChecker.InsanityType type, String msg, FieldCache.CacheEntry[] entries)
    {
      if (null == type) {
        throw new IllegalArgumentException("Insanity requires non-null InsanityType");
      }
      if ((null == entries) || (0 == entries.length)) {
        throw new IllegalArgumentException("Insanity requires non-null/non-empty CacheEntry[]");
      }
      this.type = type;
      this.msg = msg;
      this.entries = entries;
    }
    
    public FieldCacheSanityChecker.InsanityType getType()
    {
      return type;
    }
    
    public String getMsg()
    {
      return msg;
    }
    
    public FieldCache.CacheEntry[] getCacheEntries()
    {
      return entries;
    }
    
    public String toString()
    {
      StringBuffer buf = new StringBuffer();
      buf.append(getType()).append(": ");
      
      String m = getMsg();
      if (null != m) {
        buf.append(m);
      }
      buf.append('\n');
      
      FieldCache.CacheEntry[] ce = getCacheEntries();
      for (int i = 0; i < ce.length; i++) {
        buf.append('\t').append(ce[i].toString()).append('\n');
      }
      return buf.toString();
    }
  }
  
  public static final class InsanityType
  {
    private final String label;
    
    private InsanityType(String label)
    {
      this.label = label;
    }
    
    public String toString()
    {
      return label;
    }
    
    public static final InsanityType SUBREADER = new InsanityType("SUBREADER");
    public static final InsanityType VALUEMISMATCH = new InsanityType("VALUEMISMATCH");
    public static final InsanityType EXPECTED = new InsanityType("EXPECTED");
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.FieldCacheSanityChecker
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

class IndexableBinaryStringTools$CodingCase
{
  int numBytes;
  int initialShift;
  int middleShift;
  int finalShift;
  int advanceBytes = 2;
  short middleMask;
  short finalMask;
  
  IndexableBinaryStringTools$CodingCase(int initialShift, int middleShift, int finalShift)
  {
    numBytes = 3;
    this.initialShift = initialShift;
    this.middleShift = middleShift;
    this.finalShift = finalShift;
    finalMask = ((short)(255 >>> finalShift));
    middleMask = ((short)(255 << middleShift));
  }
  
  IndexableBinaryStringTools$CodingCase(int initialShift, int finalShift)
  {
    numBytes = 2;
    this.initialShift = initialShift;
    this.finalShift = finalShift;
    finalMask = ((short)(255 >>> finalShift));
    if (finalShift != 0) {
      advanceBytes = 1;
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.IndexableBinaryStringTools.CodingCase
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

import java.nio.ByteBuffer;
import java.nio.CharBuffer;

public class IndexableBinaryStringTools
{
  private static final CodingCase[] CODING_CASES = { new CodingCase(7, 1), new CodingCase(14, 6, 2), new CodingCase(13, 5, 3), new CodingCase(12, 4, 4), new CodingCase(11, 3, 5), new CodingCase(10, 2, 6), new CodingCase(9, 1, 7), new CodingCase(8, 0) };
  
  public static int getEncodedLength(ByteBuffer original)
    throws IllegalArgumentException
  {
    if (original.hasArray())
    {
      long length = original.limit() - original.arrayOffset();
      return (int)((length * 8L + 14L) / 15L) + 1;
    }
    throw new IllegalArgumentException("original argument must have a backing array");
  }
  
  public static int getDecodedLength(CharBuffer encoded)
    throws IllegalArgumentException
  {
    if (encoded.hasArray())
    {
      int numChars = encoded.limit() - encoded.arrayOffset() - 1;
      if (numChars <= 0) {
        return 0;
      }
      int numFullBytesInFinalChar = encoded.charAt(encoded.limit() - 1);
      int numEncodedChars = numChars - 1;
      return (numEncodedChars * 15 + 7) / 8 + numFullBytesInFinalChar;
    }
    throw new IllegalArgumentException("encoded argument must have a backing array");
  }
  
  public static void encode(ByteBuffer input, CharBuffer output)
  {
    if ((input.hasArray()) && (output.hasArray()))
    {
      byte[] inputArray = input.array();
      int inputOffset = input.arrayOffset();
      int inputLength = input.limit() - inputOffset;
      char[] outputArray = output.array();
      int outputOffset = output.arrayOffset();
      int outputLength = getEncodedLength(input);
      output.limit(outputOffset + outputLength);
      output.position(0);
      if (inputLength > 0)
      {
        int inputByteNum = inputOffset;
        int caseNum = 0;
        for (int outputCharNum = outputOffset; inputByteNum + CODING_CASESnumBytes <= inputLength; outputCharNum++)
        {
          CodingCase codingCase = CODING_CASES[caseNum];
          if (2 == numBytes) {
            outputArray[outputCharNum] = ((char)(((inputArray[inputByteNum] & 0xFF) << initialShift) + ((inputArray[(inputByteNum + 1)] & 0xFF) >>> finalShift & finalMask) & 0x7FFF));
          } else {
            outputArray[outputCharNum] = ((char)(((inputArray[inputByteNum] & 0xFF) << initialShift) + ((inputArray[(inputByteNum + 1)] & 0xFF) << middleShift) + ((inputArray[(inputByteNum + 2)] & 0xFF) >>> finalShift & finalMask) & 0x7FFF));
          }
          inputByteNum += advanceBytes;
          caseNum++;
          if (caseNum == CODING_CASES.length) {
            caseNum = 0;
          }
        }
        CodingCase codingCase = CODING_CASES[caseNum];
        if (inputByteNum + 1 < inputLength)
        {
          outputArray[(outputCharNum++)] = ((char)(((inputArray[inputByteNum] & 0xFF) << initialShift) + ((inputArray[(inputByteNum + 1)] & 0xFF) << middleShift) & 0x7FFF));
          
          outputArray[(outputCharNum++)] = '\001';
        }
        else if (inputByteNum < inputLength)
        {
          outputArray[(outputCharNum++)] = ((char)((inputArray[inputByteNum] & 0xFF) << initialShift & 0x7FFF));
          
          outputArray[(outputCharNum++)] = (caseNum == 0 ? 1 : '\000');
        }
        else
        {
          outputArray[(outputCharNum++)] = '\001';
        }
      }
    }
    else
    {
      throw new IllegalArgumentException("Arguments must have backing arrays");
    }
  }
  
  public static void decode(CharBuffer input, ByteBuffer output)
  {
    if ((input.hasArray()) && (output.hasArray()))
    {
      int numInputChars = input.limit() - input.arrayOffset() - 1;
      int numOutputBytes = getDecodedLength(input);
      output.limit(numOutputBytes + output.arrayOffset());
      output.position(0);
      byte[] outputArray = output.array();
      char[] inputArray = input.array();
      if (numOutputBytes > 0)
      {
        int caseNum = 0;
        int outputByteNum = output.arrayOffset();
        for (int inputCharNum = input.arrayOffset(); inputCharNum < numInputChars - 1; inputCharNum++)
        {
          CodingCase codingCase = CODING_CASES[caseNum];
          short inputChar = (short)inputArray[inputCharNum];
          if (2 == numBytes)
          {
            if (0 == caseNum)
            {
              outputArray[outputByteNum] = ((byte)(inputChar >>> initialShift));
            }
            else
            {
              int tmp139_137 = outputByteNum; byte[] tmp139_135 = outputArray;tmp139_135[tmp139_137] = ((byte)(tmp139_135[tmp139_137] + (byte)(inputChar >>> initialShift)));
            }
            outputArray[(outputByteNum + 1)] = ((byte)((inputChar & finalMask) << finalShift));
          }
          else
          {
            int tmp182_180 = outputByteNum; byte[] tmp182_178 = outputArray;tmp182_178[tmp182_180] = ((byte)(tmp182_178[tmp182_180] + (byte)(inputChar >>> initialShift)));
            outputArray[(outputByteNum + 1)] = ((byte)((inputChar & middleMask) >>> middleShift));
            
            outputArray[(outputByteNum + 2)] = ((byte)((inputChar & finalMask) << finalShift));
          }
          outputByteNum += advanceBytes;
          caseNum++;
          if (caseNum == CODING_CASES.length) {
            caseNum = 0;
          }
        }
        short inputChar = (short)inputArray[inputCharNum];
        CodingCase codingCase = CODING_CASES[caseNum];
        if (0 == caseNum) {
          outputArray[outputByteNum] = 0;
        }
        int tmp303_301 = outputByteNum; byte[] tmp303_299 = outputArray;tmp303_299[tmp303_301] = ((byte)(tmp303_299[tmp303_301] + (byte)(inputChar >>> initialShift)));
        int bytesLeft = numOutputBytes - outputByteNum;
        if (bytesLeft > 1) {
          if (2 == numBytes)
          {
            outputArray[(outputByteNum + 1)] = ((byte)((inputChar & finalMask) >>> finalShift));
          }
          else
          {
            outputArray[(outputByteNum + 1)] = ((byte)((inputChar & middleMask) >>> middleShift));
            if (bytesLeft > 2) {
              outputArray[(outputByteNum + 2)] = ((byte)((inputChar & finalMask) << finalShift));
            }
          }
        }
      }
    }
    else
    {
      throw new IllegalArgumentException("Arguments must have backing arrays");
    }
  }
  
  public static ByteBuffer decode(CharBuffer input)
  {
    byte[] outputArray = new byte[getDecodedLength(input)];
    ByteBuffer output = ByteBuffer.wrap(outputArray);
    decode(input, output);
    return output;
  }
  
  public static CharBuffer encode(ByteBuffer input)
  {
    char[] outputArray = new char[getEncodedLength(input)];
    CharBuffer output = CharBuffer.wrap(outputArray);
    encode(input, output);
    return output;
  }
  
  static class CodingCase
  {
    int numBytes;
    int initialShift;
    int middleShift;
    int finalShift;
    int advanceBytes = 2;
    short middleMask;
    short finalMask;
    
    CodingCase(int initialShift, int middleShift, int finalShift)
    {
      numBytes = 3;
      this.initialShift = initialShift;
      this.middleShift = middleShift;
      this.finalShift = finalShift;
      finalMask = ((short)(255 >>> finalShift));
      middleMask = ((short)(255 << middleShift));
    }
    
    CodingCase(int initialShift, int finalShift)
    {
      numBytes = 2;
      this.initialShift = initialShift;
      this.finalShift = finalShift;
      finalMask = ((short)(255 >>> finalShift));
      if (finalShift != 0) {
        advanceBytes = 1;
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.IndexableBinaryStringTools
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class MapOfSets
{
  private final Map theMap;
  
  public MapOfSets(Map m)
  {
    theMap = m;
  }
  
  public Map getMap()
  {
    return theMap;
  }
  
  public int put(Object key, Object val)
  {
    Set theSet;
    Set theSet;
    if (theMap.containsKey(key))
    {
      theSet = (Set)theMap.get(key);
    }
    else
    {
      theSet = new HashSet(23);
      theMap.put(key, theSet);
    }
    theSet.add(val);
    return theSet.size();
  }
  
  public int putAll(Object key, Collection vals)
  {
    Set theSet;
    Set theSet;
    if (theMap.containsKey(key))
    {
      theSet = (Set)theMap.get(key);
    }
    else
    {
      theSet = new HashSet(23);
      theMap.put(key, theSet);
    }
    theSet.addAll(vals);
    return theSet.size();
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.MapOfSets
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

public abstract class MemoryModel
{
  public abstract int getArraySize();
  
  public abstract int getClassSize();
  
  public abstract int getPrimitiveSize(Class paramClass);
  
  public abstract int getReferenceSize();
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.MemoryModel
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

public abstract class NumericUtils$IntRangeBuilder
{
  public void addRange(String minPrefixCoded, String maxPrefixCoded)
  {
    throw new UnsupportedOperationException();
  }
  
  public void addRange(int min, int max, int shift)
  {
    addRange(NumericUtils.intToPrefixCoded(min, shift), NumericUtils.intToPrefixCoded(max, shift));
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.NumericUtils.IntRangeBuilder
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

public abstract class NumericUtils$LongRangeBuilder
{
  public void addRange(String minPrefixCoded, String maxPrefixCoded)
  {
    throw new UnsupportedOperationException();
  }
  
  public void addRange(long min, long max, int shift)
  {
    addRange(NumericUtils.longToPrefixCoded(min, shift), NumericUtils.longToPrefixCoded(max, shift));
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.NumericUtils.LongRangeBuilder
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

public final class NumericUtils
{
  public static final int PRECISION_STEP_DEFAULT = 4;
  public static final char SHIFT_START_LONG = ' ';
  public static final int BUF_SIZE_LONG = 11;
  public static final char SHIFT_START_INT = '`';
  public static final int BUF_SIZE_INT = 6;
  
  public static int longToPrefixCoded(long val, int shift, char[] buffer)
  {
    if ((shift > 63) || (shift < 0)) {
      throw new IllegalArgumentException("Illegal shift value, must be 0..63");
    }
    int nChars = (63 - shift) / 7 + 1;int len = nChars + 1;
    buffer[0] = ((char)(32 + shift));
    long sortableBits = val ^ 0x8000000000000000;
    sortableBits >>>= shift;
    while (nChars >= 1)
    {
      buffer[(nChars--)] = ((char)(int)(sortableBits & 0x7F));
      sortableBits >>>= 7;
    }
    return len;
  }
  
  public static String longToPrefixCoded(long val, int shift)
  {
    char[] buffer = new char[11];
    int len = longToPrefixCoded(val, shift, buffer);
    return new String(buffer, 0, len);
  }
  
  public static String longToPrefixCoded(long val)
  {
    return longToPrefixCoded(val, 0);
  }
  
  public static int intToPrefixCoded(int val, int shift, char[] buffer)
  {
    if ((shift > 31) || (shift < 0)) {
      throw new IllegalArgumentException("Illegal shift value, must be 0..31");
    }
    int nChars = (31 - shift) / 7 + 1;int len = nChars + 1;
    buffer[0] = ((char)(96 + shift));
    int sortableBits = val ^ 0x80000000;
    sortableBits >>>= shift;
    while (nChars >= 1)
    {
      buffer[(nChars--)] = ((char)(sortableBits & 0x7F));
      sortableBits >>>= 7;
    }
    return len;
  }
  
  public static String intToPrefixCoded(int val, int shift)
  {
    char[] buffer = new char[6];
    int len = intToPrefixCoded(val, shift, buffer);
    return new String(buffer, 0, len);
  }
  
  public static String intToPrefixCoded(int val)
  {
    return intToPrefixCoded(val, 0);
  }
  
  public static long prefixCodedToLong(String prefixCoded)
  {
    int shift = prefixCoded.charAt(0) - ' ';
    if ((shift > 63) || (shift < 0)) {
      throw new NumberFormatException("Invalid shift value in prefixCoded string (is encoded value really a LONG?)");
    }
    long sortableBits = 0L;
    int i = 1;
    for (int len = prefixCoded.length(); i < len; i++)
    {
      sortableBits <<= 7;
      char ch = prefixCoded.charAt(i);
      if (ch > '') {
        throw new NumberFormatException("Invalid prefixCoded numerical value representation (char " + Integer.toHexString(ch) + " at position " + i + " is invalid)");
      }
      sortableBits |= ch;
    }
    return sortableBits << shift ^ 0x8000000000000000;
  }
  
  public static int prefixCodedToInt(String prefixCoded)
  {
    int shift = prefixCoded.charAt(0) - '`';
    if ((shift > 31) || (shift < 0)) {
      throw new NumberFormatException("Invalid shift value in prefixCoded string (is encoded value really an INT?)");
    }
    int sortableBits = 0;
    int i = 1;
    for (int len = prefixCoded.length(); i < len; i++)
    {
      sortableBits <<= 7;
      char ch = prefixCoded.charAt(i);
      if (ch > '') {
        throw new NumberFormatException("Invalid prefixCoded numerical value representation (char " + Integer.toHexString(ch) + " at position " + i + " is invalid)");
      }
      sortableBits |= ch;
    }
    return sortableBits << shift ^ 0x80000000;
  }
  
  public static long doubleToSortableLong(double val)
  {
    long f = Double.doubleToRawLongBits(val);
    if (f < 0L) {
      f ^= 0x7FFFFFFFFFFFFFFF;
    }
    return f;
  }
  
  public static String doubleToPrefixCoded(double val)
  {
    return longToPrefixCoded(doubleToSortableLong(val));
  }
  
  public static double sortableLongToDouble(long val)
  {
    if (val < 0L) {
      val ^= 0x7FFFFFFFFFFFFFFF;
    }
    return Double.longBitsToDouble(val);
  }
  
  public static double prefixCodedToDouble(String val)
  {
    return sortableLongToDouble(prefixCodedToLong(val));
  }
  
  public static int floatToSortableInt(float val)
  {
    int f = Float.floatToRawIntBits(val);
    if (f < 0) {
      f ^= 0x7FFFFFFF;
    }
    return f;
  }
  
  public static String floatToPrefixCoded(float val)
  {
    return intToPrefixCoded(floatToSortableInt(val));
  }
  
  public static float sortableIntToFloat(int val)
  {
    if (val < 0) {
      val ^= 0x7FFFFFFF;
    }
    return Float.intBitsToFloat(val);
  }
  
  public static float prefixCodedToFloat(String val)
  {
    return sortableIntToFloat(prefixCodedToInt(val));
  }
  
  public static void splitLongRange(LongRangeBuilder builder, int precisionStep, long minBound, long maxBound)
  {
    splitRange(builder, 64, precisionStep, minBound, maxBound);
  }
  
  public static void splitIntRange(IntRangeBuilder builder, int precisionStep, int minBound, int maxBound)
  {
    splitRange(builder, 32, precisionStep, minBound, maxBound);
  }
  
  private static void splitRange(Object builder, int valSize, int precisionStep, long minBound, long maxBound)
  {
    if (precisionStep < 1) {
      throw new IllegalArgumentException("precisionStep must be >=1");
    }
    if (minBound > maxBound) {
      return;
    }
    for (int shift = 0;; shift += precisionStep)
    {
      long diff = 1L << shift + precisionStep;
      long mask = (1L << precisionStep) - 1L << shift;
      
      boolean hasLower = (minBound & mask) != 0L;
      boolean hasUpper = (maxBound & mask) != mask;
      
      long nextMinBound = (hasLower ? minBound + diff : minBound) & (mask ^ 0xFFFFFFFFFFFFFFFF);
      long nextMaxBound = (hasUpper ? maxBound - diff : maxBound) & (mask ^ 0xFFFFFFFFFFFFFFFF);
      
      boolean lowerWrapped = nextMinBound < minBound;
      boolean upperWrapped = nextMaxBound > maxBound;
      if ((shift + precisionStep >= valSize) || (nextMinBound > nextMaxBound) || (lowerWrapped) || (upperWrapped))
      {
        addRange(builder, valSize, minBound, maxBound, shift);
        
        break;
      }
      if (hasLower) {
        addRange(builder, valSize, minBound, minBound | mask, shift);
      }
      if (hasUpper) {
        addRange(builder, valSize, maxBound & (mask ^ 0xFFFFFFFFFFFFFFFF), maxBound, shift);
      }
      minBound = nextMinBound;
      maxBound = nextMaxBound;
    }
  }
  
  private static void addRange(Object builder, int valSize, long minBound, long maxBound, int shift)
  {
    maxBound |= (1L << shift) - 1L;
    switch (valSize)
    {
    case 64: 
      ((LongRangeBuilder)builder).addRange(minBound, maxBound, shift);
      break;
    case 32: 
      ((IntRangeBuilder)builder).addRange((int)minBound, (int)maxBound, shift);
      break;
    default: 
      throw new IllegalArgumentException("valSize must be 32 or 64.");
    }
  }
  
  public static abstract class LongRangeBuilder
  {
    public void addRange(String minPrefixCoded, String maxPrefixCoded)
    {
      throw new UnsupportedOperationException();
    }
    
    public void addRange(long min, long max, int shift)
    {
      addRange(NumericUtils.longToPrefixCoded(min, shift), NumericUtils.longToPrefixCoded(max, shift));
    }
  }
  
  public static abstract class IntRangeBuilder
  {
    public void addRange(String minPrefixCoded, String maxPrefixCoded)
    {
      throw new UnsupportedOperationException();
    }
    
    public void addRange(int min, int max, int shift)
    {
      addRange(NumericUtils.intToPrefixCoded(min, shift), NumericUtils.intToPrefixCoded(max, shift));
    }
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.util.NumericUtils
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.util;

import java.io.Serializable;
import java.util.Arrays;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.DocIdSetIterator;

public class OpenBitSet
  extends DocIdSet
  implements Cloneable, Serializable
{
  protected long[] bits;
  protected int wlen;
  
  public OpenBitSet(long numBits)
  {
    bits = new long[bits2words(numBits)];
    wlen = bits.length;
  }
  
  public OpenBitSet()
  {
    this(64L);
  }
  
  public OpenBitSet(long[] bits, int numWords)
  {
    this.bits = bits;
    wlen = numWords;
  }
  
  public DocIdSetIterator iterator()
  {
    return new OpenBitSetIterator(bits, wlen);
  }
  
  public boolean isCacheable()
  {
    return true;
  }
  
  public long capacity()
  {
    return bits.length << 6;
  }
  
  public long size()
  {
    return capacity();
  }
  
  public boolean isEmpty()
  {
    return cardinality() == 0L;
  }
  
  public long[] getBits()
  {
    return bits;
  }
  
  public void setBits(long[] bits)
  {
    this.bits = bits;
  }
  
  public int getNumWords()
  {
    return wlen;
  }
  
  public void setNumWords(int nWords)
  {
    wlen = nWords;
  }
  
  public boolean get(int index)
  {
    int i = index >> 6;
    if (i >= bits.length) {
      return false;
    }
    int bit = index & 0x3F;
    long bitmask = 1L << bit;
    return (bits[i] & bitmask) != 0L;
  }
  
  public boolean fastGet(int index)
  {
    int i = index >> 6;
    
    int bit = index & 0x3F;
    long bitmask = 1L << bit;
    return (bits[i] & bitmask) != 0L;
  }
  
  public boolean get(long index)
  {
    int i = (int)(index >> 6);
    if (i >= bits.length) {
      return false;
    }
    int bit = (int)index & 0x3F;
    long bitmask = 1L << bit;
    return (bits[i] & bitmask) != 0L;
  }
  
  public boolean fastGet(long index)
  {
    int i = (int)(index >> 6);
    int bit = (int)index & 0x3F;
    long bitmask = 1L << bit;
    return (bits[i] & bitmask) != 0L;
  }
  
  public int getBit(int index)
  {
    int i = index >> 6;
    int bit = index & 0x3F;
    return (int)(bits[i] >>> bit) & 0x1;
  }
  
  public void set(long index)
  {
    int wordNum = expandingWordNum(index);
    int bit = (int)index & 0x3F;
    long bitmask = 1L << bit;
    bits[wordNum] |= bitmask;
  }
  
  public void fastSet(int index)
  {
    int wordNum = index >> 6;
    int bit = index & 0x3F;
    long bitmask = 1L << bit;
    bits[wordNum] |= bitmask;
  }
  
  public void fastSet(long index)
  {
    int wordNum = (int)(index >> 6);
    int bit = (int)index & 0x3F;
    long bitmask = 1L << bit;
    bits[wordNum] |= bitmask;
  }
  
  public void set(long startIndex, long endIndex)
  {
    if (endIndex <= startIndex) {
      return;
    }
    int startWord = (int)(startIndex >> 6);
    
    int endWord = expandingWordNum(endIndex - 1L);
    
    long startmask = -1L << (int)startIndex;
    long endmask = -1L >>> (int)-endIndex;
    if (startWord == endWord)
    {
      bits[startWord] |= startmask & endmask;
      return;
    }
    bits[startWord] |= startmask;
    Arrays.fill(bits, startWord + 1, endWord, -1L);
    bits[endWord] |= endmask;
  }
  
  protected int expandingWordNum(long index)
  {
    int wordNum = (int)(index >> 6);
    if (wordNum >= wlen)
    {
      ensureCapacity(index + 1L);
      wlen = (wordNum + 1);
    }
    return wordNum;
  }
  
  public void fastClear(int index)
  {
    int wordNum = index >> 6;
    int bit = index & 0x3F;
    long bitmask = 1L << bit;
    bits[wordNum] &= (bitmask ^ 0xFFFFFFFFFFFFFFFF);
  }
  
  public void fastClear(long index)
  {
    int wordNum = (int)(index >> 6);
    int bit = (int)index & 0x3F;
    long bitmask = 1L << bit;
    bits[wordNum] &= (bitmask ^ 0xFFFFFFFFFFFFFFFF);
  }
  
  public void clear(long index)
  {
    int wordNum = (int)(index >> 6);
    if (wordNum >= wlen) {
      return;
    }
    int bit = (int)index & 0x3F;
    long bitmask = 1L << bit;
    bits[wordNum] &= (bitmask ^ 0xFFFFFFFFFFFFFFFF);
  }
  
  public void clear(int startIndex, int endIndex)
  {
    if (endIndex <= startIndex) {
      return;
    }
    int startWord = startIndex >> 6;
    if (startWord >= wlen) {
      return;
    }
    int endWord = endIndex - 1 >> 6;
    
    long startmask = -1L << startIndex;
    long endmask = -1L >>> -endIndex;
    
    startmask ^= 0xFFFFFFFFFFFFFFFF;
    endmask ^= 0xFFFFFFFFFFFFFFFF;
    if (startWord == endWord)
    {
      bits[startWo
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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56

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