Package de.sciss.io
Class Marker
- java.lang.Object
-
- de.sciss.io.Marker
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable
public class Marker extends java.lang.Object implements java.lang.Cloneable, java.lang.Comparable, java.io.SerializableA struct class: marker in an audio file. (copied from FScape).- See Also:
AudioFileDescr.KEY_MARKERS, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.StringnameA marker's namestatic java.util.ComparatornameComparatorAComparatorwhich can be used to sort a list of markers according to the markers' names.longposA marker's position in sample frames
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intadd(java.util.List markers, Marker marker)Adds marker chronologically to a pre-sorted list.java.lang.Objectclone()Returns a new marker which is equal to this one.intcompareTo(java.lang.Object o)Implementation of theComparableinterface.booleanequals(java.lang.Object o)static intfind(java.util.List markers, java.lang.String name, int startIndex)Gets the index for specific marker in a list.inthashCode()
-
-
-
Field Detail
-
nameComparator
public static final java.util.Comparator nameComparator
AComparatorwhich can be used to sort a list of markers according to the markers' names. Note that to sort markers according to their position, you can use the natural ordering of the markers as defined by theComparableinterface.- See Also:
Collections.sort( List ),Collections.sort( List, Comparator )
-
pos
public final long pos
A marker's position in sample frames
-
name
public final java.lang.String name
A marker's name
-
-
Constructor Detail
-
Marker
public Marker(long pos, java.lang.String name)Constructs a new immutable marker- Parameters:
pos- position in sample framesname- marker's name
-
Marker
public Marker(Marker orig)
Constructs a new immutable marker identical to a given marker.- Parameters:
orig- the marker to copy
-
-
Method Detail
-
clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedExceptionReturns a new marker which is equal to this one.CloneNotSupportedExceptionis never thrown.- Overrides:
clonein classjava.lang.Object- Returns:
- a new marker with the same name and position as this marker
- Throws:
java.lang.CloneNotSupportedException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
compareTo
public int compareTo(java.lang.Object o)
Implementation of theComparableinterface. The passed object can be either anotherMarkeror aRegion. In the latter case, the region's start position is compared to this marker's position.- Specified by:
compareToin interfacejava.lang.Comparable- Parameters:
o- the object to compare to this marker- Returns:
- negative or positive value, if the object is greater or smaller compared to this marker, zero if they are equal
- Throws:
java.lang.ClassCastException- ifois neither aMarkersnor aRegion
-
add
public static int add(java.util.List markers, Marker marker)Adds marker chronologically to a pre-sorted list.- Parameters:
markers- a chronological marker listmarker- the marker to insert such that its predecessor has a position less or equal this marker's position and the marker's successor has a position greater than this marker's position.- Returns:
- marker index in vector at which it was inserted
-
find
public static int find(java.util.List markers, java.lang.String name, int startIndex)Gets the index for specific marker in a list. Note that if the markers have distinct names (no duplicates), it may be more convenient to create a list copy, sort it using thenameComparator, and looking it up usingCollections.binarySearch().- Parameters:
markers- aListwhose elements are instanceofMarker.name- marker name to findstartIndex- where to begin- Returns:
- The list index of the first occurance (beginning
at
startIndex) of a marker whose name equals the given name. - See Also:
nameComparator,Collections.binarySearch( List, Object, Comparator )
-
-