brbrain
Class PoseSequence

java.lang.Object
  extended by brbrain.PoseSequence

public class PoseSequence
extends java.lang.Object

Sequence of Bioloid Poses.

A pose sequence may have zero poses but always has an immutable pose format, to which all added poses must adhere.

The sequence is both iterated and mutated via ListIterators acquired from the listIterator() methods.

Copyright (C) 2007 Marsette A. Vona, III

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Author:
Marsette (Marty) A. Vona, III

Field Summary
 int[] axIDs
          the set of axIDs; do not mutate
private static java.lang.String cvsid
           
protected  Pose formatPose
          a dummy pose giving the format
protected  java.util.LinkedList<Pose> poses
          the poses
 int readNum
          the number of regs in the BRBrain read format
 AXRegister readStart
          the first reg in the BRBrain read format
 AXRegister[] registers
          the set of registers; do not mutate
 int writeNum
          the number of regs in the BRBrain write format, or 0 if none
 AXRegister writeStart
          the first reg in the BRBrain write format, or null if none
 
Constructor Summary
PoseSequence(int[] axIDs, AXRegister[] registers, AXRegister writeStart, int writeNum)
          make a new empty sequence with the given format
 
Method Summary
protected  void checkPose(Pose p)
          make sure that a pose has the correct format
 Pose getFirst()
          get the first pose in the sequence, NoSuchElement exception if empty
 Pose getLast()
          get the last pose in the sequence, NoSuchElement exception if empty
 boolean isEmpty()
          check if the sequence is empty
 java.util.ListIterator<Pose> listIterator()
          get an iterator
 java.util.ListIterator<Pose> listIterator(int index)
          get an iterator starting at the given zero-based index
 void readFrom(java.io.InputStream is)
          covers readFrom(Pose.PoseTokenizer), conses the tokenizer
 void readFrom(Pose.PoseTokenizer t)
          Clear current sequence and read all poses in the format Pose.readFrom(brbrain.Pose) expects.
 int size()
          get the number of poses in the sequence
protected  java.util.ListIterator<Pose> wrapIterator(java.util.ListIterator<Pose> it)
          wrap a vanilla iterator with format checking and setting
 void writeHeaderTo(java.io.OutputStream s)
          covers writeHeaderTo(PrintWriter)
 void writeHeaderTo(java.io.PrintWriter w)
          write a header comment with the axIDs
 void writeTo(java.io.OutputStream s)
          covers writeTo(PrintWriter)
 void writeTo(java.io.PrintWriter w)
          write all poses in the format readFrom(brbrain.Pose.PoseTokenizer) expects
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsid

private static final java.lang.String cvsid
See Also:
Constant Field Values

axIDs

public final int[] axIDs
the set of axIDs; do not mutate


registers

public final AXRegister[] registers
the set of registers; do not mutate


readStart

public final AXRegister readStart
the first reg in the BRBrain read format


writeStart

public final AXRegister writeStart
the first reg in the BRBrain write format, or null if none


readNum

public final int readNum
the number of regs in the BRBrain read format


writeNum

public final int writeNum
the number of regs in the BRBrain write format, or 0 if none


formatPose

protected Pose formatPose
a dummy pose giving the format


poses

protected java.util.LinkedList<Pose> poses
the poses

Constructor Detail

PoseSequence

public PoseSequence(int[] axIDs,
                    AXRegister[] registers,
                    AXRegister writeStart,
                    int writeNum)
make a new empty sequence with the given format

Method Detail

listIterator

public java.util.ListIterator<Pose> listIterator()
get an iterator


listIterator

public java.util.ListIterator<Pose> listIterator(int index)
get an iterator starting at the given zero-based index


wrapIterator

protected java.util.ListIterator<Pose> wrapIterator(java.util.ListIterator<Pose> it)
wrap a vanilla iterator with format checking and setting


checkPose

protected void checkPose(Pose p)
make sure that a pose has the correct format


size

public int size()
get the number of poses in the sequence


isEmpty

public boolean isEmpty()
check if the sequence is empty


getFirst

public Pose getFirst()
get the first pose in the sequence, NoSuchElement exception if empty


getLast

public Pose getLast()
get the last pose in the sequence, NoSuchElement exception if empty


readFrom

public void readFrom(Pose.PoseTokenizer t)
              throws java.io.IOException

Clear current sequence and read all poses in the format Pose.readFrom(brbrain.Pose) expects.

Throws:
java.io.IOException

readFrom

public void readFrom(java.io.InputStream is)
              throws java.io.IOException
covers readFrom(Pose.PoseTokenizer), conses the tokenizer

Throws:
java.io.IOException

writeTo

public void writeTo(java.io.PrintWriter w)
             throws java.io.IOException
write all poses in the format readFrom(brbrain.Pose.PoseTokenizer) expects

Throws:
java.io.IOException

writeTo

public void writeTo(java.io.OutputStream s)
             throws java.io.IOException
covers writeTo(PrintWriter)

Throws:
java.io.IOException

writeHeaderTo

public void writeHeaderTo(java.io.PrintWriter w)
                   throws java.io.IOException
write a header comment with the axIDs

Throws:
java.io.IOException

writeHeaderTo

public void writeHeaderTo(java.io.OutputStream s)
                   throws java.io.IOException
covers writeHeaderTo(PrintWriter)

Throws:
java.io.IOException