code
stringlengths
11
173k
docstring
stringlengths
2
593k
func_name
stringlengths
2
189
language
stringclasses
1 value
repo
stringclasses
844 values
path
stringlengths
11
294
url
stringlengths
60
339
license
stringclasses
4 values
public byte getRevision() { return REVISION; }
Retrieve the Revision
ID3v11Tag::getRevision
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public ID3v11Tag() { }
Creates a new ID3v11 datatype.
ID3v11Tag::ID3v11Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public ID3v11Tag(AbstractTag mp3tag) { if (mp3tag != null) { if (mp3tag instanceof ID3v1Tag id3old) { if (mp3tag instanceof ID3v11Tag) { throw new UnsupportedOperationException("Copy Constructor not called. Please type cast the argument"); } // id3v1_1 objects are also id3v1 objects this.title = id3old.title; this.artist = id3old.artist; this.album = id3old.album; this.comment = id3old.comment; this.year = id3old.year; this.genre = id3old.genre; } else { ID3v24Tag id3tag; // first change the tag to ID3v2_4 tag if not one already if (!(mp3tag instanceof ID3v24Tag)) { id3tag = new ID3v24Tag(mp3tag); } else { id3tag = (ID3v24Tag) mp3tag; } ID3v24Frame frame; String text; if (id3tag.hasFrame(ID3v24Frames.FRAME_ID_TITLE)) { frame = (ID3v24Frame) id3tag.getFrame(ID3v24Frames.FRAME_ID_TITLE); text = ((FrameBodyTIT2) frame.getBody()).getText(); this.title = ID3Tags.truncate(text, FIELD_TITLE_LENGTH); } if (id3tag.hasFrame(ID3v24Frames.FRAME_ID_ARTIST)) { frame = (ID3v24Frame) id3tag.getFrame(ID3v24Frames.FRAME_ID_ARTIST); text = ((FrameBodyTPE1) frame.getBody()).getText(); this.artist = ID3Tags.truncate(text, FIELD_ARTIST_LENGTH); } if (id3tag.hasFrame(ID3v24Frames.FRAME_ID_ALBUM)) { frame = (ID3v24Frame) id3tag.getFrame(ID3v24Frames.FRAME_ID_ALBUM); text = ((FrameBodyTALB) frame.getBody()).getText(); this.album = ID3Tags.truncate(text, FIELD_ALBUM_LENGTH); } if (id3tag.hasFrame(ID3v24Frames.FRAME_ID_YEAR)) { frame = (ID3v24Frame) id3tag.getFrame(ID3v24Frames.FRAME_ID_YEAR); text = ((FrameBodyTDRC) frame.getBody()).getText(); this.year = ID3Tags.truncate(text, FIELD_YEAR_LENGTH); } if (id3tag.hasFrame(ID3v24Frames.FRAME_ID_COMMENT)) { Iterator iterator = id3tag.getFrameOfType(ID3v24Frames.FRAME_ID_COMMENT); text = ""; while (iterator.hasNext()) { frame = (ID3v24Frame) iterator.next(); text += (((FrameBodyCOMM) frame.getBody()).getText() + " "); } this.comment = ID3Tags.truncate(text, FIELD_COMMENT_LENGTH); } if (id3tag.hasFrame(ID3v24Frames.FRAME_ID_GENRE)) { frame = (ID3v24Frame) id3tag.getFrame(ID3v24Frames.FRAME_ID_GENRE); text = ((FrameBodyTCON) frame.getBody()).getText(); try { this.genre = (byte) ID3Tags.findNumber(text); } catch (TagException ex) { Integer genreId = GenreTypes.getInstanceOf().getIdForValue(text); if(null!= genreId) this.genre = genreId.byteValue(); else { logger.log(Level.WARNING, getLoggingFilename() + ":" + "Unable to convert TCON frame to format suitable for v11 tag", ex); this.genre = (byte) ID3v1Tag.GENRE_UNDEFINED; } } } if (id3tag.hasFrame(ID3v24Frames.FRAME_ID_TRACK)) { frame = (ID3v24Frame) id3tag.getFrame(ID3v24Frames.FRAME_ID_TRACK); this.track = (byte) ((FrameBodyTRCK) frame.getBody()).getTrackNo().intValue(); } } } }
Creates a new ID3v11 datatype from a non v11 tag @param mp3tag @throws UnsupportedOperationException
ID3v11Tag::ID3v11Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public ID3v11Tag(RandomAccessFile file, String loggingFilename) throws TagNotFoundException, IOException { setLoggingFilename(loggingFilename); FileChannel fc; ByteBuffer byteBuffer = ByteBuffer.allocate(TAG_LENGTH); fc = file.getChannel(); fc.position(file.length() - TAG_LENGTH); fc.read(byteBuffer); byteBuffer.flip(); read(byteBuffer); }
Creates a new ID3v11 datatype. @param file @param loggingFilename @throws TagNotFoundException @throws IOException
ID3v11Tag::ID3v11Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public ID3v11Tag(RandomAccessFile file) throws TagNotFoundException, IOException { this(file, ""); }
Creates a new ID3v11 datatype. @param file @throws TagNotFoundException @throws IOException @deprecated use {@link #ID3v11Tag(RandomAccessFile,String)} instead
ID3v11Tag::ID3v11Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public void setComment(String comment) { if (comment == null) { throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg()); } this.comment = ID3Tags.truncate(comment, FIELD_COMMENT_LENGTH); }
Set Comment @param comment
ID3v11Tag::setComment
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public String getFirstComment() { return comment; }
Get Comment @return comment
ID3v11Tag::getFirstComment
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public void deleteField(FieldKey genericKey) { if (genericKey == FieldKey.TRACK) { track = 0; } else { super.deleteField(genericKey); } }
Delete any instance of tag fields with this key @param genericKey
ID3v11Tag::deleteField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public boolean equals(Object obj) { if (!(obj instanceof ID3v11Tag object)) { return false; } return this.track == object.track && super.equals(obj); }
Compares Object with this only returns true if both v1_1 tags with all fields set to same value @param obj Comparing Object @return
ID3v11Tag::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public boolean seek(ByteBuffer byteBuffer) { byte[] buffer = new byte[FIELD_TAGID_LENGTH]; // read the TAG value byteBuffer.get(buffer, 0, FIELD_TAGID_LENGTH); if (!(Arrays.equals(buffer, TAG_ID))) { return false; } // Check for the empty byte before the TRACK byteBuffer.position(FIELD_TRACK_INDICATOR_POS); if (byteBuffer.get() != END_OF_FIELD) { return false; } //Now check for TRACK if the next byte is also null byte then not v1.1 //tag, however this means cannot have v1_1 tag with track setField to zero/undefined //because on next read will be v1 tag. return byteBuffer.get() != END_OF_FIELD; }
Find identifier within byteBuffer to indicate that a v11 tag exists within the buffer @param byteBuffer @return true if find header for v11 tag within buffer
ID3v11Tag::seek
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public void read(ByteBuffer byteBuffer) throws TagNotFoundException { if (!seek(byteBuffer)) { throw new TagNotFoundException("ID3v1 tag not found"); } logger.finer("Reading v1.1 tag"); //Do single file read of data to cut down on file reads byte[] dataBuffer = new byte[TAG_LENGTH]; byteBuffer.position(0); byteBuffer.get(dataBuffer, 0, TAG_LENGTH); title = new String(dataBuffer, FIELD_TITLE_POS, FIELD_TITLE_LENGTH, StandardCharsets.ISO_8859_1).trim(); Matcher m = AbstractID3v1Tag.endofStringPattern.matcher(title); if (m.find()) { title = title.substring(0, m.start()); } artist = new String(dataBuffer, FIELD_ARTIST_POS, FIELD_ARTIST_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(artist); if (m.find()) { artist = artist.substring(0, m.start()); } album = new String(dataBuffer, FIELD_ALBUM_POS, FIELD_ALBUM_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(album); if (m.find()) { album = album.substring(0, m.start()); } year = new String(dataBuffer, FIELD_YEAR_POS, FIELD_YEAR_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(year); if (m.find()) { year = year.substring(0, m.start()); } comment = new String(dataBuffer, FIELD_COMMENT_POS, FIELD_COMMENT_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(comment); if (m.find()) { comment = comment.substring(0, m.start()); } track = dataBuffer[FIELD_TRACK_POS]; genre = dataBuffer[FIELD_GENRE_POS]; }
Read in a tag from the ByteBuffer @param byteBuffer from where to read in a tag @throws TagNotFoundException if unable to read a tag in the byteBuffer
ID3v11Tag::read
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public void write(RandomAccessFile file) throws IOException { logger.config("Saving ID3v11 tag to file"); byte[] buffer = new byte[TAG_LENGTH]; int i; String str; delete(file); file.seek(file.length()); System.arraycopy(TAG_ID, FIELD_TAGID_POS, buffer, FIELD_TAGID_POS, TAG_ID.length); int offset = FIELD_TITLE_POS; if (TagOptionSingleton.getInstance().isId3v1SaveTitle()) { str = ID3Tags.truncate(title, FIELD_TITLE_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_ARTIST_POS; if (TagOptionSingleton.getInstance().isId3v1SaveArtist()) { str = ID3Tags.truncate(artist, FIELD_ARTIST_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_ALBUM_POS; if (TagOptionSingleton.getInstance().isId3v1SaveAlbum()) { str = ID3Tags.truncate(album, FIELD_ALBUM_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_YEAR_POS; if (TagOptionSingleton.getInstance().isId3v1SaveYear()) { str = ID3Tags.truncate(year, FIELD_YEAR_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_COMMENT_POS; if (TagOptionSingleton.getInstance().isId3v1SaveComment()) { str = ID3Tags.truncate(comment, FIELD_COMMENT_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_TRACK_POS; buffer[offset] = track; // skip one byte extra blank for 1.1 definition offset = FIELD_GENRE_POS; if (TagOptionSingleton.getInstance().isId3v1SaveGenre()) { buffer[offset] = genre; } file.write(buffer); logger.config("Saved ID3v11 tag to file"); }
Write this representation of tag to the file indicated @param file that this tag should be written to @throws IOException thrown if there were problems writing to the file
ID3v11Tag::write
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v11Tag.java
Apache-2.0
public int compare(String frameId1, String frameId2) { int frameId1Index= frameIdsInPreferredOrder.indexOf(frameId1); if(frameId1Index==-1) { frameId1Index=Integer.MAX_VALUE; } int frameId2Index= frameIdsInPreferredOrder.indexOf(frameId2); //Because othwerwise returns -1 whihc would be tags in list went to top of list if(frameId2Index==-1) { frameId2Index=Integer.MAX_VALUE; } //To have determinable ordering AND because if returns equal Treese considers as equal if(frameId1Index==frameId2Index) { return frameId1.compareTo(frameId2); } return frameId1Index - frameId2Index; }
@param frameId1 @param frameId2 @return
ID3v24PreferredFrameOrderComparator::compare
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24PreferredFrameOrderComparator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24PreferredFrameOrderComparator.java
Apache-2.0
public byte getRelease() { return RELEASE; }
Retrieve the Release
ID3v1Tag::getRelease
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public byte getMajorVersion() { return MAJOR_VERSION; }
Retrieve the Major Version
ID3v1Tag::getMajorVersion
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public byte getRevision() { return REVISION; }
Retrieve the Revision
ID3v1Tag::getRevision
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public ID3v1Tag() { }
Creates a new ID3v1 datatype.
ID3v1Tag::ID3v1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public ID3v1Tag(RandomAccessFile file, String loggingFilename) throws TagNotFoundException, IOException { setLoggingFilename(loggingFilename); FileChannel fc; ByteBuffer byteBuffer; fc = file.getChannel(); fc.position(file.length() - TAG_LENGTH); byteBuffer = ByteBuffer.allocate(TAG_LENGTH); fc.read(byteBuffer); byteBuffer.flip(); read(byteBuffer); }
Creates a new ID3v1 datatype. @param file @param loggingFilename @throws TagNotFoundException @throws IOException
ID3v1Tag::ID3v1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public ID3v1Tag(RandomAccessFile file) throws TagNotFoundException, IOException { this(file, ""); }
Creates a new ID3v1 datatype. @param file @throws TagNotFoundException @throws IOException @deprecated use {@link #ID3v1Tag(RandomAccessFile,String)} instead
ID3v1Tag::ID3v1Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<String> getAll(FieldKey genericKey) throws KeyNotFoundException { List<String> list = new ArrayList<String>(); list.add(getFirst(genericKey.name())); return list; }
Maps the generic key to the ogg key and return the list of values for this field as strings @param genericKey @return @throws KeyNotFoundException
ID3v1Tag::getAll
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void setAlbum(String album) { if (album == null) { throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg()); } this.album = ID3Tags.truncate(album, FIELD_ALBUM_LENGTH); }
Set Album @param album
ID3v1Tag::setAlbum
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirstAlbum() { return album; }
Get Album @return album
ID3v1Tag::getFirstAlbum
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<TagField> getAlbum() { if (getFirstAlbum().length() > 0) { ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.ALBUM.name(), getFirstAlbum()); return returnFieldToList(field); } else { return new ArrayList<TagField>(); } }
@return album within list or empty if does not exist
ID3v1Tag::getAlbum
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void setArtist(String artist) { if (artist == null) { throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg()); } this.artist = ID3Tags.truncate(artist, FIELD_ARTIST_LENGTH); }
Set Artist @param artist
ID3v1Tag::setArtist
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirstArtist() { return artist; }
Get Artist @return artist
ID3v1Tag::getFirstArtist
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<TagField> getArtist() { if (getFirstArtist().length() > 0) { ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.ARTIST.name(), getFirstArtist()); return returnFieldToList(field); } else { return new ArrayList<TagField>(); } }
@return Artist within list or empty if does not exist
ID3v1Tag::getArtist
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void setComment(String comment) { if (comment == null) { throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg()); } this.comment = ID3Tags.truncate(comment, FIELD_COMMENT_LENGTH); }
Set Comment @param comment @throws IllegalArgumentException if comment null
ID3v1Tag::setComment
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<TagField> getComment() { if (getFirstComment().length() > 0) { ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.COMMENT.name(), getFirstComment()); return returnFieldToList(field); } else { return new ArrayList<TagField>(); } }
@return comment within list or empty if does not exist
ID3v1Tag::getComment
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirstComment() { return comment; }
Get Comment @return comment
ID3v1Tag::getFirstComment
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void setGenre(String genreVal) { if (genreVal == null) { throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg()); } Integer genreID = GenreTypes.getInstanceOf().getIdForValue(genreVal); if (genreID != null) { this.genre = genreID.byteValue(); } else { this.genre = (byte) GENRE_UNDEFINED; } }
Sets the genreID, <p>ID3v1 only supports genres defined in a predefined list so if unable to find value in list set 255, which seems to be the value winamp uses for undefined. @param genreVal
ID3v1Tag::setGenre
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirstGenre() { Integer genreId = genre & BYTE_TO_UNSIGNED; String genreValue = GenreTypes.getInstanceOf().getValueForId(genreId); if (genreValue == null) { return ""; } else { return genreValue; } }
Get Genre @return genre or empty string if not valid
ID3v1Tag::getFirstGenre
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<TagField> getGenre() { if (getFirst(FieldKey.GENRE).length() > 0) { ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.GENRE.name(), getFirst(FieldKey.GENRE)); return returnFieldToList(field); } else { return new ArrayList<TagField>(); } }
Get Genre field <p>Only a single genre is available in ID3v1 @return
ID3v1Tag::getGenre
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void setTitle(String title) { if (title == null) { throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg()); } this.title = ID3Tags.truncate(title, FIELD_TITLE_LENGTH); }
Set Title @param title
ID3v1Tag::setTitle
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirstTitle() { return title; }
Get title @return Title
ID3v1Tag::getFirstTitle
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<TagField> getTitle() { if (getFirst(FieldKey.TITLE).length() > 0) { ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.TITLE.name(), getFirst(FieldKey.TITLE)); return returnFieldToList(field); } else { return new ArrayList<TagField>(); } }
Get title field <p>Only a single title is available in ID3v1 @return
ID3v1Tag::getTitle
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void setYear(String year) { this.year = ID3Tags.truncate(year, FIELD_YEAR_LENGTH); }
Set year @param year
ID3v1Tag::setYear
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirstYear() { return year; }
Get year @return year
ID3v1Tag::getFirstYear
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<TagField> getYear() { if (getFirst(FieldKey.YEAR).length() > 0) { ID3v1TagField field = new ID3v1TagField(ID3v1FieldKey.YEAR.name(), getFirst(FieldKey.YEAR)); return returnFieldToList(field); } else { return new ArrayList<TagField>(); } }
Get year field <p>Only a single year is available in ID3v1 @return
ID3v1Tag::getYear
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public TagField createField(FieldKey genericKey, String... values) { String value = values[0]; if (genericKey == null) { throw new IllegalArgumentException(ErrorMessage.GENERAL_INVALID_NULL_ARGUMENT.getMsg()); } ID3v1FieldKey idv1FieldKey = tagFieldToID3v1Field.get(genericKey); if(idv1FieldKey==null) { throw new KeyNotFoundException(ErrorMessage.INVALID_FIELD_FOR_ID3V1TAG.getMsg(genericKey.name())); } return new ID3v1TagField(idv1FieldKey .name(), value); }
Create Tag Field using generic key
ID3v1Tag::createField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public List<TagField> getFields(FieldKey genericKey) { switch (genericKey) { case ARTIST: return getArtist(); case ALBUM: return getAlbum(); case TITLE: return getTitle(); case GENRE: return getGenre(); case YEAR: return getYear(); case COMMENT: return getComment(); default: return new ArrayList<TagField>(); } }
Returns a {@linkplain List list} of {@link TagField} objects whose &quot;{@linkplain TagField#getId() id}&quot; is the specified one.<br> @param genericKey The generic field key @return A list of {@link TagField} objects with the given &quot;id&quot;.
ID3v1Tag::getFields
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirst(String genericKey) { FieldKey matchingKey = FieldKey.valueOf(genericKey); if (matchingKey != null) { return getFirst(matchingKey); } else { return ""; } }
Retrieve the first value that exists for this key id @param genericKey @return
ID3v1Tag::getFirst
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getFirst(FieldKey genericKey) { switch (genericKey) { case ARTIST: return getFirstArtist(); case ALBUM: return getFirstAlbum(); case TITLE: return getFirstTitle(); case GENRE: return getFirstGenre(); case YEAR: return getFirstYear(); case COMMENT: return getFirstComment(); default: return ""; } }
Retrieve the first value that exists for this generic key @param genericKey @return
ID3v1Tag::getFirst
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public String getSubValue(FieldKey id, int n, int m) { return getValue(id,n); }
The m parameter is effectively ignored @param id @param n @param m @return
ID3v1Tag::getSubValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void deleteField(FieldKey genericKey) { switch (genericKey) { case ARTIST: setArtist(""); break; case ALBUM: setAlbum(""); break; case TITLE: setTitle(""); break; case GENRE: setGenre(""); break; case YEAR: setYear(""); break; case COMMENT: setComment(""); break; } }
Delete any instance of tag fields with this key @param genericKey
ID3v1Tag::deleteField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public boolean equals(Object obj) { if (!(obj instanceof ID3v1Tag object)) { return false; } if (!this.album.equals(object.album)) { return false; } if (!this.artist.equals(object.artist)) { return false; } if (!this.comment.equals(object.comment)) { return false; } if (this.genre != object.genre) { return false; } if (!this.title.equals(object.title)) { return false; } return this.year.equals(object.year) && super.equals(obj); }
@param obj @return true if this and obj are equivalent
ID3v1Tag::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public Iterator iterator() { return new ID3v1Iterator(this); }
@return an iterator to iterate through the fields of the tag
ID3v1Tag::iterator
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void read(ByteBuffer byteBuffer) throws TagNotFoundException { if (!seek(byteBuffer)) { throw new TagNotFoundException(getLoggingFilename() + ":" + "ID3v1 tag not found"); } logger.finer(getLoggingFilename() + ":" + "Reading v1 tag"); //Do single file read of data to cut down on file reads byte[] dataBuffer = new byte[TAG_LENGTH]; byteBuffer.position(0); byteBuffer.get(dataBuffer, 0, TAG_LENGTH); title = new String(dataBuffer, FIELD_TITLE_POS, FIELD_TITLE_LENGTH, StandardCharsets.ISO_8859_1).trim(); Matcher m = AbstractID3v1Tag.endofStringPattern.matcher(title); if (m.find()) { title = title.substring(0, m.start()); } artist = new String(dataBuffer, FIELD_ARTIST_POS, FIELD_ARTIST_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(artist); if (m.find()) { artist = artist.substring(0, m.start()); } album = new String(dataBuffer, FIELD_ALBUM_POS, FIELD_ALBUM_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(album); logger.finest(getLoggingFilename() + ":" + "Orig Album is:" + comment + ":"); if (m.find()) { album = album.substring(0, m.start()); logger.finest(getLoggingFilename() + ":" + "Album is:" + album + ":"); } year = new String(dataBuffer, FIELD_YEAR_POS, FIELD_YEAR_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(year); if (m.find()) { year = year.substring(0, m.start()); } comment = new String(dataBuffer, FIELD_COMMENT_POS, FIELD_COMMENT_LENGTH, StandardCharsets.ISO_8859_1).trim(); m = AbstractID3v1Tag.endofStringPattern.matcher(comment); logger.finest(getLoggingFilename() + ":" + "Orig Comment is:" + comment + ":"); if (m.find()) { comment = comment.substring(0, m.start()); logger.finest(getLoggingFilename() + ":" + "Comment is:" + comment + ":"); } genre = dataBuffer[FIELD_GENRE_POS]; }
@param byteBuffer @throws TagNotFoundException
ID3v1Tag::read
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public boolean seek(ByteBuffer byteBuffer) { byte[] buffer = new byte[FIELD_TAGID_LENGTH]; // read the TAG value byteBuffer.get(buffer, 0, FIELD_TAGID_LENGTH); return (Arrays.equals(buffer, TAG_ID)); }
Does a tag of this version exist within the byteBuffer @return whether tag exists within the byteBuffer
ID3v1Tag::seek
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void write(RandomAccessFile file) throws IOException { logger.config("Saving ID3v1 tag to file"); byte[] buffer = new byte[TAG_LENGTH]; int i; String str; delete(file); file.seek(file.length()); //Copy the TAGID into new buffer System.arraycopy(TAG_ID, FIELD_TAGID_POS, buffer, FIELD_TAGID_POS, TAG_ID.length); int offset = FIELD_TITLE_POS; if (TagOptionSingleton.getInstance().isId3v1SaveTitle()) { str = ID3Tags.truncate(title, FIELD_TITLE_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_ARTIST_POS; if (TagOptionSingleton.getInstance().isId3v1SaveArtist()) { str = ID3Tags.truncate(artist, FIELD_ARTIST_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_ALBUM_POS; if (TagOptionSingleton.getInstance().isId3v1SaveAlbum()) { str = ID3Tags.truncate(album, FIELD_ALBUM_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_YEAR_POS; if (TagOptionSingleton.getInstance().isId3v1SaveYear()) { str = ID3Tags.truncate(year, AbstractID3v1Tag.FIELD_YEAR_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_COMMENT_POS; if (TagOptionSingleton.getInstance().isId3v1SaveComment()) { str = ID3Tags.truncate(comment, FIELD_COMMENT_LENGTH); for (i = 0; i < str.length(); i++) { buffer[i + offset] = (byte) str.charAt(i); } } offset = FIELD_GENRE_POS; if (TagOptionSingleton.getInstance().isId3v1SaveGenre()) { buffer[offset] = genre; } file.write(buffer); logger.config("Saved ID3v1 tag to file"); }
Write this tag to the file, replacing any tag previously existing @param file @throws IOException
ID3v1Tag::write
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void createStructure() { MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier()); //Header MP3File.getStructureFormatter().addElement(TYPE_TITLE, this.title); MP3File.getStructureFormatter().addElement(TYPE_ARTIST, this.artist); MP3File.getStructureFormatter().addElement(TYPE_ALBUM, this.album); MP3File.getStructureFormatter().addElement(TYPE_YEAR, this.year); MP3File.getStructureFormatter().addElement(TYPE_COMMENT, this.comment); MP3File.getStructureFormatter().addElement(TYPE_GENRE, this.genre); MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG); }
Create structured representation of this item.
ID3v1Tag::createStructure
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public void deleteArtworkField() throws KeyNotFoundException { throw new UnsupportedOperationException(ErrorMessage.GENERIC_NOT_SUPPORTED.getMsg()); }
Delete all instance of artwork Field @throws KeyNotFoundException
ID3v1Tag::deleteArtworkField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Tag.java
Apache-2.0
public ID3v23Frame() { }
Creates a new ID3v23 Frame
ID3v23Frame::ID3v23Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public ID3v23Frame(String identifier) { super(identifier); statusFlags = new StatusFlags(); encodingFlags = new EncodingFlags(); }
Creates a new ID3v23 Frame of type identifier. <p>An empty body of the correct type will be automatically created. This constructor should be used when wish to create a new frame from scratch using user data. @param identifier
ID3v23Frame::ID3v23Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public ID3v23Frame(ID3v23Frame frame) { super(frame); statusFlags = new StatusFlags(frame.getStatusFlags().getOriginalFlags()); encodingFlags = new EncodingFlags(frame.getEncodingFlags().getFlags()); }
Copy Constructor Creates a new v23 frame based on another v23 frame @param frame
ID3v23Frame::ID3v23Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
protected ID3v23Frame(ID3v24Frame frame, String identifier) throws InvalidFrameException { this.identifier=identifier; statusFlags = new StatusFlags((ID3v24Frame.StatusFlags) frame.getStatusFlags()); encodingFlags = new EncodingFlags(frame.getEncodingFlags().getFlags()); }
Partially construct ID3v24 Frame form an IS3v23Frame Used for Special Cases @param frame @param identifier @throws InvalidFrameException
ID3v23Frame::ID3v23Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public ID3v23Frame(AbstractID3v2Frame frame) throws InvalidFrameException { logger.finer("Creating frame from a frame of a different version"); if (frame instanceof ID3v23Frame) { throw new UnsupportedOperationException("Copy Constructor not called. Please type cast the argument"); } else if (frame instanceof ID3v22Frame) { statusFlags = new StatusFlags(); encodingFlags = new EncodingFlags(); } else if (frame instanceof ID3v24Frame) { statusFlags = new StatusFlags((ID3v24Frame.StatusFlags) frame.getStatusFlags()); encodingFlags = new EncodingFlags(frame.getEncodingFlags().getFlags()); } if (frame instanceof ID3v24Frame) { //Unknown Frame e.g NCON, also protects when known id but has unsupported frame body if (frame.getBody() instanceof FrameBodyUnsupported) { this.frameBody = new FrameBodyUnsupported((FrameBodyUnsupported) frame.getBody()); this.frameBody.setHeader(this); identifier = frame.getIdentifier(); logger.config("UNKNOWN:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier); return; } // Deprecated frame for v24 else if (frame.getBody() instanceof FrameBodyDeprecated) { //Was it valid for this tag version, if so try and reconstruct if (ID3Tags.isID3v23FrameIdentifier(frame.getIdentifier())) { this.frameBody = ((FrameBodyDeprecated) frame.getBody()).getOriginalFrameBody(); this.frameBody.setHeader(this); this.frameBody.setTextEncoding(ID3TextEncodingConversion.getTextEncoding(this,this.frameBody.getTextEncoding())); identifier = frame.getIdentifier(); logger.config("DEPRECATED:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier); } //or was it still deprecated, if so leave as is else { this.frameBody = new FrameBodyDeprecated((FrameBodyDeprecated) frame.getBody()); this.frameBody.setHeader(this); this.frameBody.setTextEncoding(ID3TextEncodingConversion.getTextEncoding(this,this.frameBody.getTextEncoding())); identifier = frame.getIdentifier(); logger.config("DEPRECATED:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier); return; } } else if (ID3Tags.isID3v24FrameIdentifier(frame.getIdentifier())) { logger.finer("isID3v24FrameIdentifier"); //Version between v4 and v3 identifier = ID3Tags.convertFrameID24To23(frame.getIdentifier()); if (identifier != null) { logger.finer("V4:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier); this.frameBody = (AbstractTagFrameBody) ID3Tags.copyObject(frame.getBody()); this.frameBody.setHeader(this); this.frameBody.setTextEncoding(ID3TextEncodingConversion.getTextEncoding(this,this.frameBody.getTextEncoding())); return; } else { //Is it a known v4 frame which needs forcing to v3 frame e.g. TDRC - TYER,TDAT identifier = ID3Tags.forceFrameID24To23(frame.getIdentifier()); if (identifier != null) { logger.finer("V4:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier); this.frameBody = this.readBody(identifier, (AbstractID3v2FrameBody) frame.getBody()); this.frameBody.setHeader(this); this.frameBody.setTextEncoding(ID3TextEncodingConversion.getTextEncoding(this,this.frameBody.getTextEncoding())); return; } //It is a v24 frame that is not known and cannot be forced in v23 e.g TDRL,in which case //we convert to a frameBody unsupported by writing contents as a byte array and feeding //it into FrameBodyUnsupported else { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ((AbstractID3v2FrameBody) frame.getBody()).write(baos); identifier = frame.getIdentifier(); this.frameBody = new FrameBodyUnsupported(identifier, baos.toByteArray()); this.frameBody.setHeader(this); logger.finer("V4:Orig id is:" + frame.getIdentifier() + ":New Id Unsupported is:" + identifier); return; } } } // Unable to find a suitable frameBody, this should not happen else { logger.severe("Orig id is:" + frame.getIdentifier() + "Unable to create Frame Body"); throw new InvalidFrameException("Orig id is:" + frame.getIdentifier() + "Unable to create Frame Body"); } } else if (frame instanceof ID3v22Frame) { if (ID3Tags.isID3v22FrameIdentifier(frame.getIdentifier())) { identifier = ID3Tags.convertFrameID22To23(frame.getIdentifier()); if (identifier != null) { logger.config("V3:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier); this.frameBody = (AbstractTagFrameBody) ID3Tags.copyObject(frame.getBody()); this.frameBody.setHeader(this); return; } //Is it a known v2 frame which needs forcing to v23 frame e.g PIC - APIC else if (ID3Tags.isID3v22FrameIdentifier(frame.getIdentifier())) { //Force v2 to v3 identifier = ID3Tags.forceFrameID22To23(frame.getIdentifier()); if (identifier != null) { logger.config("V22Orig id is:" + frame.getIdentifier() + "New id is:" + identifier); this.frameBody = this.readBody(identifier, (AbstractID3v2FrameBody) frame.getBody()); this.frameBody.setHeader(this); return; } //No mechanism exists to convert it to a v23 frame else { this.frameBody = new FrameBodyDeprecated((AbstractID3v2FrameBody) frame.getBody()); this.frameBody.setHeader(this); identifier = frame.getIdentifier(); logger.config("Deprecated:V22:orig id id is:" + frame.getIdentifier() + ":New id is:" + identifier); return; } } } // Unknown Frame e.g NCON else { this.frameBody = new FrameBodyUnsupported((FrameBodyUnsupported) frame.getBody()); this.frameBody.setHeader(this); identifier = frame.getIdentifier(); logger.config("UNKNOWN:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier); return; } } logger.warning("Frame is unknown version:"+frame.getClass()); }
Creates a new ID3v23Frame based on another frame of a different version. @param frame @throws org.jaudiotagger.tag.InvalidFrameException
ID3v23Frame::ID3v23Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public ID3v23Frame(ByteBuffer byteBuffer, String loggingFilename) throws InvalidFrameException, InvalidDataTypeException { setLoggingFilename(loggingFilename); read(byteBuffer); }
Creates a new ID3v23Frame dataType by reading from byteBuffer. @param byteBuffer to read from @param loggingFilename @throws org.jaudiotagger.tag.InvalidFrameException
ID3v23Frame::ID3v23Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public ID3v23Frame(ByteBuffer byteBuffer) throws InvalidFrameException, InvalidDataTypeException { this(byteBuffer, ""); }
Creates a new ID3v23Frame dataType by reading from byteBuffer. @param byteBuffer to read from @deprecated use {@link #ID3v23Frame(ByteBuffer,String)} instead @throws org.jaudiotagger.tag.InvalidFrameException
ID3v23Frame::ID3v23Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public int getSize() { return frameBody.getSize() + ID3v23Frame.FRAME_HEADER_SIZE; }
Return size of frame @return int frame size
ID3v23Frame::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public boolean equals(Object obj) { if ( this == obj ) return true; if (!(obj instanceof ID3v23Frame that)) { return false; } return EqualsUtil.areEqual(this.statusFlags, that.statusFlags) && EqualsUtil.areEqual(this.encodingFlags, that.encodingFlags) && super.equals(that); }
Compare for equality To be deemed equal obj must be a IDv23Frame with the same identifier and the same flags. containing the same body,dataType list ectera. equals() method is made up from all the various components @param obj @return if true if this object is equivalent to obj
ID3v23Frame::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public void read(ByteBuffer byteBuffer) throws InvalidFrameException, InvalidDataTypeException { String identifier = readIdentifier(byteBuffer); if (!isValidID3v2FrameIdentifier(identifier)) { logger.config(getLoggingFilename() + ":Invalid identifier:" + identifier); byteBuffer.position(byteBuffer.position() - (getFrameIdSize() - 1)); throw new InvalidFrameIdentifierException(getLoggingFilename() + ":" + identifier + ":is not a valid ID3v2.30 frame"); } //Read the size field (as Big Endian Int - byte buffers always initialised to Big Endian order) frameSize = byteBuffer.getInt(); if (frameSize < 0) { logger.warning(getLoggingFilename() + ":Invalid Frame Size:"+frameSize+":" + identifier); throw new InvalidFrameException(identifier + " is invalid frame:"+frameSize); } else if (frameSize == 0) { logger.warning(getLoggingFilename() + ":Empty Frame Size:" + identifier); //We don't process this frame or add to frameMap because contains no useful information //Skip the two flag bytes so in correct position for subsequent frames byteBuffer.get(); byteBuffer.get(); throw new EmptyFrameException(identifier + " is empty frame"); } else if (frameSize > byteBuffer.remaining()) { logger.warning(getLoggingFilename() + ":Invalid Frame size of " +frameSize +" larger than size of" + byteBuffer.remaining() + " before mp3 audio:" + identifier); throw new InvalidFrameException(identifier + " is invalid frame:"+frameSize +" larger than size of" + byteBuffer.remaining() + " before mp3 audio:" + identifier); } //Read the flag bytes statusFlags = new StatusFlags(byteBuffer.get()); encodingFlags = new EncodingFlags(byteBuffer.get()); String id; //If this identifier is a valid v24 identifier or easily converted to v24 id = ID3Tags.convertFrameID23To24(identifier); // Cant easily be converted to v24 but is it a valid v23 identifier if (id == null) { // It is a valid v23 identifier so should be able to find a // frame body for it. if (ID3Tags.isID3v23FrameIdentifier(identifier)) { id = identifier; } // Unknown so will be created as FrameBodyUnsupported else { id = UNSUPPORTED_ID; } } logger.fine(getLoggingFilename() + ":Identifier was:" + identifier + " reading using:" + id + "with frame size:" + frameSize); //Read extra bits appended to frame header for various encodings //These are not included in header size but are included in frame size but won't be read when we actually //try to read the frame body data int extraHeaderBytesCount = 0; int decompressedFrameSize = -1; if (((EncodingFlags) encodingFlags).isCompression()) { //Read the Decompressed Size decompressedFrameSize = byteBuffer.getInt(); extraHeaderBytesCount = FRAME_COMPRESSION_UNCOMPRESSED_SIZE; logger.fine(getLoggingFilename() + ":Decompressed frame size is:" + decompressedFrameSize); } if (((EncodingFlags) encodingFlags).isEncryption()) { //Consume the encryption byte extraHeaderBytesCount += FRAME_ENCRYPTION_INDICATOR_SIZE; encryptionMethod = byteBuffer.get(); } if (((EncodingFlags) encodingFlags).isGrouping()) { //Read the Grouping byte, but do nothing with it extraHeaderBytesCount += FRAME_GROUPING_INDICATOR_SIZE; groupIdentifier = byteBuffer.get(); } if(((EncodingFlags)encodingFlags).isNonStandardFlags()) { //Probably corrupt so treat as a standard frame logger.severe(getLoggingFilename() + ":InvalidEncodingFlags:" + Hex.asHex(encodingFlags.getFlags())); } if (((EncodingFlags) encodingFlags).isCompression()) { if (decompressedFrameSize > (100 * frameSize)) { throw new InvalidFrameException(identifier + " is invalid frame, frame size " + frameSize + " cannot be:" + decompressedFrameSize + " when uncompressed"); } } //Work out the real size of the frameBody data int realFrameSize = frameSize - extraHeaderBytesCount; if(realFrameSize<=0) { throw new InvalidFrameException(identifier + " is invalid frame, realframeSize is:" + realFrameSize); } ByteBuffer frameBodyBuffer; //Read the body data try { if (((EncodingFlags) encodingFlags).isCompression()) { frameBodyBuffer = ID3Compression.uncompress(identifier,getLoggingFilename(),byteBuffer, decompressedFrameSize, realFrameSize); if(((EncodingFlags) encodingFlags).isEncryption()) { frameBody = readEncryptedBody(id, frameBodyBuffer, decompressedFrameSize); } else { frameBody = readBody(id, frameBodyBuffer, decompressedFrameSize); } } else if (((EncodingFlags) encodingFlags).isEncryption()) { frameBodyBuffer = byteBuffer.slice(); frameBodyBuffer.limit(frameSize); frameBody = readEncryptedBody(identifier, frameBodyBuffer, frameSize); } else { //Create Buffer that only contains the body of this frame rather than the remainder of tag frameBodyBuffer = byteBuffer.slice(); frameBodyBuffer.limit(realFrameSize); frameBody = readBody(id, frameBodyBuffer, realFrameSize); } //TODO code seems to assume that if the frame created is not a v23FrameBody //it should be deprecated, but what about if somehow a V24Frame has been put into a V23 Tag, shouldn't //it then be created as FrameBodyUnsupported if (!(frameBody instanceof ID3v23FrameBody)) { logger.config(getLoggingFilename() + ":Converted frameBody with:" + identifier + " to deprecated frameBody"); frameBody = new FrameBodyDeprecated((AbstractID3v2FrameBody) frameBody); } } finally { //Update position of main buffer, so no attempt is made to reread these bytes byteBuffer.position(byteBuffer.position() + realFrameSize); } }
Read the frame from a byteBuffer @param byteBuffer buffer to read from
ID3v23Frame::read
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public void write(ByteArrayOutputStream tagBuffer) { logger.config("Writing frame to buffer:" + getIdentifier()); //This is where we will write header, move position to where we can //write body ByteBuffer headerBuffer = ByteBuffer.allocate(FRAME_HEADER_SIZE); //Write Frame Body Data ByteArrayOutputStream bodyOutputStream = new ByteArrayOutputStream(); ((AbstractID3v2FrameBody) frameBody).write(bodyOutputStream); //Write Frame Header write Frame ID if (getIdentifier().length() == 3) { identifier = identifier + ' '; } headerBuffer.put(getIdentifier().getBytes(StandardCharsets.ISO_8859_1), 0, FRAME_ID_SIZE); //Write Frame Size int size = frameBody.getSize(); logger.fine("Frame Size Is:" + size); headerBuffer.putInt(frameBody.getSize()); //Write the Flags //Status Flags:leave as they were when we read headerBuffer.put(statusFlags.getWriteFlags()); //Remove any non standard flags ((EncodingFlags) encodingFlags).unsetNonStandardFlags(); //Unset Compression flag if previously set because we uncompress previously compressed frames on write. ((EncodingFlags)encodingFlags).unsetCompression(); headerBuffer.put(encodingFlags.getFlags()); try { //Add header to the Byte Array Output Stream tagBuffer.write(headerBuffer.array()); if (((EncodingFlags) encodingFlags).isEncryption()) { tagBuffer.write(encryptionMethod); } if (((EncodingFlags) encodingFlags).isGrouping()) { tagBuffer.write(groupIdentifier); } //Add body to the Byte Array Output Stream tagBuffer.write(bodyOutputStream.toByteArray()); } catch (IOException ioe) { //This could never happen coz not writing to file, so convert to RuntimeException throw new RuntimeException(ioe); } }
Write the frame to bufferOutputStream
ID3v23Frame::write
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
StatusFlags(ID3v24Frame.StatusFlags statusFlags) { originalFlags = convertV4ToV3Flags(statusFlags.getOriginalFlags()); writeFlags = originalFlags; modifyFlags(); }
Use this constructor when convert a v24 frame @param statusFlags
StatusFlags::StatusFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public boolean isValidID3v2FrameIdentifier(String identifier) { Matcher m = ID3v23Frame.validFrameIdentifier.matcher(identifier); return m.matches(); }
Does the frame identifier meet the syntax for a idv3v2 frame identifier. must start with a capital letter and only contain capital letters and numbers @param identifier to be checked @return whether the identifier is valid
EncodingFlags::isValidID3v2FrameIdentifier
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public void createStructure() { MP3File.getStructureFormatter().openHeadingElement(TYPE_FRAME, getIdentifier()); MP3File.getStructureFormatter().addElement(TYPE_FRAME_SIZE, frameSize); statusFlags.createStructure(); encodingFlags.createStructure(); frameBody.createStructure(); MP3File.getStructureFormatter().closeHeadingElement(TYPE_FRAME); }
Return String Representation of body
EncodingFlags::createStructure
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public boolean isCommon() { return ID3v23Frames.getInstanceOf().isCommon(getId()); }
@return true if considered a common frame
EncodingFlags::isCommon
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public boolean isBinary() { return ID3v23Frames.getInstanceOf().isBinary(getId()); }
@return true if considered a common frame
EncodingFlags::isBinary
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public void setEncoding(final Charset encoding) { Integer encodingId = TextEncoding.getInstanceOf().getIdForCharset(encoding); if(encodingId!=null) { if(encodingId <2) { this.getBody().setTextEncoding(encodingId.byteValue()); } } }
Sets the charset encoding used by the field. @param encoding charset.
EncodingFlags::setEncoding
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Frame.java
Apache-2.0
public ID3v22Frame(AbstractID3v2FrameBody body) { super(body); }
Creates a new ID3v22 Frame with given body @param body New body and frame is based on this
ID3v22Frame::ID3v22Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public boolean equals(Object obj) { if ( this == obj ) return true; if (!(obj instanceof ID3v22Frame that)) { return false; } return EqualsUtil.areEqual(this.statusFlags, that.statusFlags) && EqualsUtil.areEqual(this.encodingFlags, that.encodingFlags) && super.equals(that); }
Compare for equality To be deemed equal obj must be a IDv23Frame with the same identifier and the same flags. containing the same body,datatype list ectera. equals() method is made up from all the various components @param obj @return if true if this object is equivalent to obj
ID3v22Frame::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public ID3v22Frame(ID3v22Frame frame) { super(frame); logger.config("Creating frame from a frame of same version"); }
Copy Constructor Creates a new v22 frame based on another v22 frame @param frame
ID3v22Frame::ID3v22Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public ID3v22Frame(AbstractID3v2Frame frame) throws InvalidFrameException { logger.config("Creating frame from a frame of a different version"); if (frame instanceof ID3v22Frame) { throw new UnsupportedOperationException("Copy Constructor not called. Please type cast the argument"); } // If it is a v24 frame is it possible to convert it into a v23 frame, and then convert from that if (frame instanceof ID3v24Frame) { ID3v23Frame v23Frame = new ID3v23Frame(frame); createV22FrameFromV23Frame(v23Frame); } //If it is a v23 frame is it possible to convert it into a v22 frame else if (frame instanceof ID3v23Frame) { createV22FrameFromV23Frame((ID3v23Frame) frame); } this.frameBody.setHeader(this); logger.config("Created frame from a frame of a different version"); }
Creates a new ID3v22 Frame from another frame of a different tag version @param frame to construct the new frame from @throws org.jaudiotagger.tag.InvalidFrameException
ID3v22Frame::ID3v22Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public ID3v22Frame(ByteBuffer byteBuffer, String loggingFilename) throws InvalidFrameException, InvalidDataTypeException { setLoggingFilename(loggingFilename); read(byteBuffer); }
Creates a new ID3v22Frame datatype by reading from byteBuffer. @param byteBuffer to read from @param loggingFilename @throws org.jaudiotagger.tag.InvalidFrameException
ID3v22Frame::ID3v22Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public ID3v22Frame(ByteBuffer byteBuffer) throws InvalidFrameException, InvalidDataTypeException { this(byteBuffer, ""); }
Creates a new ID3v23Frame datatype by reading from byteBuffer. @param byteBuffer to read from @deprecated use {@link #ID3v22Frame(ByteBuffer,String)} instead @throws org.jaudiotagger.tag.InvalidFrameException
ID3v22Frame::ID3v22Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public int getSize() { return frameBody.getSize() + getFrameHeaderSize(); }
Return size of frame @return int size of frame
ID3v22Frame::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public void read(ByteBuffer byteBuffer) throws InvalidFrameException, InvalidDataTypeException { String identifier = readIdentifier(byteBuffer); byte[] buffer = new byte[getFrameSizeSize()]; // Is this a valid identifier? if (!isValidID3v2FrameIdentifier(identifier)) { logger.config("Invalid identifier:" + identifier); byteBuffer.position(byteBuffer.position() - (getFrameIdSize() - 1)); throw new InvalidFrameIdentifierException(getLoggingFilename() + ":" + identifier + ":is not a valid ID3v2.20 frame"); } //Read Frame Size (same size as Frame Id so reuse buffer) byteBuffer.get(buffer, 0, getFrameSizeSize()); frameSize = decodeSize(buffer); if (frameSize < 0) { throw new InvalidFrameException(identifier + " has invalid size of:" + frameSize); } else if (frameSize == 0) { //We dont process this frame or add to framemap becuase contains no useful information logger.warning("Empty Frame:" + identifier); throw new EmptyFrameException(identifier + " is empty frame"); } else if (frameSize > byteBuffer.remaining()) { logger.warning("Invalid Frame size larger than size before mp3 audio:" + identifier); throw new InvalidFrameException(identifier + " is invalid frame"); } else { logger.fine("Frame Size Is:" + frameSize); //Convert v2.2 to v2.4 id just for reading the data String id = ID3Tags.convertFrameID22To24(identifier); if (id == null) { //OK,it may be convertable to a v.3 id even though not valid v.4 id = ID3Tags.convertFrameID22To23(identifier); if (id == null) { // Is it a valid v22 identifier so should be able to find a // frame body for it. if (ID3Tags.isID3v22FrameIdentifier(identifier)) { id = identifier; } // Unknown so will be created as FrameBodyUnsupported else { id = UNSUPPORTED_ID; } } } logger.fine("Identifier was:" + identifier + " reading using:" + id); //Create Buffer that only contains the body of this frame rather than the remainder of tag ByteBuffer frameBodyBuffer = byteBuffer.slice(); frameBodyBuffer.limit(frameSize); try { frameBody = readBody(id, frameBodyBuffer, frameSize); } finally { //Update position of main buffer, so no attempt is made to reread these bytes byteBuffer.position(byteBuffer.position() + frameSize); } } }
Read frame from file. Read the frame header then delegate reading of data to frame body. @param byteBuffer
ID3v22Frame::read
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
private int decodeSize(byte[] buffer) { BigInteger bi = new BigInteger(buffer); int tmpSize = bi.intValue(); if (tmpSize < 0) { logger.warning("Invalid Frame Size of:" + tmpSize + "Decoded from bin:" + Integer.toBinaryString(tmpSize) + "Decoded from hex:" + Integer.toHexString(tmpSize)); } return tmpSize; }
Read Frame Size, which has to be decoded @param buffer @return
ID3v22Frame::decodeSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public void write(ByteArrayOutputStream tagBuffer) { logger.config("Write Frame to Buffer" + getIdentifier()); //This is where we will write header, move position to where we can //write body ByteBuffer headerBuffer = ByteBuffer.allocate(getFrameHeaderSize()); //Write Frame Body Data ByteArrayOutputStream bodyOutputStream = new ByteArrayOutputStream(); ((AbstractID3v2FrameBody) frameBody).write(bodyOutputStream); //Write Frame Header //Write Frame ID must adjust can only be 3 bytes long headerBuffer.put(getIdentifier().getBytes(StandardCharsets.ISO_8859_1), 0, getFrameIdSize()); encodeSize(headerBuffer, frameBody.getSize()); //Add header to the Byte Array Output Stream try { tagBuffer.write(headerBuffer.array()); //Add body to the Byte Array Output Stream tagBuffer.write(bodyOutputStream.toByteArray()); } catch (IOException ioe) { //This could never happen coz not writing to file, so convert to RuntimeException throw new RuntimeException(ioe); } }
Write Frame raw data
ID3v22Frame::write
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
private void encodeSize(ByteBuffer headerBuffer, int size) { headerBuffer.put((byte) ((size & 0x00FF0000) >> 16)); headerBuffer.put((byte) ((size & 0x0000FF00) >> 8)); headerBuffer.put((byte) (size & 0x000000FF)); logger.fine("Frame Size Is Actual:" + size + ":Encoded bin:" + Integer.toBinaryString(size) + ":Encoded Hex" + Integer.toHexString(size)); }
Write Frame Size (can now be accurately calculated, have to convert 4 byte int to 3 byte format. @param headerBuffer @param size
ID3v22Frame::encodeSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public boolean isValidID3v2FrameIdentifier(String identifier) { Matcher m = ID3v22Frame.validFrameIdentifier.matcher(identifier); return m.matches(); }
Does the frame identifier meet the syntax for a idv3v2 frame identifier. must start with a capital letter and only contain capital letters and numbers @param identifier @return
ID3v22Frame::isValidID3v2FrameIdentifier
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public void createStructure() { MP3File.getStructureFormatter().openHeadingElement(TYPE_FRAME, getIdentifier()); MP3File.getStructureFormatter().addElement(TYPE_FRAME_SIZE, frameSize); frameBody.createStructure(); MP3File.getStructureFormatter().closeHeadingElement(TYPE_FRAME); }
Return String Representation of body
ID3v22Frame::createStructure
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public boolean isCommon() { return ID3v22Frames.getInstanceOf().isCommon(getId()); }
@return true if considered a common frame
ID3v22Frame::isCommon
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public boolean isBinary() { return ID3v22Frames.getInstanceOf().isBinary(getId()); }
@return true if considered a common frame
ID3v22Frame::isBinary
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public void setEncoding(final Charset encoding) { Integer encodingId = TextEncoding.getInstanceOf().getIdForCharset(encoding); if(encodingId!=null) { if(encodingId <2) { this.getBody().setTextEncoding(encodingId.byteValue()); } } }
Sets the charset encoding used by the field. @param encoding charset.
ID3v22Frame::setEncoding
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frame.java
Apache-2.0
public boolean isDiscardIfFileAltered(String frameID) { return discardIfFileAlteredFrames.contains(frameID); }
If file changes discard these frames @param frameID @return
ID3Frames::isDiscardIfFileAltered
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
Apache-2.0
public boolean isMultipleAllowed(String frameID) { return multipleFrames.contains(frameID); }
Are multiple occurrences of frame allowed @param frameID @return
ID3Frames::isMultipleAllowed
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
Apache-2.0
public boolean isSupportedFrames(String frameID) { return supportedFrames.contains(frameID); }
@param frameID @return true if frames with this id are part of the specification
ID3Frames::isSupportedFrames
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
Apache-2.0
public boolean isCommon(String frameID) { return commonFrames.contains(frameID); }
@param frameID @return true if frames with this id are considered common
ID3Frames::isCommon
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
Apache-2.0
public boolean isBinary(String frameID) { return binaryFrames.contains(frameID); }
@param frameID @return true if frames with this id are binary (non textual data)
ID3Frames::isBinary
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
Apache-2.0
public boolean isExtensionFrames(String frameID) { return extensionFrames.contains(frameID); }
@param frameID @return true if frame is a known extension
ID3Frames::isExtensionFrames
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Frames.java
Apache-2.0
public static boolean requiresUnsynchronization(byte[] abySource) { for (int i = 0; i < abySource.length - 1; i++) { if (((abySource[i] & MPEGFrameHeader.SYNC_BYTE1) == MPEGFrameHeader.SYNC_BYTE1) && ((abySource[i + 1] & MPEGFrameHeader.SYNC_BYTE2) == MPEGFrameHeader.SYNC_BYTE2)) { if (logger.isLoggable(Level.FINEST)) { logger.finest("Unsynchronisation required found bit at:" + i); } return true; } } return false; }
Check if a byte array will require unsynchronization before being written as a tag. If the byte array contains any $FF $E0 bytes, then it will require unsynchronization. @param abySource the byte array to be examined @return true if unsynchronization is required, false otherwise
ID3Unsynchronization::requiresUnsynchronization
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Unsynchronization.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Unsynchronization.java
Apache-2.0
public static byte[] unsynchronize(byte[] abySource) { ByteArrayInputStream input = new ByteArrayInputStream(abySource); ByteArrayOutputStream output = new ByteArrayOutputStream(abySource.length); int count = 0; while (input.available() > 0) { int firstByte = input.read(); count++; output.write(firstByte); if ((firstByte & MPEGFrameHeader.SYNC_BYTE1) == MPEGFrameHeader.SYNC_BYTE1) { // if byte is $FF, we must check the following byte if there is one if (input.available() > 0) { input.mark(1); // remember where we were, if we don't need to unsynchronize int secondByte = input.read(); if ((secondByte & MPEGFrameHeader.SYNC_BYTE2) == MPEGFrameHeader.SYNC_BYTE2) { // we need to unsynchronize here if (logger.isLoggable(Level.FINEST)) { logger.finest("Writing unsynchronisation bit at:" + count); } output.write(0); } else if (secondByte == 0) { // we need to unsynchronize here if (logger.isLoggable(Level.FINEST)) { logger.finest("Inserting zero unsynchronisation bit at:" + count); } output.write(0); } input.reset(); } } } // if we needed to unsynchronize anything, and this tag ends with 0xff, we have to append a zero byte, // which will be removed on de-unsynchronization later if ((abySource[abySource.length - 1] & MPEGFrameHeader.SYNC_BYTE1) == MPEGFrameHeader.SYNC_BYTE1) { logger.finest("Adding unsynchronisation bit at end of stream"); output.write(0); } return output.toByteArray(); }
Unsynchronize an array of bytes, this should only be called if the decision has already been made to unsynchronize the byte array In order to prevent a media player from incorrectly interpreting the contents of a tag, all $FF bytes followed by a byte with value >=224 must be followed by a $00 byte (thus, $FF $F0 sequences become $FF $00 $F0). Additionally because unsynchronisation is being applied any existing $FF $00 have to be converted to $FF $00 $00 @param abySource a byte array to be unsynchronized @return a unsynchronized representation of the source
ID3Unsynchronization::unsynchronize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Unsynchronization.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Unsynchronization.java
Apache-2.0
protected static ByteBuffer uncompress(String identifier,String filename, ByteBuffer byteBuffer, int decompressedFrameSize, int realFrameSize) throws InvalidFrameException { logger.config(filename + ":About to decompress " + realFrameSize + " bytes, expect result to be:" + decompressedFrameSize + " bytes"); // Decompress the bytes into this buffer, size initialized from header field byte[] result = new byte[decompressedFrameSize]; byte[] input = new byte[realFrameSize]; //Store position ( just after frame header and any extra bits) //Read frame data into array, and then put buffer back to where it was int position = byteBuffer.position(); byteBuffer.get(input, 0, realFrameSize); byteBuffer.position(position); Inflater decompresser = new Inflater(); decompresser.setInput(input); try { int inflatedTo = decompresser.inflate(result); logger.config(filename + ":Decompressed to " + inflatedTo + " bytes"); } catch (DataFormatException dfe) { logger.log(Level.CONFIG,"Unable to decompress this frame:"+identifier,dfe); //Update position of main buffer, so no attempt is made to reread these bytes byteBuffer.position(byteBuffer.position() + realFrameSize); throw new InvalidFrameException(ErrorMessage.ID3_UNABLE_TO_DECOMPRESS_FRAME.getMsg(identifier,filename,dfe.getMessage())); } decompresser.end(); return ByteBuffer.wrap(result); }
Decompress realFrameSize bytes to decompressedFrameSize bytes and return as ByteBuffer @param byteBuffer @param decompressedFrameSize @param realFrameSize @return @throws org.jaudiotagger.tag.InvalidFrameException
ID3Compression::uncompress
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Compression.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Compression.java
Apache-2.0
public ID3v22FieldKey getId3KeyFromGenericKey(FieldKey genericKey) { return tagFieldToId3.get(genericKey); }
@param genericKey @return id3 key for generic key
ID3v22Frames::getId3KeyFromGenericKey
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frames.java
Apache-2.0
public FieldKey getGenericKeyFromId3(ID3v22FieldKey fieldKey) { return id3ToTagField.get(fieldKey); }
Get generic key for ID3 field key @param fieldKey @return
ID3v22Frames::getGenericKeyFromId3
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frames.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Frames.java
Apache-2.0
public boolean equals(Object obj) { return (obj instanceof AbstractTag) && super.equals(obj); }
Determines whether another datatype is equal to this tag. It just compares if they are the same class, then calls <code>super.equals(obj)</code>. @param obj The object to compare @return if they are equal
AbstractTag::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractTag.java
Apache-2.0
public byte getRelease() { return RELEASE; }
Retrieve the Release
ID3v22Tag::getRelease
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
Apache-2.0
public byte getMajorVersion() { return MAJOR_VERSION; }
Retrieve the Major Version
ID3v22Tag::getMajorVersion
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
Apache-2.0
public byte getRevision() { return REVISION; }
Retrieve the Revision
ID3v22Tag::getRevision
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
Apache-2.0
public ID3v22Tag() { frameMap = new LinkedHashMap(); encryptedFrameMap = new LinkedHashMap(); }
Creates a new empty ID3v2_2 tag.
ID3v22Tag::ID3v22Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22Tag.java
Apache-2.0