PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/dependencies/jaudiotagger/src/main/java/org/jaudiotagger/tag/id3/framebody/FrameBodyTPOS.java

http://github.com/tulskiy/musique
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
  1. /*
  2. * MusicTag Copyright (C)2003,2004
  3. *
  4. * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser
  5. * General Public License as published by the Free Software Foundation; either version 2.1 of the License,
  6. * or (at your option) any later version.
  7. *
  8. * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
  9. * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. * See the GNU Lesser General Public License for more details.
  11. *
  12. * You should have received a copy of the GNU Lesser General Public License along with this library; if not,
  13. * you can get a copy from http://www.opensource.org/licenses/lgpl-license.php or write to the Free Software
  14. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. */
  16. package org.jaudiotagger.tag.id3.framebody;
  17. import org.jaudiotagger.tag.InvalidTagException;
  18. import org.jaudiotagger.tag.datatype.DataTypes;
  19. import org.jaudiotagger.tag.datatype.NumberHashMap;
  20. import org.jaudiotagger.tag.datatype.PartOfSet;
  21. import org.jaudiotagger.tag.id3.ID3v24Frames;
  22. import org.jaudiotagger.tag.id3.valuepair.TextEncoding;
  23. import java.nio.ByteBuffer;
  24. /**
  25. * Part of a set Text information frame.
  26. * <p/>
  27. * <p>The 'Part of a set' frame is a numeric string that describes which part of a set the audio came from.
  28. * This frame is used if the source described in the "TALB" frame is divided into several mediums, e.g. a double CD.
  29. * The value may be extended with a "/" character and a numeric string containing the total number of parts in the set.
  30. * e.g. "1/2".
  31. * <p/>
  32. * <p>For more details, please refer to the ID3 specifications:
  33. * <ul>
  34. * <li><a href="http://www.id3.org/id3v2.3.0.txt">ID3 v2.3.0 Spec</a>
  35. * </ul>
  36. *
  37. * @author : Paul Taylor
  38. * @author : Eric Farng
  39. * @version $Id: FrameBodyTPOS.java 895 2010-04-15 15:21:45Z paultaylor $
  40. */
  41. public class FrameBodyTPOS extends AbstractID3v2FrameBody implements ID3v23FrameBody, ID3v24FrameBody {
  42. /**
  43. * Creates a new FrameBodyTRCK datatype.
  44. */
  45. public FrameBodyTPOS() {
  46. setObjectValue(DataTypes.OBJ_TEXT_ENCODING, TextEncoding.ISO_8859_1);
  47. setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue());
  48. }
  49. public FrameBodyTPOS(FrameBodyTPOS body) {
  50. super(body);
  51. }
  52. /**
  53. * Creates a new FrameBodyTRCK datatype, the value is parsed literally
  54. *
  55. * @param textEncoding
  56. * @param text
  57. */
  58. public FrameBodyTPOS(byte textEncoding, String text) {
  59. setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
  60. setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue(text));
  61. }
  62. public FrameBodyTPOS(byte textEncoding, Integer discNo, Integer discTotal) {
  63. super();
  64. setObjectValue(DataTypes.OBJ_TEXT_ENCODING, textEncoding);
  65. setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue(discNo, discTotal));
  66. }
  67. /**
  68. * Creates a new FrameBodyTRCK datatype.
  69. *
  70. * @param byteBuffer
  71. * @param frameSize
  72. * @throws java.io.IOException
  73. * @throws InvalidTagException
  74. */
  75. public FrameBodyTPOS(ByteBuffer byteBuffer, int frameSize) throws InvalidTagException {
  76. super(byteBuffer, frameSize);
  77. }
  78. /**
  79. * The ID3v2 frame identifier
  80. *
  81. * @return the ID3v2 frame identifier for this frame type
  82. */
  83. public String getIdentifier() {
  84. return ID3v24Frames.FRAME_ID_SET;
  85. }
  86. public String getUserFriendlyValue() {
  87. return String.valueOf(getDiscNo());
  88. }
  89. public String getText() {
  90. return getObjectValue(DataTypes.OBJ_TEXT).toString();
  91. }
  92. public Integer getDiscNo() {
  93. return ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).getCount();
  94. }
  95. public void setDiscNo(Integer discNo) {
  96. ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).setCount(discNo);
  97. }
  98. public Integer getDiscTotal() {
  99. return ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).getTotal();
  100. }
  101. public void setDiscTotal(Integer discTotal) {
  102. ((PartOfSet.PartOfSetValue) getObjectValue(DataTypes.OBJ_TEXT)).setTotal(discTotal);
  103. }
  104. public void setText(String text) {
  105. setObjectValue(DataTypes.OBJ_TEXT, new PartOfSet.PartOfSetValue(text));
  106. }
  107. protected void setupObjectList() {
  108. objectList.add(new NumberHashMap(DataTypes.OBJ_TEXT_ENCODING, this, TextEncoding.TEXT_ENCODING_FIELD_SIZE));
  109. objectList.add(new PartOfSet(DataTypes.OBJ_TEXT, this));
  110. }
  111. }