gov.sns.xal.model.probe.traj
Class Trajectory

java.lang.Object
  |
  +--gov.sns.xal.model.probe.traj.Trajectory
All Implemented Interfaces:
IArchive
Direct Known Subclasses:
BeamTrajectory, DiagnosticProbeTrajectory, ParticlePerturbProbeTrajectory, ParticleTrajectory, SynchronousTrajectory, TransferMapTrajectory

public abstract class Trajectory
extends java.lang.Object
implements IArchive

Manages the history for a probe. Saves ProbeState objects, each of which reflects the state of the Probe at a particular point in time.


Field Summary
static java.lang.String TRAJ_LABEL
          XML element tag for trajectory
 
Constructor Summary
Trajectory()
          Create a new, emtpy Trajectory object.
 
Method Summary
protected  void addPropertiesTo(DataAdaptor container)
          Override this method in subclasses to add subclass-specific properties to the output.
 java.lang.String getDescription()
          Return the user comment associated with this trajectory.
 java.util.Date getTimestamp()
          Return the time stamp of the trajectory object
 int[] indicesForElement(java.lang.String element)
          Returns an array of the state indices corresponding to the specified element.
 ProbeState initialState()
          Returns the probe's initial state or null if there is none.
 void load(DataAdaptor container)
          Load the current Trajectory object with the state history information in the DataAdaptor object.
protected abstract  ProbeState newProbeState()
          Creates a new ProbeState object with the proper type for the trajectory.
protected abstract  ProbeState newProbeState(IProbe probe)
          Creates a new ProbeState object with the proper type for the trajectory.
 int numStates()
          Return the number of states in the trajectory.
 ProbeState popLastState()
          Remove the last state from the trajectory and return it.
static Trajectory readFrom(DataAdaptor container)
          Read the contents of the supplied DataAdaptor and return an instance of the appropriate Trajectory species.
protected  void readPropertiesFrom(DataAdaptor container)
          Allow subclasses to read subclass-specific properties from the DataAdaptor.
 void save(DataAdaptor container)
          Adds a representation of this Trajectory and its state history to the supplied DataAdaptor.
 void saveState(ProbeState s)
          Save the ProbeState object directly to the trajectory at the tail.
 void setDescription(java.lang.String strDescr)
          Set the user comment string
 void setTimestamp(long lngTimeStamp)
          Set the time stamp of the trajectory.
 ProbeState stateAtPosition(double pos)
          Returns the probe state at the specified position.
 java.util.Iterator stateIterator()
          Return an Iterator over the iterator's states.
 ProbeState[] statesForElement(java.lang.String strElemId)
          Returns the states associated with the specified element.
 ProbeState[] statesInPositionRange(double low, double high)
          Returns the states that fall within the specified position range, inclusive.
 ProbeState stateWithIndex(int i)
          Returns the state corresponding to the specified index, or null if there is none.
 java.lang.String toString()
          Store a textual representation of the trajectory to a string
 void update(IProbe probe)
          Captures the specified probe's current state to a ProbeState object then saves it to the trajectory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TRAJ_LABEL

public static final java.lang.String TRAJ_LABEL
XML element tag for trajectory

See Also:
Constant Field Values
Constructor Detail

Trajectory

public Trajectory()
Create a new, emtpy Trajectory object.

Method Detail

readFrom

public static Trajectory readFrom(DataAdaptor container)
                           throws ParsingException
Read the contents of the supplied DataAdaptor and return an instance of the appropriate Trajectory species.

Parameters:
container - DataAdaptor to read a Trajectory from
Returns:
a Trajectory for the contents of the DataAdaptor
Throws:
ParsingException - error encountered reading the DataAdaptor

newProbeState

protected abstract ProbeState newProbeState()
Creates a new ProbeState object with the proper type for the trajectory.

Returns:
new, empty ProbeState object

newProbeState

protected abstract ProbeState newProbeState(IProbe probe)
Creates a new ProbeState object with the proper type for the trajectory. Initialize new ProbeState to the state of the argument.

Parameters:
probe - probe interface belonging to object with the proper type for this trajectory
Returns:
new ProbeState object initialized to probe

addPropertiesTo

protected void addPropertiesTo(DataAdaptor container)
Override this method in subclasses to add subclass-specific properties to the output. Subclass implementations should call super.addPropertiesTo so that superclass implementations are executed.

Parameters:
container - the DataAdaptor to add properties to

readPropertiesFrom

protected void readPropertiesFrom(DataAdaptor container)
                           throws ParsingException
Allow subclasses to read subclass-specific properties from the DataAdaptor. Implementations should call super.readPropertiesFrom to ensure that superclass implementations are executed.

Parameters:
container - DataAdaptor to read properties from
ParsingException

setDescription

public void setDescription(java.lang.String strDescr)
Set the user comment string

Parameters:
strDescr - user comment string

setTimestamp

public void setTimestamp(long lngTimeStamp)
Set the time stamp of the trajectory.

Parameters:
lngTimeStamp - number of milliseconds since January 1, 1970 GMT

update

public void update(IProbe probe)
Captures the specified probe's current state to a ProbeState object then saves it to the trajectory. State goes at the tail of the trajectory list.

Parameters:
probe - target probe object

saveState

public void saveState(ProbeState s)
Save the ProbeState object directly to the trajectory at the tail.


popLastState

public ProbeState popLastState()
Remove the last state from the trajectory and return it.

Returns:
the most recent ProbeState in the history

getDescription

public java.lang.String getDescription()
Return the user comment associated with this trajectory.

Returns:
user comment (meta-data)

getTimestamp

public java.util.Date getTimestamp()
Return the time stamp of the trajectory object

Returns:
trajectory time stamp

stateIterator

public java.util.Iterator stateIterator()
Return an Iterator over the iterator's states.


numStates

public int numStates()
Return the number of states in the trajectory.

Returns:
the number of states

initialState

public ProbeState initialState()
Returns the probe's initial state or null if there is none.

Returns:
the probe's initial state or null

stateAtPosition

public ProbeState stateAtPosition(double pos)
Returns the probe state at the specified position. Returns null if there is no state for the specified position.


statesInPositionRange

public ProbeState[] statesInPositionRange(double low,
                                          double high)
Returns the states that fall within the specified position range, inclusive.

Parameters:
low - lower bound on position range
high - upper bound on position range
Returns:
an array of ProbeState objects whose position falls within the specified range

statesForElement

public ProbeState[] statesForElement(java.lang.String strElemId)
Returns the states associated with the specified element.

Parameters:
strElemId - the name of the element to search for
Returns:
an array of ProbeState objects for that element

indicesForElement

public int[] indicesForElement(java.lang.String element)
Returns an array of the state indices corresponding to the specified element.

Parameters:
element - name of element to search for
Returns:
an array of integer indices corresponding to that element

stateWithIndex

public ProbeState stateWithIndex(int i)
Returns the state corresponding to the specified index, or null if there is none.

Parameters:
i - index of state to return
Returns:
state corresponding to specified index

toString

public java.lang.String toString()
Store a textual representation of the trajectory to a string

Overrides:
toString in class java.lang.Object
Returns:
trajectory contents in string form

save

public void save(DataAdaptor container)
Adds a representation of this Trajectory and its state history to the supplied DataAdaptor.

Specified by:
save in interface IArchive
Parameters:
container - DataAdaptor in which to add Trajectory data

load

public void load(DataAdaptor container)
          throws DataFormatException
Load the current Trajectory object with the state history information in the DataAdaptor object.

Specified by:
load in interface IArchive
Parameters:
container - DataAdaptor from which state history is extracted
Throws:
DataFormatException - malformated data in DataAdaptor