package org.farng.mp3.id3;
import org.farng.mp3.InvalidTagException;
import org.farng.mp3.object.ObjectStringFixedLength;
import org.farng.mp3.object.ObjectStringNullTerminated;
import org.farng.mp3.object.ObjectStringSizeTerminated;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
* <h3>4.20. Linked information</h3>
* <p/>
* <p> To keep information duplication as low as possible this frame may be<br> used to link
* information from another ID3v2 tag that might reside in<br> another audio file or alone in a binary
* file. It is RECOMMENDED that<br>
* <p/>
* this method is only used when the files are stored on a CD-ROM or<br> other circumstances
* when the risk of file separation is low. The<br> frame contains a frame identifier, which is the frame
* that should be<br> linked into this tag, a URL [URL] field, where a reference to the<br>
* file where the frame is given, and additional ID data, if needed.<br>
* <p/>
* Data should be retrieved from the first tag found in the file to<br> which this link
* points. There may be more than one "LINK" frame in a<br> tag, but only one with the same
* contents. A linked frame is to be<br> considered as part of the tag and has the same restrictions as if
* it<br>
* <p/>
* was a physical part of the tag (i.e. only one "RVRB" frame allowed,<br> whether
* it's linked or not).</p>
* <p/>
* <p> <Header for 'Linked information', ID: "LINK"><br>
* <p/>
* Frame identifier $xx xx xx xx<br>
* URL
* <text string> $00<br> ID and additional data <text string(s)></p>
* <p/>
* <p> Frames that may be linked and need no additional data are "ASPI",<br>
* "ETCO", "EQU2", "MCID", "MLLT", "OWNE", "RVA2",
* "RVRB", "SYTC", the<br>
* <p/>
* text information frames and the URL link frames.</p>
* <p/>
* <p> The "AENC", "APIC", "GEOB" and "TXXX" frames may be linked
* with<br>
* <p/>
* the content descriptor as additional ID data.</p>
* <p/>
* <p> The "USER" frame may be linked with the language field as additional<br> ID
* data.<br> </p>
* <p/>
* <p> The "PRIV" frame may be linked with the owner identifier as<br> additional ID
* data.</p>
* <p/>
* <p> The "COMM", "SYLT" and "USLT"
* <p/>
* frames may be linked with three bytes<br> of language descriptor directly followed by a content
* descriptor as<br> additional ID data.<br> </p>
*
* @author Eric Farng
* @version $Revision: 1.4 $
*/
public class FrameBodyLINK extends AbstractID3v2FrameBody {
/**
* Creates a new FrameBodyLINK object.
*/
public FrameBodyLINK() {
super();
}
/**
* Creates a new FrameBodyLINK object.
*/
public FrameBodyLINK(final FrameBodyLINK body) {
super(body);
}
/**
* Creates a new FrameBodyLINK object.
*/
public FrameBodyLINK(final String frameIdentifier, final String url, final String additionalData) {
setObject("Frame Identifier", frameIdentifier);
setObject("URL", url);
setObject("ID and Additional Data", additionalData);
}
/**
* Creates a new FrameBodyLINK object.
*/
public FrameBodyLINK(final RandomAccessFile file) throws IOException, InvalidTagException {
this.read(file);
}
public String getAdditionalData() {
return (String) getObject("ID and Additional Data");
}
public void getAdditionalData(final String additionalData) {
setObject("ID and Additional Data", additionalData);
}
public String getFrameIdentifier() {
return (String) getObject("Frame Identifier");
}
public void getFrameIdentifier(final String frameIdentifier) {
setObject("Frame Identifier", frameIdentifier);
}
public String getIdentifier() {
return "LINK" + ((char) 0) + getFrameIdentifier() + ((char) 0) + getAdditionalData();
}
protected void setupObjectList() {
appendToObjectList(new ObjectStringFixedLength("Frame Identifier", 4));
appendToObjectList(new ObjectStringNullTerminated("URL"));
appendToObjectList(new ObjectStringSizeTerminated("ID and Additional Data"));
}
}