Package de.sciss.io
Class Span
- java.lang.Object
-
- de.sciss.io.Span
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable
public class Span extends java.lang.Object implements java.io.Serializable, java.lang.CloneableA struct class: a span between a start and end point in one dimensional space. The start point is considered inclusive while the end point is considered exclusive. In Meloncillo, it is mainly used to describe a time span in sense rate frames.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description longstartThe spanstartshould be treated as if it was immutable!static java.util.ComparatorstartComparatorlongstopThe spanstartshould be treated as if it was immutable!static java.util.ComparatorstopComparator
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longclip(long pos)java.lang.Objectclone()Returns a new span which is equal to this one.booleancontains(long position)Checks if a position lies within the span.booleancontains(Span anotherSpan)Checks if another span lies within the span.booleanequals(java.lang.Object o)Checks if this span is equal to an object.longgetLength()Queries the span's extent (duration, length etc.)longgetStart()Queries the span's start.longgetStop()Queries the span's end.inthashCode()Spanintersection(Span anotherSpan)static Spanintersection(Span span1, Span span2)booleanisEmpty()Checks if the span is empty.booleanoverlaps(Span anotherSpan)Checks if a two spans overlap each other.SpanreplaceStart(long newStart)SpanreplaceStop(long newStop)Spanshift(long delta)java.lang.StringtoString()booleantouches(Span anotherSpan)Checks if a two spans overlap or touch each other.Spanunion(Span anotherSpan)static Spanunion(Span span1, Span span2)Union operation on two spans.
-
-
-
Field Detail
-
startComparator
public static final java.util.Comparator startComparator
-
stopComparator
public static final java.util.Comparator stopComparator
-
start
public final long start
The spanstartshould be treated as if it was immutable!
-
stop
public final long stop
The spanstartshould be treated as if it was immutable!
-
-
Constructor Detail
-
Span
public Span()
Create a new empty span whose start and stop are zero.
-
Span
public Span(long start, long stop)Creates a span with the given start and stop points. The caller has to ensure that start <= stop (this is not checked)- Parameters:
start- beginning of the spanstop- end of the span
-
Span
public Span(Span span)
Create a span with the start and stop points copied from another span.- Parameters:
span- template span whose start and end are copied
-
-
Method Detail
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a new span which is equal to this one.CloneNotSupportedExceptionis never thrown.- Overrides:
clonein classjava.lang.Object- Returns:
- a new span with the same start and stop as this span
- Throws:
java.lang.CloneNotSupportedException
-
contains
public boolean contains(long position)
Checks if a position lies within the span.- Returns:
true, ifstart <= position < stop
-
contains
public boolean contains(Span anotherSpan)
Checks if another span lies within the span.- Parameters:
anotherSpan- second span, may benull(in this case returnsfalse)- Returns:
true, ifanotherSpan.start >= this.span && anotherSpan.stop <= this.stop
-
overlaps
public boolean overlaps(Span anotherSpan)
Checks if a two spans overlap each other.- Parameters:
anotherSpan- second span, may benull(in this case returnsfalse)- Returns:
true, if the spans overlap each other
-
touches
public boolean touches(Span anotherSpan)
Checks if a two spans overlap or touch each other.- Parameters:
anotherSpan- second span, may benull(in this case returnsfalse)- Returns:
true, if the spans overlap each other
-
isEmpty
public boolean isEmpty()
Checks if the span is empty.- Returns:
true, ifstart == stop
-
equals
public boolean equals(java.lang.Object o)
Checks if this span is equal to an object.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- an object to compare to this span- Returns:
true, ifois a span with the same start and end point
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getStart
public long getStart()
Queries the span's start.- Returns:
- the start point of the span
-
getStop
public long getStop()
Queries the span's end.- Returns:
- the end point of the span
-
getLength
public long getLength()
Queries the span's extent (duration, length etc.)- Returns:
- length of the span, i.e.
stop - start
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
union
public static Span union(Span span1, Span span2)
Union operation on two spans.- Parameters:
span1- first span to fuse (may benull)span2- second span to fuse (may benull)- Returns:
- a new span whose extension
covers both span1 and span2, or
nullif bothspan1andspan2arenull
-
clip
public long clip(long pos)
-
replaceStart
public Span replaceStart(long newStart)
-
replaceStop
public Span replaceStop(long newStop)
-
shift
public Span shift(long delta)
-
-