org.metasyntactic.id3.v2
Class SynchsafeInteger
java.lang.Object
|
+--org.metasyntactic.id3.v2.SynchsafeInteger
- public class SynchsafeInteger
- extends java.lang.Object
In some parts of the tag it is inconvenient to use the unsychronisation
scheme because the size of unsynchronised data is not known in advance,
which is particularly problematic with size descriptors. The solution in
ID3v2 is to use synchsafe integers, in which there can never be any false
synchs. Synchsafe integers are integers that keep its highest bit (bit 7)
zeroed, making seven bits out of eight available. Thus a 32 bit synchsafe
integer can store 28 bits of information.
Example:
255 (%11111111) encoded as a 16 bit synchsafe integer is 383
(%00000001 01111111).
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
SynchsafeInteger
public SynchsafeInteger(int value)
- Creates new SyncsafeInteger
getValue
public int getValue()
setValue
public void setValue(int value)
write
public void write(java.io.OutputStream out,
int length)
throws java.io.IOException
java.io.IOException
read
public static SynchsafeInteger read(java.io.InputStream in,
int length)
throws java.io.IOException
java.io.IOException
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals in class java.lang.Object
equals
public boolean equals(SynchsafeInteger s)
hashCode
public int hashCode()
- Overrides:
hashCode in class java.lang.Object
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object
main
public static void main(java.lang.String[] args)