Xindice API
version 1.2m1

org.apache.xindice.core.data
Class Value

java.lang.Object
  extended byorg.apache.xindice.core.data.Value
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
Key

public class Value
extends Object
implements Comparable

Value is the primary base class for all data storing objects. The content window of value objects are immutable, but the underlying byte array which was used for constructing the value might be not.

Version:
$Revision: 594315 $, $Date: 2007-11-12 17:10:44 -0500 (Mon, 12 Nov 2007) $

Constructor Summary
Value(byte[] data)
           
Value(byte[] data, int pos, int len)
           
Value(String data)
           
Value(Value value)
          Usually there is no need to create a copy of the value, since it is an immutable object.
 
Method Summary
 byte byteAt(int index)
          Returns the byte at the specified index.
 int compareTo(Object obj)
           
 int compareTo(Value value)
           
 void copyTo(byte[] tdata, int tpos)
          Copy contents of the value into supplied byte array.
 void copyTo(byte[] tdata, int tpos, int len)
          Copy len bytes of value's content into supplied byte array.
 boolean equals(Object obj)
           
 boolean equals(Value value)
           
 byte[] getData()
          getData retrieves a copy of the data which is being stored by this value as a byte array.
 InputStream getInputStream()
          Return an InputStream for the value.
 int getLength()
          getLength retrieves the length of the data being stored by the Value.
 int hashCode()
           
 int intAt(int index)
          Returns the int value at the specified index.
 Key keyAt(int start, int len)
          Get a key that is part of this value object.
 short shortAt(int index)
          Returns the short value at the specified index.
 boolean startsWith(Value value)
           
 void streamTo(OutputStream out)
          Stream the content of the value into an OutputStream.
 String toString()
           
 Value valueAt(int start, int len)
          Get a value that is part of this value object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Value

public Value(Value value)
Usually there is no need to create a copy of the value, since it is an immutable object. This constructor is mainly used to create key objects.

Parameters:
value - the value object which data will be used to construct this value.

Value

public Value(byte[] data)

Value

public Value(byte[] data,
             int pos,
             int len)

Value

public Value(String data)
Method Detail

getLength

public final int getLength()
getLength retrieves the length of the data being stored by the Value.

Returns:
The Value length

getData

public final byte[] getData()
getData retrieves a copy of the data which is being stored by this value as a byte array.

Data copying is performed in order to ensure immutability of the Value. Avoid using this method if possible.

Returns:
The data

byteAt

public final byte byteAt(int index)
Returns the byte at the specified index.

Parameters:
index - byte index
Returns:
the byte at the specified index.
Throws:
ArrayIndexOutOfBoundsException - if index is negative number or is not less that the length of Value data

shortAt

public final short shortAt(int index)
Returns the short value at the specified index.

Parameters:
index - short index
Returns:
the short at the specified index.
Throws:
ArrayIndexOutOfBoundsException - if index is negative number or is not less that the length of the data array

intAt

public final int intAt(int index)
Returns the int value at the specified index.

Parameters:
index - int index
Returns:
the int at the specified index.
Throws:
ArrayIndexOutOfBoundsException - if index is negative number or is not less that the length of the data array

valueAt

public final Value valueAt(int start,
                           int len)
Get a value that is part of this value object.

Parameters:
start - beginning index
len - length of the new value
Returns:
Value object
Throws:
ArrayIndexOutOfBoundsException - if start index is either negative or isn't less then length of original Value

keyAt

public final Key keyAt(int start,
                       int len)
Get a key that is part of this value object.

Parameters:
start - beginning index
len - length of the new key
Returns:
Key object
Throws:
ArrayIndexOutOfBoundsException - if start index is either negative or isn't less then length of original Value

getInputStream

public final InputStream getInputStream()
Return an InputStream for the value.

Returns:
An InputStream

streamTo

public final void streamTo(OutputStream out)
                    throws IOException
Stream the content of the value into an OutputStream.

Parameters:
out - the OutputStream
Throws:
IOException - if write failed

copyTo

public final void copyTo(byte[] tdata,
                         int tpos)
Copy contents of the value into supplied byte array.

Parameters:
tdata - byte array for the value
tpos - starting position

copyTo

public final void copyTo(byte[] tdata,
                         int tpos,
                         int len)
Copy len bytes of value's content into supplied byte array.

Parameters:
tdata - byte array for the value
tpos - starting position
len - count of bytes to copy

startsWith

public final boolean startsWith(Value value)

compareTo

public final int compareTo(Value value)

compareTo

public final int compareTo(Object obj)
Specified by:
compareTo in interface Comparable

hashCode

public int hashCode()

equals

public boolean equals(Value value)

equals

public boolean equals(Object obj)

toString

public final String toString()

Xindice API
version 1.2m1

Copyright (c) 1999-2007 The Apache Software Foundation. All Rights Reserved.