AbstractFrameBodyUrlLinkpublic abstract class AbstractFrameBodyUrlLink extends AbstractID3v2FrameBody Abstract super class of all URL Frames |
Constructors Summary |
---|
protected AbstractFrameBodyUrlLink()Creates a new FrameBodyUrlLink datatype.
super();
| protected AbstractFrameBodyUrlLink(AbstractFrameBodyUrlLink body)Copy Constructor
super(body);
| public AbstractFrameBodyUrlLink(String urlLink)Creates a new FrameBodyUrlLink datatype., set up with data.
setObjectValue(DataTypes.OBJ_URLLINK, urlLink);
| protected AbstractFrameBodyUrlLink(ByteBuffer byteBuffer, int frameSize)Creates a new FrameBodyUrlLink datatype.
super(byteBuffer, frameSize);
|
Methods Summary |
---|
private java.lang.String | encodeURL(java.lang.String url)Encode url because may receive url already encoded or not, but we can only store as ISO8859-1
try
{
final String[] splitURL = url.split("(?<!/)/(?!/)", -1);
final StringBuffer sb = new StringBuffer(splitURL[0]);
for (int i = 1; i < splitURL.length; i++)
{
sb.append("/").append(URLEncoder.encode(splitURL[i], "utf-8"));
}
return sb.toString();
}
catch (UnsupportedEncodingException uee)
{
//Should never happen as utf-8 is always availablebut in case it does we just return the utl
//unmodified
logger.warning("Uable to url encode because utf-8 charset not available:" + uee.getMessage());
return url;
}
| public java.lang.String | getUrlLink()Get URL Link
return (String) getObjectValue(DataTypes.OBJ_URLLINK);
| public java.lang.String | getUserFriendlyValue()
return getUrlLink();
| public void | setUrlLink(java.lang.String urlLink)Set URL Link
if (urlLink == null)
{
throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg());
}
setObjectValue(DataTypes.OBJ_URLLINK, urlLink);
| protected void | setupObjectList()
objectList.add(new StringSizeTerminated(DataTypes.OBJ_URLLINK, this));
| public void | write(java.io.ByteArrayOutputStream tagBuffer)If the description cannot be encoded using the current encoding change the encoder
CharsetEncoder encoder = Charset.forName(TextEncoding.CHARSET_ISO_8859_1).newEncoder();
String origUrl = getUrlLink();
if (!encoder.canEncode(origUrl))
{
//ALL W Frames only support ISO-8859-1 for the url itself, if unable to encode let us assume
//the link just needs url encoding
setUrlLink(encodeURL(origUrl));
//We still cant convert so just set log error and set to blank to allow save to continue
if (!encoder.canEncode(getUrlLink()))
{
logger.warning(ErrorMessage.MP3_UNABLE_TO_ENCODE_URL.getMsg(origUrl));
setUrlLink("");
}
//it was ok, just note the modification made
else
{
logger.warning(ErrorMessage.MP3_URL_SAVED_ENCODED.getMsg(origUrl, getUrlLink()));
}
}
super.write(tagBuffer);
|
|