Mp4DiscNoFieldpublic class Mp4DiscNoField extends Mp4TagTextNumberField Represents the Disc No field
Contains some reserved fields that we currently ignore
Reserved:2 bytes
Disc Number:2 bytes
Total no of Discs:2 bytes
|
Fields Summary |
---|
private static final int | NONE_VALUE_INDEX | private static final int | DISC_NO_INDEX | private static final int | DISC_TOTAL_INDEX |
Constructors Summary |
---|
public Mp4DiscNoField(String discValue)Create new Disc Field parsing the String for the discno/total
super(Mp4FieldKey.DISCNUMBER.getFieldName(), discValue);
numbers = new ArrayList<Short>();
numbers.add(new Short("0"));
String values[] = discValue.split("/");
switch (values.length)
{
case 1:
try
{
numbers.add(Short.parseShort(values[0]));
}
catch (NumberFormatException nfe)
{
throw new FieldDataInvalidException("Value of:" + values[0] + " is invalid for field:" + id);
}
numbers.add(new Short("0"));
break;
case 2:
try
{
numbers.add(Short.parseShort(values[0]));
}
catch (NumberFormatException nfe)
{
throw new FieldDataInvalidException("Value of:" + values[0] + " is invalid for field:" + id);
}
try
{
numbers.add(Short.parseShort(values[1]));
}
catch (NumberFormatException nfe)
{
throw new FieldDataInvalidException("Value of:" + values[1] + " is invalid for field:" + id);
}
break;
default:
throw new FieldDataInvalidException("Value is invalid for field:" + id);
}
| public Mp4DiscNoField(int discNo)Create new Disc No field with only discNo
super(Mp4FieldKey.DISCNUMBER.getFieldName(), String.valueOf(discNo));
numbers = new ArrayList<Short>();
numbers.add(new Short("0"));
numbers.add((short) discNo);
numbers.add(new Short("0"));
| public Mp4DiscNoField(int discNo, int total)Create new Disc No Field with Disc No and total number of discs
super(Mp4FieldKey.DISCNUMBER.getFieldName(), String.valueOf(discNo));
numbers = new ArrayList<Short>();
numbers.add(new Short("0"));
numbers.add((short) discNo);
numbers.add((short) total);
| public Mp4DiscNoField(String id, ByteBuffer data)
super(id, data);
|
Methods Summary |
---|
protected void | build(java.nio.ByteBuffer data)
//Data actually contains a 'Data' Box so process data using this
Mp4BoxHeader header = new Mp4BoxHeader(data);
Mp4DataBox databox = new Mp4DataBox(header, data);
dataSize = header.getDataLength();
numbers = databox.getNumbers();
//Disc number always hold four values, we can discard the first one and last one, the second one is the disc no
//and the third is the total no of discs so only use if not zero
StringBuffer sb = new StringBuffer();
if ((numbers.size() > DISC_NO_INDEX) && (numbers.get(DISC_NO_INDEX) > 0))
{
sb.append(numbers.get(DISC_NO_INDEX));
}
if ((numbers.size() > DISC_TOTAL_INDEX) && (numbers.get(DISC_TOTAL_INDEX) > 0))
{
sb.append("/").append(numbers.get(DISC_TOTAL_INDEX));
}
content = sb.toString();
| public java.lang.Short | getDiscNo()
return numbers.get(DISC_NO_INDEX);
| public java.lang.Short | getDiscTotal()
if(numbers.size()<=DISC_TOTAL_INDEX)
{
return 0;
}
return numbers.get(DISC_TOTAL_INDEX);
| public void | setDiscNo(int discNo)Set Disc No
numbers.set(DISC_NO_INDEX, (short) discNo);
| public void | setDiscTotal(int discTotal)Set total number of discs
numbers.set(DISC_TOTAL_INDEX, (short) discTotal);
|
|