lucene-core-2.9.4-dev

rg.apache.lucene.analysis.tokenattributes.PayloadAttributeImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.analysis.tokenattributes;

import org.apache.lucene.util.Attribute;

public abstract interface PositionIncrementAttribute
  extends Attribute
{
  public abstract void setPositionIncrement(int paramInt);
  
  public abstract int getPositionIncrement();
}

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

import java.io.Serializable;
import org.apache.lucene.util.AttributeImpl;

public class PositionIncrementAttributeImpl
  extends AttributeImpl
  implements PositionIncrementAttribute, Cloneable, Serializable
{
  private int positionIncrement = 1;
  
  public void setPositionIncrement(int positionIncrement)
  {
    if (positionIncrement < 0) {
      throw new IllegalArgumentException("Increment must be zero or greater: " + positionIncrement);
    }
    this.positionIncrement = positionIncrement;
  }
  
  public int getPositionIncrement()
  {
    return positionIncrement;
  }
  
  public void clear()
  {
    positionIncrement = 1;
  }
  
  public boolean equals(Object other)
  {
    if (other == this) {
      return true;
    }
    if ((other instanceof PositionIncrementAttributeImpl)) {
      return positionIncrement == positionIncrement;
    }
    return false;
  }
  
  public int hashCode()
  {
    return positionIncrement;
  }
  
  public void copyTo(AttributeImpl target)
  {
    PositionIncrementAttribute t = (PositionIncrementAttribute)target;
    t.setPositionIncrement(positionIncrement);
  }
}

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

import org.apache.lucene.util.Attribute;

public abstract interface TermAttribute
  extends Attribute
{
  public abstract String term();
  
  public abstract void setTermBuffer(char[] paramArrayOfChar, int paramInt1, int paramInt2);
  
  public abstract void setTermBuffer(String paramString);
  
  public abstract void setTermBuffer(String paramString, int paramInt1, int paramInt2);
  
  public abstract char[] termBuffer();
  
  public abstract char[] resizeTermBuffer(int paramInt);
  
  public abstract int termLength();
  
  public abstract void setTermLength(int paramInt);
}

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

import java.io.Serializable;
import org.apache.lucene.util.ArrayUtil;
import org.apache.lucene.util.AttributeImpl;

public class TermAttributeImpl
  extends AttributeImpl
  implements TermAttribute, Cloneable, Serializable
{
  private static int MIN_BUFFER_SIZE = 10;
  private char[] termBuffer;
  private int termLength;
  
  public String term()
  {
    initTermBuffer();
    return new String(termBuffer, 0, termLength);
  }
  
  public void setTermBuffer(char[] buffer, int offset, int length)
  {
    growTermBuffer(length);
    System.arraycopy(buffer, offset, termBuffer, 0, length);
    termLength = length;
  }
  
  public void setTermBuffer(String buffer)
  {
    int length = buffer.length();
    growTermBuffer(length);
    buffer.getChars(0, length, termBuffer, 0);
    termLength = length;
  }
  
  public void setTermBuffer(String buffer, int offset, int length)
  {
    assert (offset <= buffer.length());
    assert (offset + length <= buffer.length());
    growTermBuffer(length);
    buffer.getChars(offset, offset + length, termBuffer, 0);
    termLength = length;
  }
  
  public char[] termBuffer()
  {
    initTermBuffer();
    return termBuffer;
  }
  
  public char[] resizeTermBuffer(int newSize)
  {
    if (termBuffer == null)
    {
      termBuffer = new char[ArrayUtil.getNextSize(newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize)];
    }
    else if (termBuffer.length < newSize)
    {
      char[] newCharBuffer = new char[ArrayUtil.getNextSize(newSize)];
      System.arraycopy(termBuffer, 0, newCharBuffer, 0, termBuffer.length);
      termBuffer = newCharBuffer;
    }
    return termBuffer;
  }
  
  private void growTermBuffer(int newSize)
  {
    if (termBuffer == null) {
      termBuffer = new char[ArrayUtil.getNextSize(newSize < MIN_BUFFER_SIZE ? MIN_BUFFER_SIZE : newSize)];
    } else if (termBuffer.length < newSize) {
      termBuffer = new char[ArrayUtil.getNextSize(newSize)];
    }
  }
  
  private void initTermBuffer()
  {
    if (termBuffer == null)
    {
      termBuffer = new char[ArrayUtil.getNextSize(MIN_BUFFER_SIZE)];
      termLength = 0;
    }
  }
  
  public int termLength()
  {
    return termLength;
  }
  
  public void setTermLength(int length)
  {
    initTermBuffer();
    if (length > termBuffer.length) {
      throw new IllegalArgumentException("length " + length + " exceeds the size of the termBuffer (" + termBuffer.length + ")");
    }
    termLength = length;
  }
  
  public int hashCode()
  {
    initTermBuffer();
    int code = termLength;
    code = code * 31 + ArrayUtil.hashCode(termBuffer, 0, termLength);
    return code;
  }
  
  public void clear()
  {
    termLength = 0;
  }
  
  public Object clone()
  {
    TermAttributeImpl t = (TermAttributeImpl)super.clone();
    if (termBuffer != null)
    {
      termBuffer = new char[termLength];
      System.arraycopy(termBuffer, 0, termBuffer, 0, termLength);
    }
    return t;
  }
  
  public boolean equals(Object other)
  {
    if (other == this) {
      return true;
    }
    if ((other instanceof TermAttribute))
    {
      initTermBuffer();
      TermAttributeImpl o = (TermAttributeImpl)other;
      o.initTermBuffer();
      if (termLength != termLength) {
        return false;
      }
      for (int i = 0; i < termLength; i++) {
        if (termBuffer[i] != termBuffer[i]) {
          return false;
        }
      }
      return true;
    }
    return false;
  }
  
  public String toString()
  {
    initTermBuffer();
    return "term=" + new String(termBuffer, 0, termLength);
  }
  
  public void copyTo(AttributeImpl target)
  {
    initTermBuffer();
    TermAttribute t = (TermAttribute)target;
    t.setTermBuffer(termBuffer, 0, termLength);
  }
}

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

import org.apache.lucene.util.Attribute;

public abstract interface TypeAttribute
  extends Attribute
{
  public abstract String type();
  
  public abstract void setType(String paramString);
}

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

import java.io.Serializable;
import org.apache.lucene.util.AttributeImpl;

public class TypeAttributeImpl
  extends AttributeImpl
  implements TypeAttribute, Cloneable, Serializable
{
  private String type;
  public static final String DEFAULT_TYPE = "word";
  
  public TypeAttributeImpl()
  {
    this("word");
  }
  
  public TypeAttributeImpl(String type)
  {
    this.type = type;
  }
  
  public String type()
  {
    return type;
  }
  
  public void setType(String type)
  {
    this.type = type;
  }
  
  public void clear()
  {
    type = "word";
  }
  
  public boolean equals(Object other)
  {
    if (other == this) {
      return true;
    }
    if ((other instanceof TypeAttributeImpl)) {
      return type.equals(type);
    }
    return false;
  }
  
  public int hashCode()
  {
    return type.hashCode();
  }
  
  public void copyTo(AttributeImpl target)
  {
    TypeAttribute t = (TypeAttribute)target;
    t.setType(type);
  }
}

/* Location:
 * Qualified Name:     org.apache.lucene.analysis.tokenattributes.TypeAttributeImpl
 * Java Class Version: 1.4 (48.0)
 * JD-Core Version:    0.7.1
 */
package org.apache.lucene.document;

import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.util.StringHelper;

public abstract class AbstractField
  implements Fieldable
{
  protected String name = "body";
  protected boolean storeTermVector = false;
  protected boolean storeOffsetWithTermVector = false;
  protected boolean storePositionWithTermVector = false;
  protected boolean omitNorms = false;
  protected boolean isStored = false;
  protected boolean isIndexed = true;
  protected boolean isTokenized = true;
  protected boolean isBinary = false;
  protected boolean isCompressed = false;
  protected boolean lazy = false;
  protected boolean omitTermFreqAndPositions = false;
  protected float boost = 1.0F;
  protected Object fieldsData = null;
  protected TokenStream tokenStream;
  protected int binaryLength;
  protected int binaryOffset;
  
  protected AbstractField() {}
  
  protected AbstractField(String name, Field.Store store, Field.Index index, Field.TermVector termVector)
  {
    if (name == null) {
      throw new NullPointerException("name cannot be null");
    }
    this.name = StringHelper.intern(name);
    if (store == Field.Store.YES)
    {
      isStored = true;
      isCompressed = false;
    }
    else if (store == Field.Store.COMPRESS)
    {
      isStored = true;
      isCompressed = true;
    }
    else if (store == Field.Store.NO)
    {
      isStored = false;
      isCompressed = false;
    }
    else
    {
      throw new IllegalArgumentException("unknown store parameter " + store);
    }
    if (index == Field.Index.NO)
    {
      isIndexed = false;
      isTokenized = false;
    }
    else if (index == Field.Index.ANALYZED)
    {
      isIndexed = true;
      isTokenized = true;
    }
    else if (index == Field.Index.NOT_ANALYZED)
    {
      isIndexed = true;
      isTokenized = false;
    }
    else if (index == Field.Index.NOT_ANALYZED_NO_NORMS)
    {
      isIndexed = true;
      isTokenized = false;
      omitNorms = true;
    }
    else if (index == Field.Index.ANALYZED_NO_NORMS)
    {
      isIndexed = true;
      isTokenized = true;
      omitNorms = true;
    }
    else
    {
      throw new IllegalArgumentException("unknown index parameter " + index);
    }
    isBinary = false;
    
    setStoreTermVector(termVector);
  }
  
  public void setBoost(float boost)
  {
    this.boost = boost;
  }
  
  public float getBoost()
  {
    return boost;
  }
  
  public String name()
  {
    return name;
  }
  
  protected void setStoreTermVector(Field.TermVector termVector)
  {
    if (termVector == Field.TermVector.NO)
    {
      storeTermVector = false;
      storePositionWithTermVector = false;
      storeOffsetWithTermVector = false;
    }
    else if (termVector == Field.TermVector.YES)
    {
      storeTermVector = true;
      storePositionWithTermVector = false;
      storeOffsetWithTermVector = false;
    }
    else if (termVector == Field.TermVector.WITH_POSITIONS)
    {
      storeTermVector = true;
      storePositionWithTermVector = true;
      storeOffsetWithTermVector = false;
    }
    else if (termVector == Field.TermVector.WITH_OFFSETS)
    {
      storeTermVector = true;
      storePositionWithTermVector = false;
      storeOffsetWithTermVector = true;
    }
    else if (termVector == Field.TermVector.WITH_POSITIONS_OFFSETS)
    {
      storeTermVector = true;
      storePositionWithTermVector = true;
      storeOffsetWithTermVector = true;
    }
    else
    {
      throw new IllegalArgumentException("unknown termVector parameter " + termVector);
    }
  }
  
  public final boolean isStored()
  {
    return isStored;
  }
  
  public final boolean isIndexed()
  {
    return isIndexed;
  }
  
  public final boolean isTokenized()
  {
    return isTokenized;
  }
  
  public final boolean isCompressed()
  {
    return isCompressed;
  }
  
  public final boolean isTermVectorStored()
  {
    return storeTermVector;
  }
  
  public boolean isStoreOffsetWithTermVector()
  {
    return storeOffsetWithTermVector;
  }
  
  public boolean isStorePositionWithTermVector()
  {
    return storePositionWithTermVector;
  }
  
  public final boolean isBinary()
  {
    return isBinary;
  }
  
  public byte[] getBinaryValue()
  {
    return getBinaryValue(null);
  }
  
  public byte[] getBinaryValue(byte[] result)
  {
    if ((isBinary) || ((fieldsData instanceof byte[]))) {
      return (byte[])fieldsData;
    }
    return null;
  }
  
  public int getBinaryLength()
  {
    if (isBinary)
    {
      if (!isCompressed) {
        return binaryLength;
      }
      return ((byte[])fieldsData).length;
    }
    if ((fieldsData instanceof byte[])) {
      return ((byte[])fieldsData).length;
    }
    return 0;
  }
  
  public int getBinaryOffset()
  {
    return binaryOffset;
  }
  
  public boolean getOmitNorms()
  {
    return omitNorms;
  }
  
  /**
   * @deprecated
   */
  public boolean getOmitTf()
  {
    return omitTermFreqAndPositions;
  }
  
  public boolean getOmitTermFreqAndPositions()
  {
    return omitTermFreqAndPositions;
  }
  
  public void setOmitNorms(boolean omitNorms)
  {
    this.omitNorms = omitNorms;
  }
  
  /**
   * @deprecated
   */
  public void setOmitTf(boolean omitTermFreqAndPositions)
  {
    this.omitTermFreqAndPositions = omitTermFreqAndPositions;
  }
  
  public void setOmitTermFreqAndPositions(boolean omitTermFreqAndPositions)
  {
    this.omitTermFreqAndPositions = omitTermFreqAndPositions;
  }
  
  public boolean isLazy()
  {
    return lazy;
  }
  
  public final String toString()
  {
    StringBuffer result = new StringBuffer();
    if (isStored)
    {
      result.append("stored");
      if (isCompressed) {
        result.append("/compressed");
      } else {
        result.append("/uncompressed");
      }
    }
    if (isIndexed)
    {
      if (result.length() > 0) {
        result.append(",");
      }
      result.append("indexed");
    }
    if (isTokenized)
    {
      if (result.length() > 0) {
        result.append(",");
      }
      result.append("tokenized");
    }
    if (storeTermVector)
    {
      if (result.length() > 0) {
        result.append(",");
      }
      result.append("termVector");
    }
    if (storeOffsetWithTermVector)
    {
      if (result.length() > 0) {
        result.append(",");
      }
      result.append("termVectorOffsets");
    }
    if (storePositionWithTermVector)
    {
      if (result.length() > 0) {
        result.append(",");
      }
      result.append("termVectorPosition");
    }
    if (isBinary)
    {
      if (result.length() > 0) {
        result.append(",");
      }
      result.append("binary");
    }
    if (omitNorms) {
      result.append(",omitNorms");
    }
    if (omitTermFreqAndPositions) {
      result.append(",omitTermFreqAndPositions");
    }
    if (lazy) {
      result.append(",lazy");
    }
    result.append('<');
    result.append(name);
    result.append(':');
    if ((fieldsData != null) && (!lazy)) {
      result.append(fieldsData);
    }
    result.append('>');
    return result.toString();
  }
}

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

import java.io.ByteArrayOutputStream;
import java.util.zip.DataFormatException;
import java.util.zip.Deflater;
import java.util.zip.Inflater;
import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util.UnicodeUtil.UTF16Result;
import org.apache.lucene.util.UnicodeUtil.UTF8Result;

public class CompressionTools
{
  public static byte[] compress(byte[] value, int offset, int length, int compressionLevel)
  {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
    
    Deflater compressor = new Deflater();
    try
    {
      compressor.setLevel(compressionLevel);
      compressor.setInput(value, offset, length);
      compressor.finish();
      
      byte[] buf = new byte['?'];
      while (!compressor.finished())
      {
        int count = compressor.deflate(buf);
        bos.write(buf, 0, count);
      }
    }
    finally
    {
      compressor.end();
    }
    return bos.toByteArray();
  }
  
  public static byte[] compress(byte[] value, int offset, int length)
  {
    return compress(value, offset, length, 9);
  }
  
  public static byte[] compress(byte[] value)
  {
    return compress(value, 0, value.length, 9);
  }
  
  public static byte[] compressString(String value)
  {
    return compressString(value, 9);
  }
  
  public static byte[] compressString(String value, int compressionLevel)
  {
    UnicodeUtil.UTF8Result result = new UnicodeUtil.UTF8Result();
    UnicodeUtil.UTF16toUTF8(value, 0, value.length(), result);
    return compress(result, 0, length, compressionLevel);
  }
  
  public static byte[] decompress(byte[] value)
    throws DataFormatException
  {
    ByteArrayOutputStream bos = new ByteArrayOutputStream(value.length);
    
    Inflater decompressor = new Inflater();
    try
    {
      decompressor.setInput(value);
      
      byte[] buf = new byte['?'];
      while (!decompressor.finished())
      {
        int count = decompressor.inflate(buf);
        bos.write(buf, 0, count);
      }
    }
    finally
    {
      decompressor.end();
    }
    return bos.toByteArray();
  }
  
  public static String decompressString(byte[] value)
    throws DataFormatException
  {
    UnicodeUtil.UTF16Result result = new UnicodeUtil.UTF16Result();
    byte[] bytes = decompress(value);
    UnicodeUtil.UTF8toUTF16(bytes, 0, bytes.length, result);
    return new String(result, 0, length);
  }
}

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

import java.util.Date;

/**
 * @deprecated
 */
public class DateField
{
  private static int DATE_LEN = Long.toString(31536000000000L, 36).length();
  
  public static String MIN_DATE_STRING()
  {
    return timeToString(0L);
  }
  
  public static String MAX_DATE_STRING()
  {
    char[] buffer = new char[DATE_LEN];
    char c = Character.forDigit(35, 36);
    for (int i = 0; i < DATE_LEN; i++) {
      buffer[i] = c;
    }
    return new String(buffer);
  }
  
  public static String dateToString(Date date)
  {
    return timeToString(date.getTime());
  }
  
  public static String timeToString(long time)
  {
    if (time < 0L) {
      throw new RuntimeException("time '" + time + "' is too early, must be >= 0");
    }
    String s = Long.toString(time, 36);
    if (s.length() > DATE_LEN) {
      throw new RuntimeException("time '" + time + "' is too late, length of string " + "representation must be <= " + DATE_LEN);
    }
    if (s.length() < DATE_LEN)
    {
      StringBuffer sb = new StringBuffer(s);
      while (sb.length() < DATE_LEN) {
        sb.insert(0, 0);
      }
      s = sb.toString();
    }
    return s;
  }
  
  public static long stringToTime(String s)
  {
    return Long.parseLong(s, 36);
  }
  
  public static Date stringToDate(String s)
  {
    return new Date(stringToTime(s));
  }
}

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

public class DateTools$Resolution
{
  public static final Resolution YEAR = new Resolution("year");
  public static final Resolution MONTH = new Resolution("month");
  public static final Resolution DAY = new Resolution("day");
  public static final Resolution HOUR = new Resolution("hour");
  public static final Resolution MINUTE = new Resolution("minute");
  public static final Resolution SECOND = new Resolution("second");
  public static final Resolution MILLISECOND = new Resolution("millisecond");
  private String resolution;
  
  private DateTools$Resolution() {}
  
  private DateTools$Resolution(String resolution)
  {
    this.resolution = resolution;
  }
  
  public String toString()
  {
    return resolution;
  }
}

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

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class DateTools
{
  private static final TimeZone GMT = TimeZone.getTimeZone("GMT");
  private static final SimpleDateFormat YEAR_FORMAT = new SimpleDateFormat("yyyy", Locale.US);
  private static final SimpleDateFormat MONTH_FORMAT = new SimpleDateFormat("yyyyMM", Locale.US);
  private static final SimpleDateFormat DAY_FORMAT = new SimpleDateFormat("yyyyMMdd", Locale.US);
  private static final SimpleDateFormat HOUR_FORMAT = new SimpleDateFormat("yyyyMMddHH", Locale.US);
  private static final SimpleDateFormat MINUTE_FORMAT = new SimpleDateFormat("yyyyMMddHHmm", Locale.US);
  private static final SimpleDateFormat SECOND_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US);
  private static final SimpleDateFormat MILLISECOND_FORMAT = new SimpleDateFormat("yyyyMMddHHmmssSSS", Locale.US);
  
  static
  {
    YEAR_FORMAT.setTimeZone(GMT);
    MONTH_FORMAT.setTimeZone(GMT);
    DAY_FORMAT.setTimeZone(GMT);
    HOUR_FORMAT.setTimeZone(GMT);
    MINUTE_FORMAT.setTimeZone(GMT);
    SECOND_FORMAT.setTimeZone(GMT);
    MILLISECOND_FORMAT.setTimeZone(GMT);
  }
  
  private static final Calendar calInstance = Calendar.getInstance(GMT);
  
  public static synchronized String dateToString(Date date, Resolution resolution)
  {
    return timeToString(date.getTime(), resolution);
  }
  
  public static synchronized String timeToString(long time, Resolution resolution)
  {
    calInstance.setTimeInMillis(round(time, resolution));
    Date date = calInstance.getTime();
    if (resolution == Resolution.YEAR) {
      return YEAR_FORMAT.format(date);
    }
    if (resolution == Resolution.MONTH) {
      return MONTH_FORMAT.format(date);
    }
    if (resolution == Resolution.DAY) {
      return DAY_FORMAT.format(date);
    }
    if (resolution == Resolution.HOUR) {
      return HOUR_FORMAT.format(date);
    }
    if (resolution == Resolution.MINUTE) {
      return MINUTE_FORMAT.format(date);
    }
    if (resolution == Resolution.SECOND) {
      return SECOND_FORMAT.format(date);
    }
    if (resolution == Resolution.MILLISECOND) {
      return MILLISECOND_FORMAT.format(date);
    }
    throw new IllegalArgumentException("unknown resolution " + resolution);
  }
  
  public static synchronized long stringToTime(String dateString)
    throws ParseException
  {
    return stringToDate(dateString).getTime();
  }
  
  public static synchronized Date stringToDate(String dateString)
    throws ParseException
  {
    if (dateString.length() == 4) {
      return YEAR_FORMAT.parse(dateString);
    }
    if (dateString.length() == 6) {
      return MONTH_FORMAT.parse(dateString);
    }
    if (dateString.length() == 8) {
      return DAY_FORMAT.parse(dateString);
    }
    if (dateString.length() == 10) {
      return HOUR_FORMAT.parse(dateString);
    }
    if (dateString.length() == 12) {
      return MINUTE_FORMAT.parse(dateString);
    }
    if (dateString.length() == 14) {
      return SECOND_FORMAT.parse(dateString);
    }
    if (dateString.length() == 17) {
      return MILLISECOND_FORMAT.parse(dateString);
    }
    throw new ParseException("Input is not valid date string: " + dateString, 0);
  }
  
  public static synchronized Date round(Date date, Resolution resolution)
  {
    return new Date(round(date.getTime(), resolution));
  }
  
  public static synchronized long round(long time, Resolution resolution)
  {
    calInstance.setTimeInMillis(time);
    if (resolution == Resolution.YEAR)
    {
      calInstance.set(2, 0);
      calInstance.set(5, 1);
      calInstance.set(11, 0);
      calInstance.set(12, 0);
      calInstance.set(13, 0);
      calInstance.set(14, 0);
    }
    else if (resolution == Resolution.MONTH)
    {
      calInstance.set(5, 1);
      calInstance.set(11, 0);
      calInstance.set(12, 0);
      calInstance.set(13, 0);
      calInstance.set(14, 0);
    }
    else if (resolution == Resolution.DAY)
    {
      calInstance.set(11, 0);
      calInstance.set(12, 0);
      calInstance.set(13, 0);
      calInstance.set(14, 0);
    }
    else if (resolution == Resolution.HOUR)
    {
      calInstance.set(12, 0);
      calInstance.set(13, 0);
      calInstance.set(14, 0);
    }
    else if (resolution == Resolution.MINUTE)
    {
      calInstance.set(13, 0);
      calInstance.set(14, 0);
    }
    else if (resolution == Resolution.SECOND)
    {
      calInstance.set(14, 0);
    }
    else if (resolution != Resolution.MILLISECOND)
    {
      throw new IllegalArgumentException("unknown resolution " + resolution);
    }
    return calInstance.getTimeInMillis();
  }
  
  public static class Resolution
  {
    public static final Resolution YEAR = new Resolution("year");
    public static final Resolution MONTH = new Resolution("month");
    public static final Resolution DAY = new Resolution("day");
    public static final Resolution HOUR = new Resolution("hour");
    public static final Resolution MINUTE = new Resolution("minute");
    public static final Resolution SECOND = new Resolution("second");
    public static final Resolution MILLISECOND = new Resolution("millisecond");
    private String resolution;
    
    private Resolution() {}
    
    private Resolution(String resolution)
    {
      this.resolution = resolution;
    }
    
    public String toString()
    {
      return resolution;
    }
  }
}

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

import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;

class Document$1
  implements Enumeration
{
  final Iterator iter = this$0.fields.iterator();
  private final Document this$0;
  
  Document$1(Document paramDocument) {}
  
  public boolean hasMoreElements()
  {
    return iter.hasNext();
  }
  
  public Object nextElement()
  {
    return iter.next();
  }
}

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

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;

public final class Document
  implements Serializable
{
  List fields = new ArrayList();
  private float boost = 1.0F;
  
  public void setBoost(float boost)
  {
    this.boost = boost;
  }
  
  public float getBoost()
  {
    return boost;
  }
  
  public final void add(Fieldable field)
  {
    fields.add(field);
  }
  
  public final void removeField(String name)
  {
    Iterator it = fields.iterator();
    while (it.hasNext())
    {
      Fieldable field = (Fieldable)it.next();
      if (field.name().equals(name))
      {
        it.remove();
        return;
      }
    }
  }
  
  public final void removeFields(String name)
  {
    Iterator it = fields.iterator();
    while (it.hasNext())
    {
      Fieldable field = (Fieldable)it.next();
      if (field.name().equals(name)) {
        it.remove();
      }
    }
  }
  
  public final Field getField(String name)
  {
    for (int i = 0; i < fields.size(); i++)
    {
      Field field = (Field)fields.get(i);
      if (field.name().equals(name)) {
        return field;
      }
    }
    return null;
  }
  
  public Fieldable getFieldable(String name)
  {
    for (int i = 0; i < fields.size(); i++)
    {
      Fieldable field = (Fieldable)fields.get(i);
      if (field.name().equals(name)) {
        return field;
      }
    }
    return null;
  }
  
  public final String get(String name)
  {
    for (int i = 0; i < fields.size(); i++)
    {
      Fieldable field = (Fieldable)fields.get(i);
      if ((field.name().equals(name)) && (!field.isBinary())) {
        return field.stringValue();
      }
    }
    return null;
  }
  
  /**
   * @deprecated
   */
  public final Enumeration fields()
  {
    new Enumeration()
    {
      final Iterator iter = fields.iterator();
      
      public boolean hasMoreElements()
      {
        return iter.hasNext();
      }
      
      public Object nextElement()
      {
        return iter.next();
      }
    };
  }
  
  public final List getFields()
  {
    return fields;
  }
  
  private static final Field[] NO_FIELDS = new Field[0];
  
  public final Field[] getFields(String name)
  {
    List result = new ArrayList();
    for (int i = 0; i < fields.size(); i++)
    {
      Field field = (Field)fields.get(i);
      if (field.name().equals(name)) {
        result.add(field);
      }
    }
    if (result.size() == 0) {
      return NO_FIELDS;
    }
    return (Field[])result.toArray(new Field[result.size()]);
  }
  
  private static final Fieldable[] NO_FIELDABLES = new Fieldable[0];
  
  public Fieldable[] getFieldables(String name)
  {
    List result = new ArrayList();
    for (int i = 0; i < fields.size(); i++)
    {
      Fieldable field = (Fieldable)fields.get(i);
      if (field.name().equals(name)) {
        result.add(field);
      }
    }
    if (result.size() == 0) {
      return NO_FIELDABLES;
    }
    return (Fieldable[])result.toArray(new Fieldable[result.size()]);
  }
  
  private static final String[] NO_STRINGS = new String[0];
  
  public final String[] getValues(String name)
  {
    List result = new ArrayList();
    for (int i = 0; i < fields.size(); i++)
    {
      Fieldable field = (Fieldable)fields.get(i);
      if ((field.name().equals(name)) && (!field.isBinary())) {
        result.add(field.stringValue());
      }
    }
    if (result.size() == 0) {
      return NO_STRINGS;
    }
    return (String[])result.toArray(new String[result.size()]);
  }
  
  private static final byte[][] NO_BYTES = new byte[0][];
  
  public final byte[][] getBinaryValues(String name)
  {
    List result = new ArrayList();
    for (int i = 0; i < fields.size(); i++)
    {
      Fieldable field = (Fieldable)fields.get(i);
      if ((field.name().equals(name)) && (field.isBinary())) {
        result.add(field.binaryValue());
      }
    }
    if (result.size() == 0) {
      return NO_BYTES;
    }
    return (byte[][])result.toArray(new byte[result.size()][]);
  }
  
  public final byte[] getBinaryValue(String name)
  {
    for (int i = 0; i < fields.size(); i++)
    {
      Fieldable field = (Fieldable)fields.get(i);
      if ((field.name().equals(name)) && (field.isBinary())) {
        return field.binaryValue();
      }
    }
    return null;
  }
  
  public final String toString()
  {
    StringBuffer buffer = new StringBuffer();
    buffer.append("Document<");
    for (int i = 0; i < fields.size(); i++)
    {
      Fieldable field = (Fieldable)fields.get(i);
      buffer.append(field.toString());
      if (i != fields.size() - 1) {
        buffer.append(" ");
      }
    }
    buffer.append(">");
    return buffer.toString();
  }
}

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

import java.io.Serializable;
import org.apache.lucene.util.Parameter;

public final class Field$Index
  extends Parameter
  implements Serializable
{
  private Field$Index(String name)
  {
    super(name);
  }
  
  public static final Index NO = new Index("NO");
  public static final Index ANALYZED = new Index("ANALYZED");
  /**
   * @deprecated
   */
  public static final Index TOKENIZED = ANALYZED;
  public static final Index NOT_ANALYZED = new Index("NOT_ANALYZED");
  /**
   * @deprecated
   */
  public static final Index UN_TOKENIZED = NOT_ANALYZED;
  public static final Index NOT_ANALYZED_NO_NORMS = new Index("NOT_ANALYZED_NO_NORMS");
  /**
   * @deprecated
   */
  public static final Index NO_NORMS = NOT_ANALYZED_NO_NORMS;
  public static final Index ANALYZED_NO_NORMS = new Index("ANALYZED_NO_NORMS");
}

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

import java.io.Serializable;
import org.apache.lucene.util.Parameter;

public final class Field$Store
  extends Parameter
  implements Serializable
{
  private Field$Store(String name)
  {
    super(name);
  }
  
  /**
   * @deprecated
   */
  public static final Store COMPRESS = new Store("COMPRESS");
  public static final Store YES = new Store("YES");
  public static final Store NO = new Store("NO");
}

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

import java.io.Serializable;
import org.apache.lucene.util.Parameter;

public final class Field$TermVector
  extends Parameter
  implements Serializable
{
  private Field$TermVector(String name)
  {
    super(name);
  }
  
  public static final TermVector NO = new TermVector("NO");
  public static final TermVector YES = new TermVector("YES");
  public static final TermVector WITH_POSITIONS = new TermVector("WITH_POSITIONS");
  public static final TermVector WITH_OFFSETS = new TermVector("WITH_OFFSETS");
  public static final TermVector WITH_POSITIONS_OFFSETS = new TermVector("WITH_POSITIONS_OFFSETS");
}

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

import java.io.Reader;
import java.io.Serializable;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.util.Parameter;
import org.apache.lucene.util.StringHelper;

public final class Field
  extends AbstractField
  implements Fieldable, Serializable
{
  public static final class Store
    extends Parameter
    implements Serializable
  {
    private Store(String name)
    {
      super();
    }
    
    /**
     * @deprecated
     */
    public static final Store COMPRESS = new Store("COMPRESS");
    public static final Store YES = new Store("YES");
    public static final Store NO = new Store("NO");
  }
  
  public static final class Index
    extends Parameter
    implements Serializable
  {
    private Index(String name)
    {
      super();
    }
    
    public static final Index NO = new Index("NO");
    public static final Index ANALYZED = new Index("ANALYZED");
    /**
     * @deprecated
     */
    public static final Index TOKENIZED = ANALYZED;
    public static final Index NOT_ANALYZED = new Index("NOT_ANALYZED");
    /**
     * @deprecated
     */
    public static final Index UN_TOKENIZED = NOT_ANALYZED;
    public static final Index NOT_ANALYZED_NO_NORMS = new Index("NOT_ANALYZED_NO_NORMS");
    /**
     * @deprecated
     */
    public static final Index NO_NORMS = NOT_ANALYZED_NO_NORMS;
    public static final Index ANALYZED_NO_NORMS = new Index("ANALYZED_NO_NORMS");
  }
  
  public static final class TermVector
    extends Parameter
    implements Serializable
  {
    private TermVector(String name)
    {
      super();
    }
    
    public static final TermVector NO = new TermVector("NO");
    public static final TermVector YES = new TermVector("YES");
    public static final TermVector WITH_POSITIONS = new TermVector("WITH_POSITIONS");
    public static final TermVector WITH_OFFSETS = new TermVector("WITH_OFFSETS");
    public static final TermVector WITH_POSITIONS_OFFSETS = new TermVector("WITH_POSITIONS_OFFSETS");
  }
  
  public String stringValue()
  {
    return (fieldsData instanceof String) ? (String)fieldsData : null;
  }
  
  public Reader readerValue()
  {
    return (fieldsData instanceof Reader) ? (Reader)fieldsData : null;
  }
  
  /**
   * @deprecated
   */
  public byte[] binaryValue()
  {
    if (!isBinary) {
      return null;
    }
    byte[] data = (byte[])fieldsData;
    if ((binaryOffset == 0) && (data.length == binaryLength)) {
      return data;
    }
    byte[] ret = new byte[binaryLength];
    System.arraycopy(data, binaryOffset, ret, 0, binaryLength);
    return ret;
  }
  
  public TokenStream tokenStreamValue()
  {
    return tokenStream;
  }
  
  public void setValue(String value)
  {
    if (isBinary) {
      throw new IllegalArgumentException("cannot set a String value on a binary field");
    }
    fieldsData = value;
  }
  
  public void setValue(Reader value)
  {
    if (isBinary) {
      throw new IllegalArgumentException("cannot set a Reader value on a binary field");
    }
    if (isStored) {
      throw new IllegalArgumentException("cannot set a Reader value on a stored field");
    }
    fieldsData = value;
  }
  
  public void setValue(byte[] value)
  {
    if (!isBinary) {
      throw new IllegalArgumentException("cannot set a byte[] value on a non-binary field");
    }
    fieldsData = value;
    binaryLength = value.length;
    binaryOffset = 0;
  }
  
  public void setValue(byte[] value, int offset, int length)
  {
    if (!isBinary) {
      throw new IllegalArgumentException("cannot set a byte[] value on a non-binary field");
    }
    fieldsData = value;
    binaryLength = length;
    binaryOffset = offset;
  }
  
  /**
   * @deprecated
   */
  public void setValue(TokenStream value)
  {
    if (isBinary) {
      throw new IllegalArgumentException("cannot set a TokenStream value on a binary field");
    }
    if (isStored) {
      throw new IllegalArgumentException("cannot set a TokenStream value on a stored field");
    }
    fieldsData = null;
    tokenStream = value;
  }
  
  public void setTokenStream(TokenStream tokenStream)
  {
    isIndexed = true;
    isTokenized = true;
    this.tokenStream = tokenStream;
  }
  
  public Field(String name, String value, Store store, Index index)
  {
    this(name, value, store, index, TermVector.NO);
  }
  
  public Field(String name, String value, Store store, Index index, TermVector termVector)
  {
    this(name, true, value, store, index, termVector);
  }
  
  public Field(String name, boolean internName, String value, Store store, Index index, TermVector termVector)
  {
    if (name == null) {
      throw new NullPointerException("name cannot be null");
    }
    if (value == null) {
      throw new NullPointerException("value cannot be null");
    }
    if ((name.length() == 0) && (value.length() == 0)) {
      throw new IllegalArgumentException("name and value cannot both be empty");
    }
    if ((index == Index.NO) && (store == Store.NO)) {
      throw new IllegalArgumentException("it doesn't make sense to have a field that is neither indexed nor stored");
    }
    if ((index == Index.NO) && (termVector != TermVector.NO)) {
      throw new IllegalArgumentException("cannot store term vector information for a field that is not indexed");
    }
    if (internName) {
      name = StringHelper.intern(name);
    }
    this.name = name;
    
    fieldsData = value;
    if (store == Store.YES)
    {
      isStored = true;
      isCompressed = false;
    }
    else if (store == Store.COMPRESS)
    {
      isStored = true;
      isCompressed = true;
    }
    else if (store == Store.NO)
    {
      isStored = false;
      isCompressed = false;
    }
    else
    {
      throw new IllegalArgumentException("unknown store parameter " + store);
    }
    if (index == Index.NO)
    {
      isIndexed = false;
      isTokenized = false;
      omitTermFreqAndPositions = false;
      omitNorms = true;
    }
    else if (index == Index.A
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