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

Quick Search    Search Deep

org.jdaemon.util
Class ArrayAccessor  view ArrayAccessor download ArrayAccessor.java

java.lang.Object
  extended byorg.jdaemon.util.ArrayAccessor
All Implemented Interfaces:
Accessor

public class ArrayAccessor
extends java.lang.Object
implements Accessor

Accessor which allows items stored in an array to be given names and accessed via those names.


Field Summary
private  java.util.TreeMap map
          Stores the mapping of names to array indices
 
Constructor Summary
ArrayAccessor(java.lang.String[] names)
          Creates a new instance of ArrayAccessor given an array of names.
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name, java.lang.Object aggregate)
          Retrieves a named attribute from an object.
 java.lang.Object getAttribute(java.lang.String name, java.lang.Object[] array)
          Retrieves a named attribute from an array.
 java.util.Iterator getAttributeNames()
          Get an iterator over all the attribute names understood by this Accessor.
 void setAttribute(java.lang.String name, java.lang.Object[] array, java.lang.Object value)
          Set the value of a named attribute within an array.
 void setAttribute(java.lang.String name, java.lang.Object aggregate, java.lang.Object value)
          Set the value of a named attribute within an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

private java.util.TreeMap map
Stores the mapping of names to array indices

Constructor Detail

ArrayAccessor

public ArrayAccessor(java.lang.String[] names)
Creates a new instance of ArrayAccessor given an array of names. If name ith String in the array of names used to construct an ArrayAccessor accessor, and objects is an array of java objects, then:

accessor.getAttribute(name, objects) == objects[i]

Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     java.lang.Object[] array)
                              throws java.lang.IllegalArgumentException
Retrieves a named attribute from an array. If name is the ith String in the array of names used to construct this ArrayAccessor, then:

accessor.getAttribute(name, array) == array[i]


getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     java.lang.Object aggregate)
                              throws java.lang.IllegalArgumentException
Retrieves a named attribute from an object. aggregate must be an array. If name is the ith String in the array of names used to construct this ArrayAccessor, then:

accessor.getAttribute(name, aggregate) == aggregate[i]

Specified by:
getAttribute in interface Accessor

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object[] array,
                         java.lang.Object value)
                  throws java.lang.IllegalArgumentException
Set the value of a named attribute within an array. If name is the ith String in the array of names used to construct this ArrayAccessor, then:

accessor.setAttribute(name, array, value) and array[i] = value

are equivalent.


setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object aggregate,
                         java.lang.Object value)
                  throws java.lang.IllegalArgumentException
Set the value of a named attribute within an object. aggregate must be an array. If name is the ith String in the array of names used to construct this ArrayAccessor, then:

accessor.setAttribute(name, aggregate, value) and aggregate[i] = value

are equivalent.

Specified by:
setAttribute in interface Accessor

getAttributeNames

public java.util.Iterator getAttributeNames()
Get an iterator over all the attribute names understood by this Accessor.

Specified by:
getAttributeNames in interface Accessor