Opus5
Class Array

java.lang.Object
  |
  +--Opus5.Array

public class Array
extends java.lang.Object

An array of Objects.

Version:
$Id: Array.java,v 3.1 1998/07/28 01:32:17 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.

Field Summary
protected  int base
          The index of the first array element.
protected  java.lang.Object[] data
          The array elements.
 
Constructor Summary
Array()
          Constructs an Array of length zero with base zero.
Array(int n)
          Constructs an Array with the specified length.
Array(int n, int m)
          Constructs an Array with the specified length and base.
 
Method Summary
 void assign(Array array)
          Assigns the value of the specified array to this array.
 java.lang.Object get(int position)
          Returns the array element at the specified position.
 int getBase()
          Returns the base of this array.
 java.lang.Object[] getData()
          Returns the data field.
 int getLength()
          Returns the length of this array.
 void put(int position, java.lang.Object object)
          Stores the specified object in this array at the specified position.
 void setBase(int base)
          Sets the base of this array to the specified value.
 void setLength(int newLength)
          Sets the length of this array to the specified value.
 java.lang.String toString()
          Returns a string representation of this array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

data

protected java.lang.Object[] data
The array elements.

base

protected int base
The index of the first array element.
Constructor Detail

Array

public Array(int n,
             int m)
Constructs an Array with the specified length and base.
Parameters:
n - The desired length.
m - The desired base.

Array

public Array()
Constructs an Array of length zero with base zero.

Array

public Array(int n)
Constructs an Array with the specified length.
Parameters:
n - The desired length.
Method Detail

assign

public void assign(Array array)
Assigns the value of the specified array to this array. This method changes the length and base of this array to match the specified array. Next, the elements of the specified array are assigned one-by-one to this array.
Parameters:
array - The desired array value.

getData

public java.lang.Object[] getData()
Returns the data field.
Returns:
the data field.

getBase

public int getBase()
Returns the base of this array.
Returns:
the base of this array.

getLength

public int getLength()
Returns the length of this array.
Returns:
the length of this array.

get

public java.lang.Object get(int position)
Returns the array element at the specified position.
Parameters:
position - The position of the desired element.
Returns:
The array element at the specified position.

put

public void put(int position,
                java.lang.Object object)
Stores the specified object in this array at the specified position.
Parameters:
position - The position of the desired element.

setBase

public void setBase(int base)
Sets the base of this array to the specified value.
Parameters:
base - The desired base.

setLength

public void setLength(int newLength)
Sets the length of this array to the specified value.
Parameters:
newLength - The desired length.

toString

public java.lang.String toString()
Returns a string representation of this array.
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this array.