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 static String forceFrameID24To23(String identifier) { return ID3Frames.forcev24Tov23.get(identifier); }
Force from ID3v2.40 FrameIdentifier to ID3v2.30, this is where the frame and structure has changed between v4 to v3 but we can still do some kind of conversion. @param identifier @return
ID3Tags::forceFrameID24To23
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
Apache-2.0
public static String convertFrameID24To23(String identifier) { String id; if (identifier.length() < 4) { return null; } id = ID3Frames.convertv24Tov23.get(identifier); if (id == null) { if (ID3v23Frames.getInstanceOf().getIdToValueMap().containsKey(identifier)) { id = identifier; } } return id; }
Convert from ID3v24 FrameIdentifier to ID3v23 @param identifier @return
ID3Tags::convertFrameID24To23
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
Apache-2.0
public static Object copyObject(Object copyObject) { Constructor<?> constructor; Class<?>[] constructorParameterArray; Object[] parameterArray; if (copyObject == null) { return null; } try { constructorParameterArray = new Class[1]; constructorParameterArray[0] = copyObject.getClass(); constructor = copyObject.getClass().getConstructor(constructorParameterArray); parameterArray = new Object[1]; parameterArray[0] = copyObject; return constructor.newInstance(parameterArray); } catch (NoSuchMethodException ex) { throw new IllegalArgumentException("NoSuchMethodException: Error finding constructor to create copy:"+copyObject.getClass().getName()); } catch (IllegalAccessException ex) { throw new IllegalArgumentException("IllegalAccessException: No access to run constructor to create copy"+copyObject.getClass().getName()); } catch (InstantiationException ex) { throw new IllegalArgumentException("InstantiationException: Unable to instantiate constructor to copy"+copyObject.getClass().getName()); } catch (java.lang.reflect.InvocationTargetException ex) { if (ex.getCause() instanceof Error) { throw (Error) ex.getCause(); } else if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } else { throw new IllegalArgumentException("InvocationTargetException: Unable to invoke constructor to create copy"); } } }
Unable to instantiate abstract classes, so can't call the copy constructor. So find out the instantiated class name and call the copy constructor through reflection (e.g for a a FrameBody would have to have a constructor that takes another frameBody as the same type as a parameter) @param copyObject @return @throws IllegalArgumentException if no suitable constructor exists
ID3Tags::copyObject
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
Apache-2.0
public static long findNumber(String str) throws TagException { return findNumber(str, 0); }
Find the first whole number that can be parsed from the string @param str string to search @return first whole number that can be parsed from the string @throws TagException
ID3Tags::findNumber
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
Apache-2.0
public static long findNumber(String str, int offset) throws TagException { if (str == null) { throw new NullPointerException("String is null"); } if ((offset < 0) || (offset >= str.length())) { throw new IndexOutOfBoundsException("Offset to image string is out of bounds: offset = " + offset + ", string.length()" + str.length()); } int i; int j; long num; i = offset; while (i < str.length()) { if (((str.charAt(i) >= '0') && (str.charAt(i) <= '9')) || (str.charAt(i) == '-')) { break; } i++; } j = i + 1; while (j < str.length()) { if (((str.charAt(j) < '0') || (str.charAt(j) > '9'))) { break; } j++; } if ((j <= str.length()) && (j > i)) { String toParseNumberFrom = str.substring(i, j); if(!toParseNumberFrom.equals("-")) num = Long.parseLong(toParseNumberFrom); else throw new TagException("Unable to find integer in string: " + str); } else { throw new TagException("Unable to find integer in string: " + str); } return num; }
Find the first whole number that can be parsed from the string @param str string to search @param offset start seaching from this index @return first whole number that can be parsed from the string @throws TagException @throws NullPointerException @throws IndexOutOfBoundsException
ID3Tags::findNumber
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
Apache-2.0
static public String stripChar(String str, char ch) { if (str != null) { char[] buffer = new char[str.length()]; int next = 0; for (int i = 0; i < str.length(); i++) { if (str.charAt(i) != ch) { buffer[next++] = str.charAt(i); } } return new String(buffer, 0, next); } else { return null; } }
Remove all occurances of the given character from the string argument. @param str String to search @param ch character to remove @return new String without the given charcter
ID3Tags::stripChar
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
Apache-2.0
public static String truncate(String str, int len) { if (str == null) { return null; } if (len < 0) { return null; } if (str.length() > len) { return str.substring(0, len); } else { return str; } }
truncate a string if it longer than the argument @param str String to truncate @param len maximum desired length of new string @return
ID3Tags::truncate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3Tags.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
ID3v23PreferredFrameOrderComparator::compare
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23PreferredFrameOrderComparator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23PreferredFrameOrderComparator.java
Apache-2.0
public ID3v24Frame(String identifier) { //Super Constructor creates a frame with empty body of type specified super(identifier); statusFlags = new StatusFlags(); encodingFlags = new EncodingFlags(); }
Creates a new ID3v2_4Frame of type identifier. 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 input @param identifier defines the type of body to be created
ID3v24Frame::ID3v24Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public ID3v24Frame(ID3v24Frame frame) { super(frame); statusFlags = new StatusFlags(frame.getStatusFlags().getOriginalFlags()); encodingFlags = new EncodingFlags(frame.getEncodingFlags().getFlags()); }
Copy Constructor:Creates a new ID3v24 frame datatype based on another frame. @param frame
ID3v24Frame::ID3v24Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
protected ID3v24Frame(ID3v23Frame frame, String identifier) throws InvalidFrameException { this.identifier=identifier; statusFlags = new StatusFlags((ID3v23Frame.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
ID3v24Frame::ID3v24Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public ID3v24Frame(AbstractID3v2Frame frame) throws InvalidFrameException { //Should not be called if ((frame instanceof ID3v24Frame)) { throw new UnsupportedOperationException("Copy Constructor not called. Please type cast the argument"); } else if (frame instanceof ID3v23Frame) { statusFlags = new StatusFlags((ID3v23Frame.StatusFlags) frame.getStatusFlags()); encodingFlags = new EncodingFlags(frame.getEncodingFlags().getFlags()); } else if (frame instanceof ID3v22Frame) { statusFlags = new StatusFlags(); encodingFlags = new EncodingFlags(); } // Convert Identifier. If the id was a known id for the original // version we should be able to convert it to an v24 frame, although it may mean minor // modification to the data. If it was not recognised originally it should remain // unknown. if (frame instanceof ID3v23Frame) { createV24FrameFromV23Frame((ID3v23Frame) frame); } else if (frame instanceof ID3v22Frame) { ID3v23Frame v23Frame = new ID3v23Frame(frame); createV24FrameFromV23Frame(v23Frame); } this.frameBody.setHeader(this); }
Creates a new ID3v24 frame datatype based on another frame of different version Converts the framebody to the equivalent v24 framebody or to UnsupportedFrameBody if identifier is unknown. @param frame to construct a new frame from @throws org.jaudiotagger.tag.InvalidFrameException
ID3v24Frame::ID3v24Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public ID3v24Frame(Lyrics3v2Field field) throws InvalidTagException { String id = field.getIdentifier(); String value; if (id.equals("IND")) { throw new InvalidTagException("Cannot create ID3v2.40 frame from Lyrics3 indications field."); } else if (id.equals("LYR")) { FieldFrameBodyLYR lyric = (FieldFrameBodyLYR) field.getBody(); Lyrics3Line line; Iterator<Lyrics3Line> iterator = lyric.iterator(); FrameBodySYLT sync; FrameBodyUSLT unsync; boolean hasTimeStamp = lyric.hasTimeStamp(); // we'll create only one frame here. // if there is any timestamp at all, we will create a sync'ed frame. sync = new FrameBodySYLT((byte) 0, "ENG", (byte) 2, (byte) 1, "", new byte[0]); unsync = new FrameBodyUSLT((byte) 0, "ENG", "", ""); while (iterator.hasNext()) { line = iterator.next(); if (hasTimeStamp) { // sync.addLyric(line); } else { unsync.addLyric(line); } } if (hasTimeStamp) { this.frameBody = sync; this.frameBody.setHeader(this); } else { this.frameBody = unsync; this.frameBody.setHeader(this); } } else if (id.equals("INF")) { value = ((FieldFrameBodyINF) field.getBody()).getAdditionalInformation(); this.frameBody = new FrameBodyCOMM((byte) 0, "ENG", "", value); this.frameBody.setHeader(this); } else if (id.equals("AUT")) { value = ((FieldFrameBodyAUT) field.getBody()).getAuthor(); this.frameBody = new FrameBodyTCOM((byte) 0, value); this.frameBody.setHeader(this); } else if (id.equals("EAL")) { value = ((FieldFrameBodyEAL) field.getBody()).getAlbum(); this.frameBody = new FrameBodyTALB((byte) 0, value); this.frameBody.setHeader(this); } else if (id.equals("EAR")) { value = ((FieldFrameBodyEAR) field.getBody()).getArtist(); this.frameBody = new FrameBodyTPE1((byte) 0, value); this.frameBody.setHeader(this); } else if (id.equals("ETT")) { value = ((FieldFrameBodyETT) field.getBody()).getTitle(); this.frameBody = new FrameBodyTIT2((byte) 0, value); this.frameBody.setHeader(this); } else if (id.equals("IMG")) { throw new InvalidTagException("Cannot create ID3v2.40 frame from Lyrics3 image field."); } else { throw new InvalidTagException("Cannot caret ID3v2.40 frame from " + id + " Lyrics3 field"); } }
Creates a new ID3v2_4Frame datatype based on Lyrics3. @param field @throws InvalidTagException
ID3v24Frame::ID3v24Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public ID3v24Frame(ByteBuffer byteBuffer, String loggingFilename) throws InvalidFrameException, InvalidDataTypeException { setLoggingFilename(loggingFilename); read(byteBuffer); }
Creates a new ID3v24Frame datatype by reading from byteBuffer. @param byteBuffer to read from @param loggingFilename @throws org.jaudiotagger.tag.InvalidFrameException
ID3v24Frame::ID3v24Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public ID3v24Frame(ByteBuffer byteBuffer) throws InvalidFrameException, InvalidDataTypeException { this(byteBuffer, ""); }
Creates a new ID3v24Frame datatype by reading from byteBuffer. @param byteBuffer to read from @throws org.jaudiotagger.tag.InvalidFrameException @deprecated use {@link #ID3v24Frame(ByteBuffer,String)} instead
ID3v24Frame::ID3v24Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public boolean equals(Object obj) { if (this == obj) return true; if (!(obj instanceof ID3v24Frame that)) { return false; } return EqualsUtil.areEqual(this.statusFlags, that.statusFlags) && EqualsUtil.areEqual(this.encodingFlags, that.encodingFlags) && super.equals(that); }
@param obj @return if obj is equivalent to this frame
ID3v24Frame::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public int getSize() { return frameBody.getSize() + ID3v24Frame.FRAME_HEADER_SIZE; }
Return size of frame @return int frame size
ID3v24Frame::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
private void checkIfFrameSizeThatIsNotSyncSafe(ByteBuffer byteBuffer) throws InvalidFrameException { if (frameSize > ID3SyncSafeInteger.MAX_SAFE_SIZE) { //Set Just after size field this is where we want to be when we leave this if statement int currentPosition = byteBuffer.position(); //Read as nonsync safe integer byteBuffer.position(currentPosition - getFrameIdSize()); int nonSyncSafeFrameSize = byteBuffer.getInt(); //Is the frame size syncsafe, should always be BUT some encoders such as Itunes do not do it properly //so do an easy check now. byteBuffer.position(currentPosition - getFrameIdSize()); boolean isNotSyncSafe = ID3SyncSafeInteger.isBufferNotSyncSafe(byteBuffer); //not relative so need to move position byteBuffer.position(currentPosition); if (isNotSyncSafe) { logger.warning(getLoggingFilename() + ":" + "Frame size is NOT stored as a sync safe integer:" + identifier); //This will return a larger frame size so need to check against buffer size if too large then we are //buggered , give up if (nonSyncSafeFrameSize > (byteBuffer.remaining() - -getFrameFlagsSize())) { logger.warning(getLoggingFilename() + ":" + "Invalid Frame size larger than size before mp3 audio:" + identifier); throw new InvalidFrameException(identifier + " is invalid frame"); } else { frameSize = nonSyncSafeFrameSize; } } else { //appears to be sync safe but lets look at the bytes just after the reported end of this //frame to see if find a valid frame header //Read the Frame Identifier byte[] readAheadbuffer = new byte[getFrameIdSize()]; byteBuffer.position(currentPosition + frameSize + getFrameFlagsSize()); if (byteBuffer.remaining() < getFrameIdSize()) { //There is no padding or framedata we are at end so assume syncsafe //reset position to just after framesize byteBuffer.position(currentPosition); } else { byteBuffer.get(readAheadbuffer, 0, getFrameIdSize()); //reset position to just after framesize byteBuffer.position(currentPosition); String readAheadIdentifier = new String(readAheadbuffer); if (isValidID3v2FrameIdentifier(readAheadIdentifier)) { //Everything ok, so continue } else if (ID3SyncSafeInteger.isBufferEmpty(readAheadbuffer)) { //no data found so assume entered padding in which case assume it is last //frame and we are ok } //haven't found identifier so maybe not syncsafe or maybe there are no more frames, just padding else { //Ok lets try using a non-syncsafe integer //size returned will be larger so is it valid if (nonSyncSafeFrameSize > byteBuffer.remaining() - getFrameFlagsSize()) { //invalid so assume syncsafe byteBuffer.position(currentPosition); } else { readAheadbuffer = new byte[getFrameIdSize()]; byteBuffer.position(currentPosition + nonSyncSafeFrameSize + getFrameFlagsSize()); if (byteBuffer.remaining() >= getFrameIdSize()) { byteBuffer.get(readAheadbuffer, 0, getFrameIdSize()); readAheadIdentifier = new String(readAheadbuffer); //reset position to just after framesize byteBuffer.position(currentPosition); //ok found a valid identifier using non-syncsafe so assume non-syncsafe size //and continue if (isValidID3v2FrameIdentifier(readAheadIdentifier)) { frameSize = nonSyncSafeFrameSize; logger.warning(getLoggingFilename() + ":" + "Assuming frame size is NOT stored as a sync safe integer:" + identifier); } //no data found so assume entered padding in which case assume it is last //frame and we are ok whereas we didn't hit padding when using syncsafe integer //or we wouldn't have got to this point. So assume syncsafe integer ended within //the frame data whereas this has reached end of frames. else if (ID3SyncSafeInteger.isBufferEmpty(readAheadbuffer)) { frameSize = nonSyncSafeFrameSize; logger.warning(getLoggingFilename() + ":" + "Assuming frame size is NOT stored as a sync safe integer:" + identifier); } //invalid so assume syncsafe as that is is the standard else { } } else { //reset position to just after framesize byteBuffer.position(currentPosition); //If the unsync framesize matches exactly the remaining bytes then assume it has the //correct size for the last frame if (byteBuffer.remaining() == 0) { frameSize = nonSyncSafeFrameSize; } //Inconclusive stick with syncsafe else { } } } } } } } }
If frame is greater than certain size it will be decoded differently if unsynchronized to if synchronized Frames with certain byte sequences should be unsynchronized but sometimes editors do not unsynchronize them so this method checks both cases and goes with the option that fits best with the data @param byteBuffer @throws InvalidFrameException
ID3v24Frame::checkIfFrameSizeThatIsNotSyncSafe
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
private void getFrameSize(ByteBuffer byteBuffer) throws InvalidFrameException { //Read frame size as syncsafe integer frameSize = ID3SyncSafeInteger.bufferToValue(byteBuffer); if (frameSize < 0) { logger.warning(getLoggingFilename() + ":" + "Invalid Frame size:" + identifier); throw new InvalidFrameException(identifier + " is invalid frame"); } else if (frameSize == 0) { logger.warning(getLoggingFilename() + ":" + "Empty Frame:" + identifier); //We dont process this frame or add to framemap becuase 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() - FRAME_FLAGS_SIZE)) { logger.warning(getLoggingFilename() + ":" + "Invalid Frame size larger than size before mp3 audio:" + identifier); throw new InvalidFrameException(identifier + " is invalid frame"); } checkIfFrameSizeThatIsNotSyncSafe(byteBuffer); }
Read the frame size form the header, check okay , if not try to fix or just throw exception @param byteBuffer @throws InvalidFrameException
ID3v24Frame::getFrameSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public void read(ByteBuffer byteBuffer) throws InvalidFrameException, InvalidDataTypeException { String identifier = readIdentifier(byteBuffer); //Is this a valid identifier? if (!isValidID3v2FrameIdentifier(identifier)) { //If not valid move file pointer back to one byte after //the original check so can try again. logger.config(getLoggingFilename() + ":" + "Invalid identifier:" + identifier); byteBuffer.position(byteBuffer.position() - (getFrameIdSize() - 1)); throw new InvalidFrameIdentifierException(getLoggingFilename() + ":" + identifier + ":is not a valid ID3v2.30 frame"); } //Get the frame size, adjusted as necessary getFrameSize(byteBuffer); //Read the flag bytes statusFlags = new StatusFlags(byteBuffer.get()); encodingFlags = new EncodingFlags(byteBuffer.get()); //Read extra bits appended to frame header for various encodings //These are not included in header size but are included in frame size but wont be read when we actually //try to read the frame body data int extraHeaderBytesCount = 0; int dataLengthSize = -1; if (((EncodingFlags) encodingFlags).isGrouping()) { extraHeaderBytesCount = ID3v24Frame.FRAME_GROUPING_INDICATOR_SIZE; groupIdentifier=byteBuffer.get(); } if (((EncodingFlags) encodingFlags).isEncryption()) { //Read the Encryption byte, but do nothing with it extraHeaderBytesCount += ID3v24Frame.FRAME_ENCRYPTION_INDICATOR_SIZE; encryptionMethod=byteBuffer.get(); } if (((EncodingFlags) encodingFlags).isDataLengthIndicator()) { //Read the sync safe size field dataLengthSize = ID3SyncSafeInteger.bufferToValue(byteBuffer); extraHeaderBytesCount += FRAME_DATA_LENGTH_SIZE; logger.config(getLoggingFilename() + ":" + "Frame Size Is:" + frameSize + " Data Length Size:" + dataLengthSize); } //Work out the real size of the frameBody data int realFrameSize = frameSize - extraHeaderBytesCount; //Create Buffer that only contains the body of this frame rather than the remainder of tag ByteBuffer frameBodyBuffer = byteBuffer.slice(); frameBodyBuffer.limit(realFrameSize); //Do we need to synchronize the frame body int syncSize = realFrameSize; if (((EncodingFlags) encodingFlags).isUnsynchronised()) { //We only want to synchronize the buffer up to the end of this frame (remember this //buffer contains the remainder of this tag not just this frame), and we cannot just //create a new buffer because when this method returns the position of the buffer is used //to look for the next frame, so we need to modify the buffer. The action of synchronizing causes //bytes to be dropped so the existing buffer is large enough to hold the modifications frameBodyBuffer = ID3Unsynchronization.synchronize(frameBodyBuffer); syncSize = frameBodyBuffer.limit(); logger.config(getLoggingFilename() + ":" + "Frame Size After Syncing is:" + syncSize); } //Read the body data try { if (((EncodingFlags) encodingFlags).isCompression()) { frameBodyBuffer = ID3Compression.uncompress(identifier, getLoggingFilename(), byteBuffer, dataLengthSize, realFrameSize); if(((EncodingFlags) encodingFlags).isEncryption()) { frameBody = readEncryptedBody(identifier, frameBodyBuffer, dataLengthSize); } else { frameBody = readBody(identifier, frameBodyBuffer, dataLengthSize); } } else if (((EncodingFlags) encodingFlags).isEncryption()) { frameBodyBuffer = byteBuffer.slice(); frameBodyBuffer.limit(realFrameSize); frameBody = readEncryptedBody(identifier, byteBuffer,frameSize); } else { frameBody = readBody(identifier, frameBodyBuffer, syncSize); } if (!(frameBody instanceof ID3v24FrameBody)) { logger.config(getLoggingFilename() + ":" + "Converted frame body 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 the specified file. Read the frame header then delegate reading of data to frame body. @param byteBuffer to read the frame from
ID3v24Frame::read
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public void write(ByteArrayOutputStream tagBuffer) { boolean unsynchronization; logger.config("Writing frame to file:" + getIdentifier()); //This is where we will write header, move position to where we can //write bodybuffer ByteBuffer headerBuffer = ByteBuffer.allocate(FRAME_HEADER_SIZE); //Write Frame Body Data to a new stream ByteArrayOutputStream bodyOutputStream = new ByteArrayOutputStream(); ((AbstractID3v2FrameBody) frameBody).write(bodyOutputStream); //Does it need unsynchronizing, and are we allowing unsychronizing byte[] bodyBuffer = bodyOutputStream.toByteArray(); unsynchronization = TagOptionSingleton.getInstance().isUnsyncTags() && ID3Unsynchronization.requiresUnsynchronization(bodyBuffer); if (unsynchronization) { bodyBuffer = ID3Unsynchronization.unsynchronize(bodyBuffer); logger.config("bodybytebuffer:sizeafterunsynchronisation:" + bodyBuffer.length); } //Write Frame Header //Write Frame ID, the identifier must be 4 bytes bytes long it may not be //because converted an unknown v2.2 id (only 3 bytes long) if (getIdentifier().length() == 3) { identifier = identifier + ' '; } headerBuffer.put(getIdentifier().getBytes(StandardCharsets.ISO_8859_1), 0, FRAME_ID_SIZE); //Write Frame Size based on size of body buffer (if it has been unsynced then it size //will have increased accordingly int size = bodyBuffer.length; logger.fine("Frame Size Is:" + size); headerBuffer.put(ID3SyncSafeInteger.valueToBuffer(size)); //Write the Flags //Status Flags:leave as they were when we read headerBuffer.put(statusFlags.getWriteFlags()); //Remove any non standard flags ((ID3v24Frame.EncodingFlags) encodingFlags).unsetNonStandardFlags(); //Encoding we only support unsynchronization if (unsynchronization) { ((ID3v24Frame.EncodingFlags) encodingFlags).setUnsynchronised(); } else { ((ID3v24Frame.EncodingFlags) encodingFlags).unsetUnsynchronised(); } //These are not currently supported on write ((ID3v24Frame.EncodingFlags) encodingFlags).unsetCompression(); ((ID3v24Frame.EncodingFlags) encodingFlags).unsetDataLengthIndicator(); 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 bodybuffer to the Byte Array Output Stream tagBuffer.write(bodyBuffer); } catch (IOException ioe) { //This could never happen coz not writing to file, so convert to RuntimeException throw new RuntimeException(ioe); } }
Write the frame. Writes the frame header but writing the data is delegated to the frame body.
ID3v24Frame::write
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public AbstractID3v2Frame.StatusFlags getStatusFlags() { return statusFlags; }
Get Status Flags Object
ID3v24Frame::getStatusFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public AbstractID3v2Frame.EncodingFlags getEncodingFlags() { return encodingFlags; }
Get Encoding Flags Object
ID3v24Frame::getEncodingFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
StatusFlags() { super(); }
Use this when creating a frame from scratch
StatusFlags::StatusFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
StatusFlags(byte flags) { originalFlags = flags; writeFlags = flags; modifyFlags(); }
Use this constructor when reading from file or from another v4 frame @param flags
StatusFlags::StatusFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
StatusFlags(ID3v23Frame.StatusFlags statusFlags) { originalFlags = convertV3ToV4Flags(statusFlags.getOriginalFlags()); writeFlags = originalFlags; modifyFlags(); }
Use this constructor when convert a v23 frame @param statusFlags
StatusFlags::StatusFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
private byte convertV3ToV4Flags(byte v3Flag) { byte v4Flag = (byte) 0; if ((v3Flag & ID3v23Frame.StatusFlags.MASK_FILE_ALTER_PRESERVATION) != 0) { v4Flag |= (byte) MASK_FILE_ALTER_PRESERVATION; } if ((v3Flag & ID3v23Frame.StatusFlags.MASK_TAG_ALTER_PRESERVATION) != 0) { v4Flag |= (byte) MASK_TAG_ALTER_PRESERVATION; } return v4Flag; }
Convert V3 Flags to equivalent V4 Flags @param v3Flag @return
StatusFlags::convertV3ToV4Flags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
protected void modifyFlags() { String str = getIdentifier(); if (ID3v24Frames.getInstanceOf().isDiscardIfFileAltered(str)) { writeFlags |= (byte) MASK_FILE_ALTER_PRESERVATION; writeFlags &= (byte) ~MASK_TAG_ALTER_PRESERVATION; } else { writeFlags &= (byte) ~MASK_FILE_ALTER_PRESERVATION; writeFlags &= (byte) ~MASK_TAG_ALTER_PRESERVATION; } }
Makes modifications to flags based on specification and frameid
StatusFlags::modifyFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
EncodingFlags() { super(); }
Use this when creating a frame from scratch
EncodingFlags::EncodingFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
EncodingFlags(byte flags) { super(flags); logEnabledFlags(); }
Use this when creating a frame from existing flags in another v4 frame @param flags
EncodingFlags::EncodingFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public boolean isValidID3v2FrameIdentifier(String identifier) { Matcher m = ID3v24Frame.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/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.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/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public boolean isCommon() { return ID3v24Frames.getInstanceOf().isCommon(getId()); }
@return true if considered a common frame
EncodingFlags::isCommon
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public boolean isBinary() { return ID3v24Frames.getInstanceOf().isBinary(getId()); }
@return true if considered a common frame
EncodingFlags::isBinary
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
public void setEncoding(final Charset encoding) { Integer encodingId = TextEncoding.getInstanceOf().getIdForCharset(encoding); if(encodingId!=null) { if(encodingId <4) { 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/ID3v24Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24Frame.java
Apache-2.0
ID3v23FieldKey(String frameId, Id3FieldType fieldType) { this.frameId = frameId; this.fieldType = fieldType; this.fieldName = frameId; }
For usual metadata fields that use a data field @param frameId the frame that will be used @param fieldType of data atom
ID3v23FieldKey::ID3v23FieldKey
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
Apache-2.0
ID3v23FieldKey(String frameId, String subId, Id3FieldType fieldType) { this.frameId = frameId; this.subId = subId; this.fieldType = fieldType; this.fieldName = frameId + ":" + subId; }
@param frameId the frame that will be used @param subId the additional key required within the frame to uniquely identify this key @param fieldType
ID3v23FieldKey::ID3v23FieldKey
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
Apache-2.0
public Id3FieldType getFieldType() { return fieldType; }
@return fieldtype
ID3v23FieldKey::getFieldType
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
Apache-2.0
public String getFrameId() { return frameId; }
This is the frame identifier used to write the field @return
ID3v23FieldKey::getFrameId
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
Apache-2.0
public String getSubId() { return subId; }
This is the subfield used within the frame for this type of field @return subId
ID3v23FieldKey::getSubId
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
Apache-2.0
public String getFieldName() { return fieldName; }
This is the value of the key that can uniquely identifer a key type @return
ID3v23FieldKey::getFieldName
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23FieldKey.java
Apache-2.0
public byte getRelease() { return RELEASE; }
Retrieve the Release
ID3v23Tag::getRelease
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public byte getMajorVersion() { return MAJOR_VERSION; }
Retrieve the Major Version
ID3v23Tag::getMajorVersion
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public byte getRevision() { return REVISION; }
Retrieve the Revision
ID3v23Tag::getRevision
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public int getCrc32() { return crc32; }
@return Cyclic Redundancy Check 32 Value
ID3v23Tag::getCrc32
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public ID3v23Tag() { frameMap = new LinkedHashMap(); encryptedFrameMap = new LinkedHashMap(); }
Creates a new empty ID3v2_3 datatype.
ID3v23Tag::ID3v23Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
protected void copyPrimitives(AbstractID3v2Tag copyObj) { logger.config("Copying primitives"); super.copyPrimitives(copyObj); if (copyObj instanceof ID3v23Tag copyObject) { this.crcDataFlag = copyObject.crcDataFlag; this.experimental = copyObject.experimental; this.extended = copyObject.extended; this.crc32 = copyObject.crc32; this.paddingSize = copyObject.paddingSize; } }
Copy primitives applicable to v2.3
ID3v23Tag::copyPrimitives
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public ID3v23Tag(ID3v23Tag copyObject) { //This doesn't do anything. super(copyObject); logger.config("Creating tag from another tag of same type"); copyPrimitives(copyObject); copyFrames(copyObject); }
Copy Constructor, creates a new ID3v2_3 Tag based on another ID3v2_3 Tag @param copyObject
ID3v23Tag::ID3v23Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public ID3v23Tag(AbstractTag mp3tag) { logger.config("Creating tag from a tag of a different version"); frameMap = new LinkedHashMap(); encryptedFrameMap = new LinkedHashMap(); if (mp3tag != null) { ID3v24Tag convertedTag; //Should use simpler copy constructor if (mp3tag instanceof ID3v23Tag) { throw new UnsupportedOperationException("Copy Constructor not called. Please type cast the argument"); } if (mp3tag instanceof ID3v24Tag) { convertedTag = (ID3v24Tag) mp3tag; } //All tags types can be converted to v2.4 so do this to simplify things else { convertedTag = new ID3v24Tag(mp3tag); } this.setLoggingFilename(convertedTag.getLoggingFilename()); //Copy Primitives copyPrimitives(convertedTag); //Copy Frames copyFrames(convertedTag); logger.config("Created tag from a tag of a different version"); } }
Constructs a new tag based upon another tag of different version/type @param mp3tag
ID3v23Tag::ID3v23Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public ID3v23Tag(ByteBuffer buffer, String loggingFilename) throws TagException { setLoggingFilename(loggingFilename); this.read(buffer); }
Creates a new ID3v2_3 datatype. @param buffer @param loggingFilename @throws TagException
ID3v23Tag::ID3v23Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public ID3v23Tag(ByteBuffer buffer) throws TagException { this(buffer, ""); }
Creates a new ID3v2_3 datatype. @param buffer @throws TagException @deprecated use {@link #ID3v23Tag(ByteBuffer,String)} instead
ID3v23Tag::ID3v23Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public String getIdentifier() { return "ID3v2.30"; }
@return textual tag identifier
ID3v23Tag::getIdentifier
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public int getSize() { int size = TAG_HEADER_LENGTH; if (extended) { size += TAG_EXT_HEADER_LENGTH; if (crcDataFlag) { size += TAG_EXT_HEADER_CRC_LENGTH; } } size += super.getSize(); return size; }
Return frame size based upon the sizes of the tags rather than the physical no of bytes between start of ID3Tag and start of Audio Data. TODO this is incorrect, because of subclasses @return size of tag
ID3v23Tag::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public boolean equals(Object obj) { if (!(obj instanceof ID3v23Tag object)) { return false; } if (this.crc32 != object.crc32) { return false; } if (this.crcDataFlag != object.crcDataFlag) { return false; } if (this.experimental != object.experimental) { return false; } if (this.extended != object.extended) { return false; } return this.paddingSize == object.paddingSize && super.equals(obj); }
Is Tag Equivalent to another tag @param obj @return true if tag is equivalent to another
ID3v23Tag::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
private void readHeaderFlags(ByteBuffer buffer) throws TagException { //Allowable Flags byte flags = buffer.get(); unsynchronization = (flags & MASK_V23_UNSYNCHRONIZATION) != 0; extended = (flags & MASK_V23_EXTENDED_HEADER) != 0; experimental = (flags & MASK_V23_EXPERIMENTAL) != 0; //Not allowable/Unknown Flags if ((flags & FileConstants.BIT4) != 0) { logger.warning(ErrorMessage.ID3_INVALID_OR_UNKNOWN_FLAG_SET.getMsg(getLoggingFilename(), FileConstants.BIT4)); } if ((flags & FileConstants.BIT3) != 0) { logger.warning(ErrorMessage.ID3_INVALID_OR_UNKNOWN_FLAG_SET.getMsg(getLoggingFilename(), FileConstants.BIT3)); } if ((flags & FileConstants.BIT2) != 0) { logger.warning(ErrorMessage.ID3_INVALID_OR_UNKNOWN_FLAG_SET.getMsg(getLoggingFilename(), FileConstants.BIT2)); } if ((flags & FileConstants.BIT1) != 0) { logger.warning(ErrorMessage.ID3_INVALID_OR_UNKNOWN_FLAG_SET.getMsg(getLoggingFilename(), FileConstants.BIT1)); } if ((flags & FileConstants.BIT0) != 0) { logger.warning(ErrorMessage.ID3_INVALID_OR_UNKNOWN_FLAG_SET.getMsg(getLoggingFilename(), FileConstants.BIT0)); } if (isUnsynchronization()) { logger.config(ErrorMessage.ID3_TAG_UNSYNCHRONIZED.getMsg(getLoggingFilename())); } if (extended) { logger.config(ErrorMessage.ID3_TAG_EXTENDED.getMsg(getLoggingFilename())); } if (experimental) { logger.config(ErrorMessage.ID3_TAG_EXPERIMENTAL.getMsg(getLoggingFilename())); } }
Read header flags <p>Log info messages for flags that have been set and log warnings when bits have been set for unknown flags @param buffer @throws TagException
ID3v23Tag::readHeaderFlags
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
private void readExtendedHeader(ByteBuffer buffer, int size) { // Int is 4 bytes. int extendedHeaderSize = buffer.getInt(); // Extended header without CRC Data if (extendedHeaderSize == TAG_EXT_HEADER_DATA_LENGTH) { //Flag should not be setField , if is log a warning byte extFlag = buffer.get(); crcDataFlag = (extFlag & MASK_V23_CRC_DATA_PRESENT) != 0; if (crcDataFlag) { logger.warning(ErrorMessage.ID3_TAG_CRC_FLAG_SET_INCORRECTLY.getMsg(getLoggingFilename())); } //2nd Flag Byte (not used) buffer.get(); //Take padding and ext header size off the size to be read paddingSize=buffer.getInt(); if(paddingSize>0) { logger.config(ErrorMessage.ID3_TAG_PADDING_SIZE.getMsg(getLoggingFilename(),paddingSize)); } size = size - ( paddingSize + TAG_EXT_HEADER_LENGTH); } else if (extendedHeaderSize == TAG_EXT_HEADER_DATA_LENGTH + TAG_EXT_HEADER_CRC_LENGTH) { logger.config(ErrorMessage.ID3_TAG_CRC.getMsg(getLoggingFilename())); //Flag should be setField, if nor just act as if it is byte extFlag = buffer.get(); crcDataFlag = (extFlag & MASK_V23_CRC_DATA_PRESENT) != 0; if (!crcDataFlag) { logger.warning(ErrorMessage.ID3_TAG_CRC_FLAG_SET_INCORRECTLY.getMsg(getLoggingFilename())); } //2nd Flag Byte (not used) buffer.get(); //Take padding size of size to be read paddingSize = buffer.getInt(); if(paddingSize>0) { logger.config(ErrorMessage.ID3_TAG_PADDING_SIZE.getMsg(getLoggingFilename(),paddingSize)); } size = size - (paddingSize + TAG_EXT_HEADER_LENGTH + TAG_EXT_HEADER_CRC_LENGTH); //CRC Data crc32 = buffer.getInt(); logger.config(ErrorMessage.ID3_TAG_CRC_SIZE.getMsg(getLoggingFilename(),crc32)); } //Extended header size is only allowed to be six or ten bytes so this is invalid but instead //of giving up lets guess its six bytes and carry on and see if we can read file ok else { logger.warning(ErrorMessage.ID3_EXTENDED_HEADER_SIZE_INVALID.getMsg(getLoggingFilename(), extendedHeaderSize)); buffer.position(buffer.position() - FIELD_TAG_EXT_SIZE_LENGTH); } }
Read the optional extended header @param buffer @param size
ID3v23Tag::readExtendedHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
protected void readFrames(ByteBuffer byteBuffer, int size) { //Now start looking for frames ID3v23Frame next; frameMap = new LinkedHashMap(); encryptedFrameMap = new LinkedHashMap(); //Read the size from the Tag Header this.fileReadSize = size; logger.finest(getLoggingFilename() + ":Start of frame body at:" + byteBuffer.position() + ",frames data size is:" + size); // Read the frames until got to up to the size as specified in header or until // we hit an invalid frame identifier or padding while (byteBuffer.position() < size) { String id; try { //Read Frame int posBeforeRead = byteBuffer.position(); logger.config(getLoggingFilename() + ":Looking for next frame at:" + posBeforeRead); next = new ID3v23Frame(byteBuffer, getLoggingFilename()); id = next.getIdentifier(); logger.config(getLoggingFilename() + ":Found "+ id+ " at frame at:" + posBeforeRead); loadFrameIntoMap(id, next); } //Found Padding, no more frames catch (PaddingException ex) { logger.config(getLoggingFilename() + ":Found padding starting at:" + byteBuffer.position()); break; } //Found Empty Frame, log it - empty frames should not exist catch (EmptyFrameException ex) { logger.warning(getLoggingFilename() + ":Empty Frame:" + ex.getMessage()); this.emptyFrameBytes += ID3v23Frame.FRAME_HEADER_SIZE; } catch (InvalidFrameIdentifierException ifie) { logger.warning(getLoggingFilename() + ":Invalid Frame Identifier:" + ifie.getMessage()); this.invalidFrames++; //Don't try and find any more frames break; } //Problem trying to find frame, often just occurs because frameHeader includes padding //and we have reached padding catch (InvalidFrameException ife) { logger.warning(getLoggingFilename() + ":Invalid Frame:" + ife.getMessage()); this.invalidFrames++; //Don't try and find any more frames break; } //Failed reading frame but may just have invalid data but correct length so lets carry on //in case we can read the next frame catch(InvalidDataTypeException idete) { logger.warning(getLoggingFilename() + ":Corrupt Frame:" + idete.getMessage()); this.invalidFrames++; continue; } } }
Read the frames Read from byteBuffer upto size @param byteBuffer @param size
ID3v23Tag::readFrames
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
private ByteBuffer writeHeaderToBuffer(int padding, int size) throws IOException { // Flags,currently we never calculate the CRC // and if we dont calculate them cant keep orig values. Tags are not // experimental and we never createField extended header to keep things simple. extended = false; experimental = false; crcDataFlag = false; // Create Header Buffer,allocate maximum possible size for the header ByteBuffer headerBuffer = ByteBuffer. allocate(TAG_HEADER_LENGTH + TAG_EXT_HEADER_LENGTH + TAG_EXT_HEADER_CRC_LENGTH); //TAGID headerBuffer.put(TAG_ID); //Major Version headerBuffer.put(getMajorVersion()); //Minor Version headerBuffer.put(getRevision()); //Flags byte flagsByte = 0; if (isUnsynchronization()) { flagsByte |= MASK_V23_UNSYNCHRONIZATION; } if (extended) { flagsByte |= MASK_V23_EXTENDED_HEADER; } if (experimental) { flagsByte |= MASK_V23_EXPERIMENTAL; } headerBuffer.put(flagsByte); //Additional Header Size,(for completeness we never actually write the extended header) int additionalHeaderSize = 0; if (extended) { additionalHeaderSize += TAG_EXT_HEADER_LENGTH; if (crcDataFlag) { additionalHeaderSize += TAG_EXT_HEADER_CRC_LENGTH; } } //Size As Recorded in Header, don't include the main header length headerBuffer.put(ID3SyncSafeInteger.valueToBuffer(padding + size + additionalHeaderSize)); //Write Extended Header if (extended) { byte extFlagsByte1 = 0; byte extFlagsByte2 = 0; //Contains CRCData if (crcDataFlag) { headerBuffer.putInt(TAG_EXT_HEADER_DATA_LENGTH + TAG_EXT_HEADER_CRC_LENGTH); extFlagsByte1 |= MASK_V23_CRC_DATA_PRESENT; headerBuffer.put(extFlagsByte1); headerBuffer.put(extFlagsByte2); headerBuffer.putInt(paddingSize); headerBuffer.putInt(crc32); } //Just extended Header else { headerBuffer.putInt(TAG_EXT_HEADER_DATA_LENGTH); headerBuffer.put(extFlagsByte1); headerBuffer.put(extFlagsByte2); //Newly Calculated Padding As Recorded in Extended Header headerBuffer.putInt(padding); } } headerBuffer.flip(); return headerBuffer; }
Write the ID3 header to the ByteBuffer. TODO Calculate the CYC Data Check TODO Reintroduce Extended Header @param padding is the size of the padding portion of the tag @param size is the size of the body data @return ByteBuffer @throws IOException
ID3v23Tag::writeHeaderToBuffer
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public long write(File file, long audioStartLocation) throws IOException { setLoggingFilename(file.getName()); logger.config("Writing tag to file:"+getLoggingFilename()); //Write Body Buffer byte[] bodyByteBuffer = writeFramesToBuffer().toByteArray(); logger.config(getLoggingFilename() + ":bodybytebuffer:sizebeforeunsynchronisation:" + bodyByteBuffer.length); // Unsynchronize if option enabled and unsync required unsynchronization = TagOptionSingleton.getInstance().isUnsyncTags() && ID3Unsynchronization.requiresUnsynchronization(bodyByteBuffer); if (isUnsynchronization()) { bodyByteBuffer = ID3Unsynchronization.unsynchronize(bodyByteBuffer); logger.config(getLoggingFilename() + ":bodybytebuffer:sizeafterunsynchronisation:" + bodyByteBuffer.length); } int sizeIncPadding = calculateTagSize(bodyByteBuffer.length + TAG_HEADER_LENGTH, (int) audioStartLocation); int padding = sizeIncPadding - (bodyByteBuffer.length + TAG_HEADER_LENGTH); logger.config(getLoggingFilename() + ":Current audiostart:" + audioStartLocation); logger.config(getLoggingFilename() + ":Size including padding:" + sizeIncPadding); logger.config(getLoggingFilename() + ":Padding:" + padding); ByteBuffer headerBuffer = writeHeaderToBuffer(padding, bodyByteBuffer.length); writeBufferToFile(file, headerBuffer, bodyByteBuffer, padding, sizeIncPadding, audioStartLocation); return sizeIncPadding; }
Write tag to file TODO:we currently never write the Extended header , but if we did the size calculation in this method would be slightly incorrect @param file The file to write to @throws IOException
ID3v23Tag::write
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public void createStructure() { MP3File.getStructureFormatter().openHeadingElement(TYPE_TAG, getIdentifier()); super.createStructureHeader(); //Header MP3File.getStructureFormatter().openHeadingElement(TYPE_HEADER, ""); MP3File.getStructureFormatter().addElement(TYPE_UNSYNCHRONISATION, this.isUnsynchronization()); MP3File.getStructureFormatter().addElement(TYPE_EXTENDED, this.extended); MP3File.getStructureFormatter().addElement(TYPE_EXPERIMENTAL, this.experimental); MP3File.getStructureFormatter().addElement(TYPE_CRCDATA, this.crc32); MP3File.getStructureFormatter().addElement(TYPE_PADDINGSIZE, this.paddingSize); MP3File.getStructureFormatter().closeHeadingElement(TYPE_HEADER); //Body super.createStructureBody(); MP3File.getStructureFormatter().closeHeadingElement(TYPE_TAG); }
For representing the MP3File in an XML Format
ID3v23Tag::createStructure
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public boolean isUnsynchronization() { return unsynchronization; }
@return is tag unsynchronized
ID3v23Tag::isUnsynchronization
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public TagField createField(ID3v23FieldKey id3Key, String value) throws KeyNotFoundException, FieldDataInvalidException { if (id3Key == null) { throw new KeyNotFoundException(); } return super.doCreateTagField(new FrameAndSubId(null, id3Key.getFrameId(), id3Key.getSubId()), value); }
Create Frame for Id3 Key Only textual data supported at the moment, should only be used with frames that support a simple string argument. @param id3Key @param value @return @throws KeyNotFoundException @throws FieldDataInvalidException
ID3v23Tag::createField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public String getFirst(ID3v23FieldKey id3v23FieldKey) throws KeyNotFoundException { if (id3v23FieldKey == null) { throw new KeyNotFoundException(); } FieldKey genericKey = ID3v23Frames.getInstanceOf().getGenericKeyFromId3(id3v23FieldKey); if(genericKey!=null) { return super.getFirst(genericKey); } else { FrameAndSubId frameAndSubId = new FrameAndSubId(null, id3v23FieldKey.getFrameId(), id3v23FieldKey.getSubId()); return super.doGetValueAtIndex(frameAndSubId, 0); } }
Retrieve the first value that exists for this id3v23key @param id3v23FieldKey @return @throws org.jaudiotagger.tag.KeyNotFoundException
ID3v23Tag::getFirst
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public void deleteField(ID3v23FieldKey id3v23FieldKey) throws KeyNotFoundException { if (id3v23FieldKey == null) { throw new KeyNotFoundException(); } super.doDeleteTagField(new FrameAndSubId(null, id3v23FieldKey.getFrameId(), id3v23FieldKey.getSubId())); }
Delete fields with this id3v23FieldKey @param id3v23FieldKey @throws org.jaudiotagger.tag.KeyNotFoundException
ID3v23Tag::deleteField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public void deleteField(String id) { super.doDeleteTagField(new FrameAndSubId(null, id,null)); }
Delete fields with this (frame) id @param id
ID3v23Tag::deleteField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public Comparator getPreferredFrameOrderComparator() { return ID3v23PreferredFrameOrderComparator.getInstanceof(); }
@return comparator used to order frames in preferred order for writing to file so that most important frames are written first.
ID3v23Tag::getPreferredFrameOrderComparator
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public List<Artwork> getArtworkList() { List<TagField> coverartList = getFields(FieldKey.COVER_ART); List<Artwork> artworkList = new ArrayList<Artwork>(coverartList.size()); for (TagField next : coverartList) { FrameBodyAPIC coverArt = (FrameBodyAPIC) ((AbstractID3v2Frame) next).getBody(); Artwork artwork = ArtworkFactory.getNew(); artwork.setMimeType(coverArt.getMimeType()); artwork.setPictureType(coverArt.getPictureType()); if (coverArt.isImageUrl()) { artwork.setLinked(true); artwork.setImageUrl(coverArt.getImageUrl()); } else { artwork.setBinaryData(coverArt.getImageData()); } artworkList.add(artwork); } return artworkList; }
{@inheritDoc}
ID3v23Tag::getArtworkList
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public TagField createField(Artwork artwork) throws FieldDataInvalidException { AbstractID3v2Frame frame = createFrame(getFrameAndSubIdFromGenericKey(FieldKey.COVER_ART).getFrameId()); FrameBodyAPIC body = (FrameBodyAPIC) frame.getBody(); if(!artwork.isLinked()) { body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, artwork.getBinaryData()); body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType()); body.setObjectValue(DataTypes.OBJ_MIME_TYPE, artwork.getMimeType()); body.setObjectValue(DataTypes.OBJ_DESCRIPTION, ""); return frame; } else { body.setObjectValue(DataTypes.OBJ_PICTURE_DATA,artwork.getImageUrl().getBytes(StandardCharsets.ISO_8859_1)); body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, artwork.getPictureType()); body.setObjectValue(DataTypes.OBJ_MIME_TYPE, FrameBodyAPIC.IMAGE_IS_URL); body.setObjectValue(DataTypes.OBJ_DESCRIPTION, ""); return frame; } }
{@inheritDoc}
ID3v23Tag::createField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public TagField createArtworkField(byte[] data, String mimeType) { AbstractID3v2Frame frame = createFrame(getFrameAndSubIdFromGenericKey(FieldKey.COVER_ART).getFrameId()); FrameBodyAPIC body = (FrameBodyAPIC) frame.getBody(); body.setObjectValue(DataTypes.OBJ_PICTURE_DATA, data); body.setObjectValue(DataTypes.OBJ_PICTURE_TYPE, PictureTypes.DEFAULT_ID); body.setObjectValue(DataTypes.OBJ_MIME_TYPE, mimeType); body.setObjectValue(DataTypes.OBJ_DESCRIPTION, ""); return frame; }
Create Artwork @param data @param mimeType of the image @see PictureTypes @return
ID3v23Tag::createArtworkField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v23Tag.java
Apache-2.0
public static int bufferToValue(byte[] buffer) { //Note Need to && with 0xff otherwise if value is greater than 128 we get a negative number //when cast byte to int return ((buffer[0] & 0xff) << 21) + ((buffer[1] & 0xff) << 14) + ((buffer[2] & 0xff) << 7) + ((buffer[3]) & 0xff); }
Read syncsafe value from byteArray in format specified in spec and convert to int. @param buffer syncsafe integer @return decoded int
ID3SyncSafeInteger::bufferToValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
Apache-2.0
public static int bufferToValue(ByteBuffer buffer) { byte[] byteBuffer = new byte[INTEGRAL_SIZE]; buffer.get(byteBuffer, 0, INTEGRAL_SIZE); return bufferToValue(byteBuffer); }
Read syncsafe value from buffer in format specified in spec and convert to int. The buffers position is moved to just after the location of the syncsafe integer @param buffer syncsafe integer @return decoded int
ID3SyncSafeInteger::bufferToValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
Apache-2.0
protected static boolean isBufferNotSyncSafe(ByteBuffer buffer) { int position = buffer.position(); //Check Bit7 not set for (int i = 0; i < INTEGRAL_SIZE; i++) { byte nextByte = buffer.get(position + i); if ((nextByte & 0x80) > 0) { return true; } } return false; }
Is buffer holding a value that is definently not syncsafe We cannot guarantee a buffer is holding a syncsafe integer but there are some checks we can do to show that it definently is not. The buffer is NOT moved after reading. This function is useful for reading ID3v24 frames created in iTunes because iTunes does not use syncsafe integers in its frames. @param buffer @return true if this buffer is definently not holding a syncsafe integer
ID3SyncSafeInteger::isBufferNotSyncSafe
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
Apache-2.0
protected static boolean isBufferEmpty(byte[] buffer) { for (byte aBuffer : buffer) { if (aBuffer != 0) { return false; } } return true; }
Checks if the buffer just contains zeros This can be used to identify when accessing padding of a tag @param buffer @return true if buffer only contains zeros
ID3SyncSafeInteger::isBufferEmpty
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
Apache-2.0
protected static byte[] valueToBuffer(int size) { byte[] buffer = new byte[4]; buffer[0] = (byte) ((size & 0x0FE00000) >> 21); buffer[1] = (byte) ((size & 0x001FC000) >> 14); buffer[2] = (byte) ((size & 0x00003F80) >> 7); buffer[3] = (byte) (size & 0x0000007F); return buffer; }
Convert int value to syncsafe value held in bytearray @param size @return buffer syncsafe integer
ID3SyncSafeInteger::valueToBuffer
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3SyncSafeInteger.java
Apache-2.0
ID3v24FieldKey(String frameId, Id3FieldType fieldType) { this.frameId = frameId; this.fieldType = fieldType; this.fieldName = frameId; }
For usual metadata fields that use a data field @param frameId the frame that will be used @param fieldType of data atom
ID3v24FieldKey::ID3v24FieldKey
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
Apache-2.0
ID3v24FieldKey(String frameId, String subId, Id3FieldType fieldType) { this.frameId = frameId; this.subId = subId; this.fieldType = fieldType; this.fieldName = frameId + ":" + subId; }
@param frameId the frame that will be used @param subId the additional key required within the frame to uniquely identify this key @param fieldType
ID3v24FieldKey::ID3v24FieldKey
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
Apache-2.0
public Id3FieldType getFieldType() { return fieldType; }
@return fieldtype
ID3v24FieldKey::getFieldType
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
Apache-2.0
public String getFrameId() { return frameId; }
This is the frame identifier used to write the field @return
ID3v24FieldKey::getFrameId
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
Apache-2.0
public String getSubId() { return subId; }
This is the subfield used within the frame for this type of field @return subId
ID3v24FieldKey::getSubId
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
Apache-2.0
public String getFieldName() { return fieldName; }
This is the value of the key that can uniquely identifer a key type @return
ID3v24FieldKey::getFieldName
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v24FieldKey.java
Apache-2.0
public ID3v1Iterator(ID3v1Tag id3v1tag) { this.id3v1tag = id3v1tag; }
Creates a new ID3v1Iterator datatype. @param id3v1tag
ID3v1Iterator::ID3v1Iterator
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
Apache-2.0
public boolean hasNext() { return hasNext(lastIndex); }
@return
ID3v1Iterator::hasNext
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
Apache-2.0
public Object next() { return next(lastIndex); }
@return
ID3v1Iterator::next
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
Apache-2.0
private boolean hasNext(int index) { switch (index) { case TITLE: return (id3v1tag.title.length() > 0) || hasNext(index + 1); case ARTIST: return (id3v1tag.artist.length() > 0) || hasNext(index + 1); case ALBUM: return (id3v1tag.album.length() > 0) || hasNext(index + 1); case COMMENT: return (id3v1tag.comment.length() > 0) || hasNext(index + 1); case YEAR: return (id3v1tag.year.length() > 0) || hasNext(index + 1); case GENRE: return (id3v1tag.genre >= (byte) 0) || hasNext(index + 1); case TRACK: if (id3v1tag instanceof ID3v11Tag) { return (((ID3v11Tag) id3v1tag).track >= (byte) 0) || hasNext(index + 1); } default: return false; } }
@param index @return
ID3v1Iterator::hasNext
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
Apache-2.0
private Object next(int index) { switch (lastIndex) { case 0: return (id3v1tag.title.length() > 0) ? id3v1tag.title : next(index + 1); case TITLE: return (id3v1tag.artist.length() > 0) ? id3v1tag.artist : next(index + 1); case ARTIST: return (id3v1tag.album.length() > 0) ? id3v1tag.album : next(index + 1); case ALBUM: return (id3v1tag.comment.length() > 0) ? id3v1tag.comment : next(index + 1); case COMMENT: return (id3v1tag.year.length() > 0) ? id3v1tag.year : next(index + 1); case YEAR: return (id3v1tag.genre >= (byte) 0) ? id3v1tag.genre : next(index + 1); case GENRE: return (id3v1tag instanceof ID3v11Tag && (((ID3v11Tag) id3v1tag).track >= (byte) 0)) ? ((ID3v11Tag) id3v1tag).track : null; default: throw new NoSuchElementException("Iteration has no more elements."); } }
@param index @return @throws NoSuchElementException
ID3v1Iterator::next
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1Iterator.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
ID3v22PreferredFrameOrderComparator::compare
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v22PreferredFrameOrderComparator.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v22PreferredFrameOrderComparator.java
Apache-2.0
public ID3v1TagField(final byte[] raw) throws UnsupportedEncodingException { String field = new String(raw, StandardCharsets.ISO_8859_1); int i = field.indexOf('='); if (i == -1) { //Beware that ogg ID, must be capitalized and contain no space.. this.id = "ERRONEOUS"; this.content = field; } else { this.id = field.substring(0, i).toUpperCase(); if (field.length() > i) { this.content = field.substring(i + 1); } else { //We have "XXXXXX=" with nothing after the "=" this.content = ""; } } checkCommon(); }
Creates an instance. @param raw Raw byte data of the tagfield. @throws UnsupportedEncodingException If the data doesn't conform "UTF-8" specification.
ID3v1TagField::ID3v1TagField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
Apache-2.0
public ID3v1TagField(final String fieldId, final String fieldContent) { this.id = fieldId.toUpperCase(); this.content = fieldContent; checkCommon(); }
Creates an instance. @param fieldId ID (name) of the field. @param fieldContent Content of the field.
ID3v1TagField::ID3v1TagField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
Apache-2.0
private void checkCommon() { this.common = id.equals(ID3v1FieldKey.TITLE.name()) || id.equals(ID3v1FieldKey.ALBUM.name()) || id.equals(ID3v1FieldKey.ARTIST.name()) || id.equals(ID3v1FieldKey.GENRE.name()) || id.equals(ID3v1FieldKey.YEAR.name()) || id.equals(ID3v1FieldKey.COMMENT.name()) || id.equals(ID3v1FieldKey.TRACK.name()); }
This method examines the ID of the current field and modifies {@link #common}in order to reflect if the tag id is a commonly used one. <br>
ID3v1TagField::checkCommon
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
Apache-2.0
protected void copy(byte[] src, byte[] dst, int dstOffset) { // for (int i = 0; i < src.length; i++) // dst[i + dstOffset] = src[i]; /* * Heared that this method is optimized and does its job very near of * the system. */ System.arraycopy(src, 0, dst, dstOffset, src.length); }
This method will copy all bytes of <code>src</code> to <code>dst</code> at the specified location. @param src bytes to copy. @param dst where to copy to. @param dstOffset at which position of <code>dst</code> the data should be copied.
ID3v1TagField::copy
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3v1TagField.java
Apache-2.0
public static byte getTextEncoding(AbstractTagFrame header, byte textEncoding) { //Should not happen, assume v23 and provide a warning if (header == null) { logger.warning("Header has not yet been set for this framebody"); if (TagOptionSingleton.getInstance().isResetTextEncodingForExistingFrames()) { return TagOptionSingleton.getInstance().getId3v23DefaultTextEncoding(); } else { return convertV24textEncodingToV23textEncoding(textEncoding); } } else if (header instanceof ID3v24Frame) { if (TagOptionSingleton.getInstance().isResetTextEncodingForExistingFrames()) { //Replace with default return TagOptionSingleton.getInstance().getId3v24DefaultTextEncoding(); } else { //All text encodings supported nothing to do return textEncoding; } } else { if (TagOptionSingleton.getInstance().isResetTextEncodingForExistingFrames()) { //Replace with default return TagOptionSingleton.getInstance().getId3v23DefaultTextEncoding(); } else { //If text encoding is an unsupported v24 one we use unicode v23 equivalent return convertV24textEncodingToV23textEncoding(textEncoding); } } }
Check the text encoding is valid for this header type and is appropriate for user text encoding options. * This is called before writing any frames that use text encoding @param header used to identify the ID3tagtype @param textEncoding currently set @return valid encoding according to version type and user options
ID3TextEncodingConversion::getTextEncoding
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3TextEncodingConversion.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3TextEncodingConversion.java
Apache-2.0
public static byte getUnicodeTextEncoding(AbstractTagFrame header) { if (header == null) { logger.warning("Header has not yet been set for this framebody"); return TextEncoding.UTF_16; } else if (header instanceof ID3v24Frame) { return TagOptionSingleton.getInstance().getId3v24UnicodeTextEncoding(); } else { return TextEncoding.UTF_16; } }
Sets the text encoding to best Unicode type for the version @param header @return
ID3TextEncodingConversion::getUnicodeTextEncoding
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3TextEncodingConversion.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3TextEncodingConversion.java
Apache-2.0
private static byte convertV24textEncodingToV23textEncoding(byte textEncoding) { //Convert to equivalent UTF16 format if (textEncoding == TextEncoding.UTF_16BE) { return TextEncoding.UTF_16; } //UTF-8 is not supported in ID3v23 and UTF-16 Format can be problematic on ID3v23 so change //to ISO-8859-1, a check before writing data will check the format is capable of writing the data else if (textEncoding == TextEncoding.UTF_8) { return TextEncoding.ISO_8859_1; } else { return textEncoding; } }
Convert v24 text encoding to a valid v23 encoding @param textEncoding @return valid encoding
ID3TextEncodingConversion::convertV24textEncodingToV23textEncoding
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/ID3TextEncodingConversion.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/ID3TextEncodingConversion.java
Apache-2.0
protected AbstractID3v2Frame() { }
Create an empty frame
AbstractID3v2Frame::AbstractID3v2Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
Apache-2.0
public AbstractID3v2Frame(AbstractID3v2Frame frame) { super(frame); }
Create a frame based on another frame @param frame
AbstractID3v2Frame::AbstractID3v2Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
Apache-2.0
public AbstractID3v2Frame(AbstractID3v2FrameBody body) { this.frameBody = body; this.frameBody.setHeader(this); }
Create a frame based on a body @param body
AbstractID3v2Frame::AbstractID3v2Frame
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
Apache-2.0
protected String getLoggingFilename() { return loggingFilename; }
Retrieve the logging filename to be used in debugging @return logging filename to be used in debugging
AbstractID3v2Frame::getLoggingFilename
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
Apache-2.0
protected void setLoggingFilename(String loggingFilename) { this.loggingFilename = loggingFilename; }
Set logging filename when construct tag for read from file @param loggingFilename
AbstractID3v2Frame::setLoggingFilename
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
Apache-2.0
public String getIdentifier() { return identifier; }
Return the frame identifier @return the frame identifier
AbstractID3v2Frame::getIdentifier
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
Apache-2.0
protected AbstractID3v2FrameBody readEncryptedBody(String identifier, ByteBuffer byteBuffer, int frameSize) throws InvalidFrameException, InvalidDataTypeException { try { AbstractID3v2FrameBody frameBody = new FrameBodyEncrypted(identifier,byteBuffer, frameSize); frameBody.setHeader(this); return frameBody; } catch(InvalidTagException ite) { throw new InvalidDataTypeException(ite); } }
Read the frameBody when frame marked as encrypted @param identifier @param byteBuffer @param frameSize @return @throws InvalidFrameException @throws InvalidDataTypeException @throws InvalidTagException
AbstractID3v2Frame::readEncryptedBody
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/id3/AbstractID3v2Frame.java
Apache-2.0