Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.javathis.utilities.pagedArray
Class PagedElement  view PagedElement download PagedElement.java

java.lang.Object
  extended bycom.javathis.utilities.pagedArray.PagedElement
All Implemented Interfaces:
java.lang.Cloneable

public class PagedElement
extends java.lang.Object
implements java.lang.Cloneable

A PagedElement contains copies of corresponding element in a JTPagedArray.

An element is a structured list of at least one field. Each field holds a numberic value. Each field is expressed by a FieldDetails object. An ElementDetails object holds the FieldDetails objects.


Field Summary
protected static int BITS_IN_A_BYTE
           
private  byte[] bytes
           
private  ElementDetails details
           
protected static int END_OF_BYTE
           
private  int[] fieldOffsets
           
private  int[] fieldTypes
           
private static java.util.ResourceBundle MAIN_RESOURCE_BUNDLE
           
private  int numberOfBytes
           
protected static int[] TYPE_SIZES
           
 
Constructor Summary
  PagedElement()
          Creates an empty PagedElement.
  PagedElement(ElementDetails elementDetails)
          Creates a PagedElement and copies all the values contained in the provided ElementDetails.
  PagedElement(JTPagedArray pagedArray)
          Creates a PagedElement and copies all the values contained in the provided JTPagedArray's ElementDetails.
protected PagedElement(PagedElement pagedElement)
          Creates a PagedElement and copies all the values contained in the provided PagedElement.
 
Method Summary
 java.lang.Object clone()
          This method may be called to create a new copy of the Object.
 void destroy()
           
 boolean equals(java.lang.Object object)
          Delegates to equals(PagedElement) 55
 boolean equals(PagedElement pagedElement)
          Checks every byte in the internal byte array and verifies the ElementDetails using ElementDetails.equals(ElementDetails) 55 method.
protected  void finalize()
          Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed.
 byte getByte(int fieldIndex)
          Returns the byte value for the selected field.
protected  byte[] getBytes()
          Returns a refernce to the internal byte array.
 byte[] getBytesCopy()
          Returns a copy of the internal bytes array.
 ElementDetails getDetails()
          Returns a reference to the internal ElementDetails.
 double getDouble(int fieldIndex)
          Returns the double value for the selected field.
 float getFloat(int fieldIndex)
          Returns the float value for the selected field.
 int getInt(int fieldIndex)
          Returns the int value for the selected field.
 long getLong(int fieldIndex)
          Returns the long value for the selected field.
 short getShort(int fieldIndex)
          Returns the byte value for the selected field.
 int hashCode()
          Get a value that represents this Object, as uniquely as possible within the confines of an int.
 void setByte(int fieldIndex, byte value)
          Sets a byte value for the selected field.
 void setBytesCopy(byte[] bytesToCopy)
          Copy each byte from the provided byte array to the internal byte array.
protected  void setDetails(ElementDetails elementDetails)
          Changes the internal ElementDetails to reference the provided ElementDetails.
 void setDouble(int fieldIndex, double value)
          Sets a double value for the selected field.
 void setFloat(int fieldIndex, float value)
          Sets a float value for the selected field.
 void setInt(int fieldIndex, int value)
          Sets a int value for the selected field.
 void setLong(int fieldIndex, long value)
          Sets a long value for the selected field.
 void setShort(int fieldIndex, short value)
          Sets a short value for the selected field.
 java.lang.String toString()
          Returns the contents of the internal byte array colon seperated hex.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MAIN_RESOURCE_BUNDLE

private static final java.util.ResourceBundle MAIN_RESOURCE_BUNDLE

numberOfBytes

private volatile int numberOfBytes

fieldTypes

private volatile int[] fieldTypes

fieldOffsets

private volatile int[] fieldOffsets

bytes

private volatile byte[] bytes

details

private volatile ElementDetails details

TYPE_SIZES

protected static final int[] TYPE_SIZES

BITS_IN_A_BYTE

protected static final int BITS_IN_A_BYTE
See Also:
Constant Field Values

END_OF_BYTE

protected static final int END_OF_BYTE
See Also:
Constant Field Values
Constructor Detail

PagedElement

public PagedElement()
Creates an empty PagedElement.


PagedElement

public PagedElement(JTPagedArray pagedArray)
Creates a PagedElement and copies all the values contained in the provided JTPagedArray's ElementDetails.


PagedElement

public PagedElement(ElementDetails elementDetails)
Creates a PagedElement and copies all the values contained in the provided ElementDetails.


PagedElement

protected PagedElement(PagedElement pagedElement)
Creates a PagedElement and copies all the values contained in the provided PagedElement.

Method Detail

destroy

public void destroy()

finalize

protected void finalize()
Description copied from class: java.lang.Object
Called on an object by the Virtual Machine at most once, at some point after the Object is determined unreachable but before it is destroyed. You would think that this means it eventually is called on every Object, but this is not necessarily the case. If execution terminates abnormally, garbage collection does not always happen. Thus you cannot rely on this method to always work. For finer control over garbage collection, use references from the java.lang.ref package.

Virtual Machines are free to not call this method if they can determine that it does nothing important; for example, if your class extends Object and overrides finalize to do simply super.finalize().

finalize() will be called by a java.lang.Thread that has no locks on any Objects, and may be called concurrently. There are no guarantees on the order in which multiple objects are finalized. This means that finalize() is usually unsuited for performing actions that must be thread-safe, and that your implementation must be use defensive programming if it is to always work.

If an Exception is thrown from finalize() during garbage collection, it will be patently ignored and the Object will still be destroyed.

It is allowed, although not typical, for user code to call finalize() directly. User invocation does not affect whether automatic invocation will occur. It is also permitted, although not recommended, for a finalize() method to "revive" an object by making it reachable from normal code again.

Unlike constructors, finalize() does not get called for an object's superclass unless the implementation specifically calls super.finalize().

The default implementation does nothing.


clone

public java.lang.Object clone()
Description copied from class: java.lang.Object
This method may be called to create a new copy of the Object. The typical behavior is as follows:
  • o == o.clone() is false
  • o.getClass() == o.clone().getClass() is true
  • o.equals(o) is true

However, these are not strict requirements, and may be violated if necessary. Of the three requirements, the last is the most commonly violated, particularly if the subclass does not override Object.equals(Object)>Object.equals(Object) 55 .

If the Object you call clone() on does not implement java.lang.Cloneable (which is a placeholder interface), then a CloneNotSupportedException is thrown. Notice that Object does not implement Cloneable; this method exists as a convenience for subclasses that do.

Object's implementation of clone allocates space for the new Object using the correct class, without calling any constructors, and then fills in all of the new field values with the old field values. Thus, it is a shallow copy. However, subclasses are permitted to make a deep copy.

All array types implement Cloneable, and override this method as follows (it should never fail):

 public Object clone()
 {
   try
     {
       super.clone();
     }
   catch (CloneNotSupportedException e)
     {
       throw new InternalError(e.getMessage());
     }
 }
 


equals

public boolean equals(java.lang.Object object)
Delegates to equals(PagedElement) 55


equals

public boolean equals(PagedElement pagedElement)
Checks every byte in the internal byte array and verifies the ElementDetails using ElementDetails.equals(ElementDetails) 55 method.


hashCode

public int hashCode()
Description copied from class: java.lang.Object
Get a value that represents this Object, as uniquely as possible within the confines of an int.

There are some requirements on this method which subclasses must follow:

  • Semantic equality implies identical hashcodes. In other words, if a.equals(b) is true, then a.hashCode() == b.hashCode() must be as well. However, the reverse is not necessarily true, and two objects may have the same hashcode without being equal.
  • It must be consistent. Whichever value o.hashCode() returns on the first invocation must be the value returned on all later invocations as long as the object exists. Notice, however, that the result of hashCode may change between separate executions of a Virtual Machine, because it is not invoked on the same object.

Notice that since hashCode is used in java.util.Hashtable and other hashing classes, a poor implementation will degrade the performance of hashing (so don't blindly implement it as returning a constant!). Also, if calculating the hash is time-consuming, a class may consider caching the results.

The default implementation returns System.identityHashCode(this)


toString

public java.lang.String toString()
Returns the contents of the internal byte array colon seperated hex.


getDetails

public ElementDetails getDetails()
Returns a reference to the internal ElementDetails.


setDetails

protected void setDetails(ElementDetails elementDetails)
Changes the internal ElementDetails to reference the provided ElementDetails. A null object will be ignored.


getBytes

protected byte[] getBytes()
Returns a refernce to the internal byte array.

WARNING: Changing the internal byte array manually is dangerous. A JTPagedArray assumes that all bytes are valid. Invalid bytes could cause erratic behavior.


getBytesCopy

public byte[] getBytesCopy()
Returns a copy of the internal bytes array.


setBytesCopy

public void setBytesCopy(byte[] bytesToCopy)
Copy each byte from the provided byte array to the internal byte array. If the provided byte array is large than the interal one, the copy will be truncated. If it is smaller than the internal one, the remaining bytes in the internal array will be unchanged. If the internal array or the provided array are null, no action will be taken.

WARNING: Changing the internal byte array manually is dangerous. A JTPagedArray assumes that all bytes are valid. Invalid bytes could cause erratic behavior.


getByte

public byte getByte(int fieldIndex)
Returns the byte value for the selected field. Possible loss of precision if the data type is not a byte.

WARNING: Field indices are not checked for reasons of performance. Therefore an ArrayIndexOutOfBoundsException could be thrown.


getShort

public short getShort(int fieldIndex)
Returns the byte value for the selected field. Possible loss of precision if the data type is greater than a short.

WARNING: Field indices are not checked for reasons of performance. Therefore an ArrayIndexOutOfBoundsException could be thrown.


getInt

public int getInt(int fieldIndex)
Returns the int value for the selected field. Possible loss of precision if the data type is greater than a int.

WARNING: Field indices are not checked for reasons of performance. Therefore an ArrayIndexOutOfBoundsException could be thrown.


getLong

public long getLong(int fieldIndex)
Returns the long value for the selected field. Possible loss of precision if the data type is greater than a long.

WARNING: Field indices are not checked for reasons of performance. Therefore an ArrayIndexOutOfBoundsException could be thrown.


getFloat

public float getFloat(int fieldIndex)
Returns the float value for the selected field. Possible loss of precision if the data type is greater than a float.

WARNING: Field indices are not checked for reasons of performance. Therefore an ArrayIndexOutOfBoundsException could be thrown.


getDouble

public double getDouble(int fieldIndex)
Returns the double value for the selected field.

WARNING: Field indices are not checked for reasons of performance. Therefore an ArrayIndexOutOfBoundsException could be thrown.


setByte

public void setByte(int fieldIndex,
                    byte value)
Sets a byte value for the selected field.


setShort

public void setShort(int fieldIndex,
                     short value)
Sets a short value for the selected field. Possible loss of precision if the data type is less than a short.


setInt

public void setInt(int fieldIndex,
                   int value)
Sets a int value for the selected field. Possible loss of precision if the data type is less than a int.


setLong

public void setLong(int fieldIndex,
                    long value)
Sets a long value for the selected field. Possible loss of precision if the data type is less than a long.


setFloat

public void setFloat(int fieldIndex,
                     float value)
Sets a float value for the selected field. Possible loss of precision if the data type is less than a float.


setDouble

public void setDouble(int fieldIndex,
                      double value)
Sets a double value for the selected field. Possible loss of precision if the data type is less than a double.