gzz.media.impl
Class Enfilade1DImpl

java.lang.Object
  |
  +--gzz.media.impl.Enfilade1DImpl
All Implemented Interfaces:
Enfilade1D, java.io.Serializable

public class Enfilade1DImpl
extends java.lang.Object
implements Enfilade1D

A simple tree implementation of enfilades.

See Also:
Serialized Form

Nested Class Summary
static class Enfilade1DImpl.Enfilade1DImplMaker
           
 
Nested classes inherited from class gzz.media.Enfilade1D
 
Field Summary
static java.lang.String rcsid
           
static Enfilade1D.Maker theMaker
           
 
Constructor Summary
Enfilade1DImpl(Enfilade1DImpl left, Span middle, Enfilade1DImpl right)
           
Enfilade1DImpl(java.util.List spans, int from, int n)
           
Enfilade1DImpl(Span span)
           
 
Method Summary
 void addToList(java.util.List l)
           
 boolean equals(java.lang.Object o)
           
 java.util.List getList()
          Get a List of the spans in this enfilade.
 Enfilade1D.Maker getMaker()
           
 int hashCode()
           
 boolean intersects(Enfilade1D other0)
          Return true if this enfilade intersects (span-wise) the other one.
 boolean intersects(Span s)
          Return true if this enfilade intersects (span-wise) the given span.
 int length()
          Get the sum of the lengths.
 java.lang.String makeString()
          Return a String object where offsets are the same as in this enfilade.
 Enfilade1D optimized()
          Return a possibly optimized version of this enfilade.
 Enfilade1D plus(Enfilade1D other)
          Return an Enfilade1D object whose vstream is a concatenation of this enfilade and the other one given.
 Enfilade1D plus(Span1D other)
          Return an Enfilade1D object whose vstream is a concatenation of this enfilade and the span given.
 Enfilade1D prepended(Span1D other)
          Return an Enfilade1D object whose vstream is a concatenation of the given span and this enfilade.
 Enfilade1D sub(int o1)
           
 Enfilade1D sub(int o1, int o2)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

rcsid

public static final java.lang.String rcsid
See Also:
Constant Field Values

theMaker

public static Enfilade1D.Maker theMaker
Constructor Detail

Enfilade1DImpl

public Enfilade1DImpl(Enfilade1DImpl left,
                      Span middle,
                      Enfilade1DImpl right)

Enfilade1DImpl

public Enfilade1DImpl(Span span)

Enfilade1DImpl

public Enfilade1DImpl(java.util.List spans,
                      int from,
                      int n)
Method Detail

getMaker

public Enfilade1D.Maker getMaker()
Specified by:
getMaker in interface Enfilade1D

length

public int length()
Description copied from interface: Enfilade1D
Get the sum of the lengths. This MUST be the same as the length of the string returned by makeString().

Specified by:
length in interface Enfilade1D

sub

public Enfilade1D sub(int o1)
Specified by:
sub in interface Enfilade1D

sub

public Enfilade1D sub(int o1,
                      int o2)
Specified by:
sub in interface Enfilade1D

plus

public Enfilade1D plus(Enfilade1D other)
Description copied from interface: Enfilade1D
Return an Enfilade1D object whose vstream is a concatenation of this enfilade and the other one given. Unless the enfilades were created by the same maker, this method may throw a classcastexception.

Specified by:
plus in interface Enfilade1D

plus

public Enfilade1D plus(Span1D other)
Description copied from interface: Enfilade1D
Return an Enfilade1D object whose vstream is a concatenation of this enfilade and the span given. Unless the enfilades were created by the same maker, this method may throw a classcastexception.

Specified by:
plus in interface Enfilade1D

prepended

public Enfilade1D prepended(Span1D other)
Description copied from interface: Enfilade1D
Return an Enfilade1D object whose vstream is a concatenation of the given span and this enfilade. Unless the enfilades were created by the same maker, this method may throw a classcastexception.

Specified by:
prepended in interface Enfilade1D

makeString

public java.lang.String makeString()
Description copied from interface: Enfilade1D
Return a String object where offsets are the same as in this enfilade. Note that having an audio span will put in a lot of dummy chars so don't do that ;)

This is not toString() because that routine will give a string which explicitly indicates that this is an enfilade, and also gives the permanent ids of the spans therein.

Specified by:
makeString in interface Enfilade1D

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getList

public java.util.List getList()
Description copied from interface: Enfilade1D
Get a List of the spans in this enfilade.

Specified by:
getList in interface Enfilade1D

addToList

public void addToList(java.util.List l)

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

intersects

public boolean intersects(Enfilade1D other0)
Return true if this enfilade intersects (span-wise) the other one. XXX Implemented using a really slow, bad algorithm.


intersects

public boolean intersects(Span s)
Return true if this enfilade intersects (span-wise) the given span. XXX Implemented using a really slow, bad algorithm.


optimized

public Enfilade1D optimized()
Description copied from interface: Enfilade1D
Return a possibly optimized version of this enfilade. This could e.g. balance a tree. This function may be relatively expensive in terms of time, and also may reduce the number of nodes that can be shared between enfilades.

It is at its most useful for enfilades that have been created by adding little by little to the end, and which are not shared. Of course, most text entered in cells *is* just like that...

This method must at least join spans which are next to each other and which are contiguous (the latter can be appended to the former). This is necessary because coniguous spans MUST be appended before saving, otherwise we'd generate lots of JUNK!

Invariants which implementations MUST obey: ( XXX too harsh? )

Specified by:
optimized in interface Enfilade1D