/dependencies/jaudiotagger/src/main/java/org/jaudiotagger/tag/id3/framebody/FrameBodyTPOS.java
Java | 129 lines | 57 code | 18 blank | 54 comment | 0 complexity | b4214e18c77d5e2b981077563464acb3 MD5 | raw file
Possible License(s): LGPL-3.0, GPL-3.0, LGPL-2.1, BSD-3-Clause
- /*
- * MusicTag Copyright (C)2003,2004
- *
- * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
- * General Public License as published by the Free Software Foundation; either version 2.1 of the License,
- * or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
- * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- * See the GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License along with this library; if not,
- * you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
- package org.jaudiotagger.tag.id3.framebody;
-
- import org.jaudiotagger.tag.InvalidTagException;
- import org.jaudiotagger.tag.datatype.DataTypes;
- import org.jaudiotagger.tag.datatype.NumberHashMap;
- import org.jaudiotagger.tag.datatype.PartOfSet;
- import org.jaudiotagger.tag.id3.ID3v24Frames;
- import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
-
- import java.nio.ByteBuffer;
-
- /**
- * Part of a set Text information frame.
- * <p/>
- * <p>The 'Part of a set' frame is a numeric string that describes which part of a set the audio came from.
- * This frame is used if the source described in the "TALB" frame is divided into several mediums, e.g. a double CD.
- * The value may be extended with a "/" character and a numeric string containing the total number of parts in the set.
- * e.g. "1/2".
- * <p/>
- * <p>For more details, please refer to the ID3 specifications:
- * <ul>
- * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
- * </ul>
- *
- * @author : Paul Taylor
- * @author : Eric Farng
- * @version $Id: FrameBodyTPOS.java 895 2010-04-15 15:21:45Z paultaylor $
- */
- public class FrameBodyTPOS extends AbstractID3v2FrameBody implements ID3v23FrameBody, ID3v24FrameBody {
- /**
- * Creates a new FrameBodyTRCK datatype.
- */
- public FrameBodyTPOS() {
- setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
- setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue());
- }
-
- public FrameBodyTPOS(FrameBodyTPOS body) {
- super(body);
- }
-
- /**
- * Creates a new FrameBodyTRCK datatype, the value is parsed literally
- *
- * @param textEncoding
- * @param text
- */
- public FrameBodyTPOS(byte textEncoding, String text) {
- setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
- setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue(text));
- }
-
- public FrameBodyTPOS(byte textEncoding, Integer discNo, Integer discTotal) {
- super();
- setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
- setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue(discNo, discTotal));
- }
-
-
- /**
- * Creates a new FrameBodyTRCK datatype.
- *
- * @param byteBuffer
- * @param frameSize
- * @throws java.io.IOException
- * @throws InvalidTagException
- */
- public FrameBodyTPOS(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException {
- super(byteBuffer, frameSize);
- }
-
-
- /**
- * The ID3v2 frame identifier
- *
- * @return the ID3v2 frame identifier for this frame type
- */
- public String getIdentifier() {
- return ID3v24Frames.FRAME_ID_SET;
- }
-
- public String getUserFriendlyValue() {
- return String.valueOf(getDiscNo());
- }
-
- public String getText() {
- return getObjectValue(DataTypes.OBJ_TEXT).toString();
- }
-
- public Integer getDiscNo() {
- return ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).getCount();
- }
-
- public void setDiscNo(Integer discNo) {
- ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).setCount(discNo);
- }
-
- public Integer getDiscTotal() {
- return ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).getTotal();
- }
-
- public void setDiscTotal(Integer discTotal) {
- ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).setTotal(discTotal);
- }
-
- public void setText(String text) {
- setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue(text));
- }
-
- protected void setupObjectList() {
- objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
- objectList.add(new PartOfSet(DataTypes.OBJ_TEXT, this));
- }
- }