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 void setField(Artwork artwork) throws FieldDataInvalidException { this.setField(createField(artwork)); }
Create field and then set within tag itself @param artwork @throws FieldDataInvalidException
WavTag::setField
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public long getSizeOfID3TagOnly() { if(!isExistingId3Tag()) { return 0; } return (id3Tag.getEndLocationInFile() - id3Tag.getStartLocationInFile()); }
@return size of the vanilla ID3Tag exclusing surrounding chunk
WavTag::getSizeOfID3TagOnly
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public long getSizeOfID3TagIncludingChunkHeader() { if(!isExistingId3Tag()) { return 0; } return getSizeOfID3TagOnly() + ChunkHeader.CHUNK_HEADER_SIZE; }
@return size of the ID3 Chunk including header
WavTag::getSizeOfID3TagIncludingChunkHeader
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public long getStartLocationInFileOfId3Chunk() { if(!isExistingId3Tag()) { return 0; } return id3Tag.getStartLocationInFile() - ChunkHeader.CHUNK_HEADER_SIZE; }
Offset into file of start ID3Chunk including header @return
WavTag::getStartLocationInFileOfId3Chunk
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public void syncToId3FromInfoIfEmpty() { try { for(FieldKey fieldKey : WavInfoTag.getSupportedKeys()) { if (id3Tag.getFirst(fieldKey).isEmpty()) { String first = infoTag.getFirst(fieldKey); if (!first.isEmpty()) { id3Tag.setField(fieldKey, stripNullTerminator(first)); } } } } catch(FieldDataInvalidException deie) { logger.log(Level.INFO, "Couldn't sync to ID3 because the data to sync was invalid", deie); } }
If we have field in INFO tag but not ID3 tag (perhaps coz doesn't exist add them to ID3 tag)
WavTag::syncToId3FromInfoIfEmpty
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public void syncToInfoFromId3IfEmpty() { try { for(FieldKey fieldKey : WavInfoTag.getSupportedKeys()) { if (infoTag.getFirst(fieldKey).isEmpty()) { if (!id3Tag.getFirst(fieldKey).isEmpty()) { infoTag.setField(fieldKey, addNullTerminatorIfNone(id3Tag.getFirst(fieldKey))); } } } } catch(FieldDataInvalidException deie) { logger.log(Level.INFO, "Couldn't sync to INFO because the data to sync was invalid", deie); } }
If we have field in INFO tag but not ID3 tag (perhaps coz doesn't exist add them to ID3 tag)
WavTag::syncToInfoFromId3IfEmpty
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public void syncToId3FromInfoOverwrite() { try { for(FieldKey fieldKey : WavInfoTag.getSupportedKeys()) { if (!infoTag.getFirst(fieldKey).isEmpty()) { id3Tag.setField(fieldKey, stripNullTerminator(infoTag.getFirst(fieldKey))); } else { id3Tag.deleteField(fieldKey); } } } catch(FieldDataInvalidException deie) { logger.log(Level.INFO, "Couldn't sync to ID3 because the data to sync was invalid", deie); } }
If we have field in INFO tag write to ID3 tag, if not we delete form ID3 (but only for tag that we can actually have in INFO tag)
WavTag::syncToId3FromInfoOverwrite
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public void syncToInfoFromId3Overwrite() { try { for(FieldKey fieldKey : WavInfoTag.getSupportedKeys()) { if (!id3Tag.getFirst(fieldKey).isEmpty()) { infoTag.setField(fieldKey, addNullTerminatorIfNone(id3Tag.getFirst(fieldKey))); } else { infoTag.deleteField(fieldKey); } } } catch(FieldDataInvalidException deie) { logger.log(Level.INFO, "Couldn't sync to INFO because the data to sync was invalid", deie); } }
If we have field in ID3 tag write to INFO tag
WavTag::syncToInfoFromId3Overwrite
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public void syncTagsAfterRead() { if(getActiveTag() instanceof WavInfoTag) { syncToInfoFromId3IfEmpty(); } else { syncToId3FromInfoIfEmpty(); } }
Call after read to ensure your preferred tag can make use of any additional metadata held in the other tag, only used if the activetag field is empty for the fieldkey
WavTag::syncTagsAfterRead
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public void syncTagBeforeWrite() { if(getActiveTag() instanceof WavInfoTag) { syncToId3FromInfoOverwrite(); } else { syncToInfoFromId3Overwrite(); } }
Call before save if saving both tags ensure any new information is the active tag is added to the other tag overwriting any existing fields
WavTag::syncTagBeforeWrite
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public static AbstractID3v2Tag createDefaultID3Tag() { if(TagOptionSingleton.getInstance().getID3V2Version()== ID3V2Version.ID3_V24) { return new ID3v24Tag(); } else if(TagOptionSingleton.getInstance().getID3V2Version()==ID3V2Version.ID3_V23) { return new ID3v23Tag(); } else if(TagOptionSingleton.getInstance().getID3V2Version()==ID3V2Version.ID3_V22) { return new ID3v22Tag(); } //Default in case not set somehow return new ID3v23Tag(); }
Default based on user option @return
WavTag::createDefaultID3Tag
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/wav/WavTag.java
Apache-2.0
public NumberHashMap(String identifier, AbstractTagFrameBody frameBody, int size) { super(identifier, frameBody, size); if (identifier.equals(DataTypes.OBJ_GENRE)) { valueToKey = GenreTypes.getInstanceOf().getValueToIdMap(); keyToValue = GenreTypes.getInstanceOf().getIdToValueMap(); //genres can be an id or literal value hasEmptyValue = true; } else if (identifier.equals(DataTypes.OBJ_TEXT_ENCODING)) { valueToKey = TextEncoding.getInstanceOf().getValueToIdMap(); keyToValue = TextEncoding.getInstanceOf().getIdToValueMap(); } else if (identifier.equals(DataTypes.OBJ_INTERPOLATION_METHOD)) { valueToKey = InterpolationTypes.getInstanceOf().getValueToIdMap(); keyToValue = InterpolationTypes.getInstanceOf().getIdToValueMap(); } else if (identifier.equals(DataTypes.OBJ_PICTURE_TYPE)) { valueToKey = PictureTypes.getInstanceOf().getValueToIdMap(); keyToValue = PictureTypes.getInstanceOf().getIdToValueMap(); //Issue #224 Values should map, but have examples where they dont, this is a workaround hasEmptyValue = true; } else if (identifier.equals(DataTypes.OBJ_TYPE_OF_EVENT)) { valueToKey = EventTimingTypes.getInstanceOf().getValueToIdMap(); keyToValue = EventTimingTypes.getInstanceOf().getIdToValueMap(); } else if (identifier.equals(DataTypes.OBJ_TIME_STAMP_FORMAT)) { valueToKey = EventTimingTimestampTypes.getInstanceOf().getValueToIdMap(); keyToValue = EventTimingTimestampTypes.getInstanceOf().getIdToValueMap(); } else if (identifier.equals(DataTypes.OBJ_TYPE_OF_CHANNEL)) { valueToKey = ChannelTypes.getInstanceOf().getValueToIdMap(); keyToValue = ChannelTypes.getInstanceOf().getIdToValueMap(); } else if (identifier.equals(DataTypes.OBJ_RECIEVED_AS)) { valueToKey = ReceivedAsTypes.getInstanceOf().getValueToIdMap(); keyToValue = ReceivedAsTypes.getInstanceOf().getIdToValueMap(); } else if (identifier.equals(DataTypes.OBJ_CONTENT_TYPE)) { valueToKey = SynchronisedLyricsContentType.getInstanceOf().getValueToIdMap(); keyToValue = SynchronisedLyricsContentType.getInstanceOf().getIdToValueMap(); } else { throw new IllegalArgumentException("Hashmap identifier not defined in this class: " + identifier); } }
Creates a new ObjectNumberHashMap datatype. @param identifier @param frameBody @param size @throws IllegalArgumentException
NumberHashMap::NumberHashMap
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public Map<Integer, String> getKeyToValue() { return keyToValue; }
@return the key to value map
NumberHashMap::getKeyToValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public Map<String, Integer> getValueToKey() { return valueToKey; }
@return the value to key map
NumberHashMap::getValueToKey
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public void setValue(Object value) { if (value instanceof Byte) { this.value = (long) ((Byte) value).byteValue(); } else if (value instanceof Short) { this.value = (long) ((Short) value).shortValue(); } else if (value instanceof Integer) { this.value = (long) ((Integer) value).intValue(); } else { this.value = value; } }
@param value
NumberHashMap::setValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public boolean equals(Object obj) { if(obj==this) { return true; } if (!(obj instanceof NumberHashMap that)) { return false; } return EqualsUtil.areEqual(hasEmptyValue, that.hasEmptyValue) && EqualsUtil.areEqual(keyToValue, that.keyToValue) && EqualsUtil.areEqual(valueToKey, that.valueToKey) && super.equals(that); }
@param obj @return
NumberHashMap::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public Iterator<String> iterator() { if (keyToValue == null) { return null; } else { // put them in a treeset first to sort them TreeSet<String> treeSet = new TreeSet<String>(keyToValue.values()); if (hasEmptyValue) { treeSet.add(""); } return treeSet.iterator(); } }
@return
NumberHashMap::iterator
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException { super.readByteArray(arr, offset); //Mismatch:Superclass uses Long, but maps expect Integer Integer intValue = ((Long) value).intValue(); if (!keyToValue.containsKey(intValue)) { if (!hasEmptyValue) { throw new InvalidDataTypeException(ErrorMessage.MP3_REFERENCE_KEY_INVALID.getMsg(identifier, intValue)); } else if (identifier.equals(DataTypes.OBJ_PICTURE_TYPE)) { logger.warning(ErrorMessage.MP3_PICTURE_TYPE_INVALID.getMsg(value)); } } }
Read the key from the buffer. @param arr @param offset @throws InvalidDataTypeException if emptyValues are not allowed and the eky was invalid.
NumberHashMap::readByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public String toString() { if (value == null) { return ""; } else if (keyToValue.get(value) == null) { return ""; } else { return keyToValue.get(value); } }
@return
NumberHashMap::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberHashMap.java
Apache-2.0
public int getSize() { int len = 0; if (value != null) { len = ((byte[]) value).length; } return len; }
Return the size in byte of this datatype @return the size in bytes
ByteArraySizeTerminated::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
Apache-2.0
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException { if (arr == null) { throw new NullPointerException("Byte array is null"); } if (offset < 0) { throw new IndexOutOfBoundsException("Offset to byte array is out of bounds: offset = " + offset + ", array.length = " + arr.length); } //Empty Byte Array if (offset >= arr.length) { value = null; return; } int len = arr.length - offset; value = new byte[len]; System.arraycopy(arr, offset, value, 0, len); }
@param arr @param offset @throws NullPointerException @throws IndexOutOfBoundsException
ByteArraySizeTerminated::readByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
Apache-2.0
public String toString() { return getSize() + " bytes"; }
Because this is usually binary data and could be very long we just return the number of bytes held @return the number of bytes
ByteArraySizeTerminated::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
Apache-2.0
public byte[] writeByteArray() { logger.config("Writing byte array" + this.getIdentifier()); return (byte[]) value; }
Write contents to a byte array @return a byte array that that contians the data that should be perisisted to file
ByteArraySizeTerminated::writeByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/ByteArraySizeTerminated.java
Apache-2.0
public TCONString(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody); }
Creates a new empty TextEncodedStringSizeTerminated datatype. @param identifier identifies the frame type @param frameBody
TCONString::TCONString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
Apache-2.0
public TCONString(TCONString object) { super(object); }
Copy constructor @param object
TCONString::TCONString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
Apache-2.0
public boolean isNullSeperateMultipleValues() { return isNullSeperateMultipleValues; }
If this field is used with ID3v24 then it is usual to null separate values. Within ID3v23 not many frames officially support multiple values, so in absense of better solution we use the v24 method, however some frames such as TCON have there own method and should not null separate values. This can be controlled by this field.
TCONString::isNullSeperateMultipleValues
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
Apache-2.0
public int getNumberOfValues() { return getValues().size(); }
How many values are held, each value is separated by a null terminator @return number of values held, usually this will be one.
TCONString::getNumberOfValues
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
Apache-2.0
public String getValueAtIndex(int index) { //Split String into separate components List values = getValues(); return (String) values.get(index); }
Get the nth value @param index @return the nth value @throws IndexOutOfBoundsException if value does not exist
TCONString::getValueAtIndex
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
Apache-2.0
public List<String> getValues() { if(isNullSeperateMultipleValues()) { return splitByNullSeperator((String) value); } else { return splitV23((String)value); } }
@return list of all values
TCONString::getValues
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
Apache-2.0
public String getValueWithoutTrailingNull() { List<String> values = getValues(); StringBuffer sb = new StringBuffer(); for(int i=0;i<values.size();i++) { if(i!=0) { sb.append("\u0000"); } sb.append(values.get(i)); } return sb.toString(); }
Get value(s) whilst removing any trailing nulls @return
TCONString::getValueWithoutTrailingNull
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/TCONString.java
Apache-2.0
public StringSizeTerminated(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody); }
Creates a new ObjectStringSizeTerminated datatype. @param identifier identifies the frame type @param frameBody
StringSizeTerminated::StringSizeTerminated
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringSizeTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringSizeTerminated.java
Apache-2.0
public StringNullTerminated(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody); }
Creates a new ObjectStringNullTerminated datatype. @param identifier identifies the frame type @param frameBody
StringNullTerminated::StringNullTerminated
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringNullTerminated.java
Apache-2.0
protected AbstractString(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody); }
Creates a new datatype @param identifier @param frameBody
AbstractString::AbstractString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
public AbstractString(String identifier, AbstractTagFrameBody frameBody, String value) { super(identifier, frameBody, value); }
Creates a new datatype, with value @param identifier @param frameBody @param value
AbstractString::AbstractString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
protected AbstractString(AbstractString object) { super(object); }
Copy constructor @param object
AbstractString::AbstractString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
public int getSize() { return size; }
Return the size in bytes of this datatype as it was/is held in file this will be effected by the encoding type. @return the size
AbstractString::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
protected void setSize(int size) { this.size = size; }
Sets the size in bytes of this data type. This is set after writing the data to allow us to recalculate the size for frame header. @param size
AbstractString::setSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
public String toString() { return (String) value; }
Return String representation of data type @return a string representation of the value
AbstractString::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
public boolean canBeEncoded() { //Try and write to buffer using the CharSet defined by the textEncoding field (note if using UTF16 we dont //need to worry about LE,BE at this point it makes no difference) final byte textEncoding = this.getBody().getTextEncoding(); final TextEncoding encoding = TextEncoding.getInstanceOf(); final Charset charset = encoding.getCharsetForId(textEncoding); CharsetEncoder encoder = charset.newEncoder(); if (encoder.canEncode((String) value)) { return true; } else { logger.finest("Failed Trying to decode" + value + "with" + encoder); return false; } }
Check the value can be encoded with the specified encoding @return
AbstractString::canBeEncoded
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
protected CharsetDecoder getCorrectDecoder(ByteBuffer inBuffer) { CharsetDecoder decoder=null; if(inBuffer.remaining()<=2) { decoder = getTextEncodingCharSet().newDecoder(); decoder.reset(); return decoder; } if(getTextEncodingCharSet()== StandardCharsets.UTF_16) { if(inBuffer.getChar(0)==0xfffe || inBuffer.getChar(0)==0xfeff) { //Get the Specified Decoder decoder = getTextEncodingCharSet().newDecoder(); decoder.reset(); } else { if(inBuffer.get(0)==0) { decoder = StandardCharsets.UTF_16BE.newDecoder(); decoder.reset(); } else { decoder = StandardCharsets.UTF_16LE.newDecoder(); decoder.reset(); } } } else { decoder = getTextEncodingCharSet().newDecoder(); decoder.reset(); } return decoder; }
If they have specified UTF-16 then decoder works out by looking at BOM but if missing we have to make an educated guess otherwise just use specified decoder @param inBuffer @return
AbstractString::getCorrectDecoder
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
protected Charset getTextEncodingCharSet() { final byte textEncoding = this.getBody().getTextEncoding(); final Charset charSetName = TextEncoding.getInstanceOf().getCharsetForId(textEncoding); logger.finest("text encoding:" + textEncoding + " charset:" + charSetName.name()); return charSetName; }
Get the text encoding being used. The text encoding is defined by the frame body that the text field belongs to. @return the text encoding charset
AbstractString::getTextEncodingCharSet
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/AbstractString.java
Apache-2.0
public StringFixedLength(String identifier, AbstractTagFrameBody frameBody, int size) { super(identifier, frameBody); if (size < 0) { throw new IllegalArgumentException("size is less than zero: " + size); } setSize(size); }
Creates a new ObjectStringFixedsize datatype. @param identifier @param frameBody @param size @throws IllegalArgumentException
StringFixedLength::StringFixedLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
Apache-2.0
public boolean equals(Object obj) { if (!(obj instanceof StringFixedLength object)) { return false; } return this.size == object.size && super.equals(obj); }
@param obj @return if obj is equivalent to this
StringFixedLength::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
Apache-2.0
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException { logger.config("Reading from array from offset:" + offset); try { final CharsetDecoder decoder = getTextEncodingCharSet().newDecoder(); //Decode buffer if runs into problems should through exception which we //catch and then set value to empty string. logger.finest("Array length is:" + arr.length + "offset is:" + offset + "Size is:" + size); if (arr.length - offset < size) { throw new InvalidDataTypeException("byte array is to small to retrieve string of declared length:" + size); } String str = decoder.decode(ByteBuffer.wrap(arr, offset, size)).toString(); if (str == null) { throw new NullPointerException("String is null"); } value = str; } catch (CharacterCodingException ce) { logger.severe(ce.getMessage()); value = ""; } logger.config("Read StringFixedLength:" + value); }
Read a string from buffer of fixed size(size has already been set in constructor) @param arr this is the buffer for the frame @param offset this is where to start reading in the buffer for this field
StringFixedLength::readByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
Apache-2.0
public byte[] writeByteArray() { ByteBuffer dataBuffer; byte[] data; //Create with a series of empty of spaces to try and ensure integrity of field if (value == null) { logger.warning("Value of StringFixedlength Field is null using default value instead"); data = new byte[size]; for (int i = 0; i < size; i++) { data[i] = ' '; } return data; } try { final Charset charset = getTextEncodingCharSet(); final CharsetEncoder encoder; if (StandardCharsets.UTF_16.equals(charset)) { //Note remember LE BOM is ff fe but tis is handled by encoder Unicode char is fe ff encoder = StandardCharsets.UTF_16LE.newEncoder(); dataBuffer = encoder.encode(CharBuffer.wrap('\ufeff' + (String) value)); } else { encoder = charset.newEncoder(); dataBuffer = encoder.encode(CharBuffer.wrap((String) value)); } } catch (CharacterCodingException ce) { logger.warning("There was a problem writing the following StringFixedlength Field:" + value + ":" + ce.getMessage() + "using default value instead"); data = new byte[size]; for (int i = 0; i < size; i++) { data[i] = ' '; } return data; } // We must return the defined size. // To check now because size is in bytes not chars if (dataBuffer != null) { //Everything ok if (dataBuffer.limit() == size) { data = new byte[dataBuffer.limit()]; dataBuffer.get(data, 0, dataBuffer.limit()); return data; } //There is more data available than allowed for this field strip else if (dataBuffer.limit() > size) { logger.warning("There was a problem writing the following StringFixedlength Field:" + value + " when converted to bytes has length of:" + dataBuffer.limit() + " but field was defined with length of:" + size + " too long so stripping extra length"); data = new byte[size]; dataBuffer.get(data, 0, size); return data; } //There is not enough data else { logger.warning("There was a problem writing the following StringFixedlength Field:" + value + " when converted to bytes has length of:" + dataBuffer.limit() + " but field was defined with length of:" + size + " too short so padding with spaces to make up extra length"); data = new byte[size]; dataBuffer.get(data, 0, dataBuffer.limit()); for (int i = dataBuffer.limit(); i < size; i++) { data[i] = ' '; } return data; } } else { logger.warning("There was a serious problem writing the following StringFixedlength Field:" + value + ":" + "using default value instead"); data = new byte[size]; for (int i = 0; i < size; i++) { data[i] = ' '; } return data; } }
Write String into byte array The string will be adjusted to ensure the correct number of bytes are written, If the current value is null or to short the written value will have the 'space' character appended to ensure this. We write this instead of the null character because the null character is likely to confuse the parser into misreading the next field. @return the byte array to be written to the file
StringFixedLength::writeByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
Apache-2.0
protected Charset getTextEncodingCharSet() { final byte textEncoding = this.getBody().getTextEncoding(); final Charset charset = TextEncoding.getInstanceOf().getCharsetForId(textEncoding); logger.finest("text encoding:" + textEncoding + " charset:" + charset.name()); return charset; }
@return the encoding of the frame body this datatype belongs to
StringFixedLength::getTextEncodingCharSet
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringFixedLength.java
Apache-2.0
public StringHashMap(String identifier, AbstractTagFrameBody frameBody, int size) { super(identifier, frameBody, size); if (identifier.equals(DataTypes.OBJ_LANGUAGE)) { valueToKey = Languages.getInstanceOf().getValueToIdMap(); keyToValue = Languages.getInstanceOf().getIdToValueMap(); } else { throw new IllegalArgumentException("Hashmap identifier not defined in this class: " + identifier); } }
Creates a new ObjectStringHashMap datatype. @param identifier @param frameBody @param size @throws IllegalArgumentException
StringHashMap::StringHashMap
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
public Map<String, String> getKeyToValue() { return keyToValue; }
@return
StringHashMap::getKeyToValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
public Map<String, String> getValueToKey() { return valueToKey; }
@return
StringHashMap::getValueToKey
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
public void setValue(Object value) { if (value instanceof String) { //Issue #273 temporary hack for MM if(value.equals("XXX")) { this.value=value.toString(); } else { this.value = ((String) value).toLowerCase(); } } else { this.value = value; } }
@param value
StringHashMap::setValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
public boolean equals(Object obj) { if (!(obj instanceof StringHashMap object)) { return false; } if (this.hasEmptyValue != object.hasEmptyValue) { return false; } if (this.keyToValue == null) { if (object.keyToValue != null) { return false; } } else { if (!this.keyToValue.equals(object.keyToValue)) { return false; } } if (this.keyToValue == null) { if (object.keyToValue != null) { return false; } } else { if (!this.valueToKey.equals(object.valueToKey)) { return false; } } return super.equals(obj); }
@param obj @return
StringHashMap::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
public Iterator<String> iterator() { if (keyToValue == null) { return null; } else { // put them in a treeset first to sort them TreeSet<String> treeSet = new TreeSet<String>(keyToValue.values()); if (hasEmptyValue) { treeSet.add(""); } return treeSet.iterator(); } }
@return
StringHashMap::iterator
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
public String toString() { if (value == null || keyToValue.get(value) == null) { return ""; } else { return keyToValue.get(value); } }
@return
StringHashMap::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
protected Charset getTextEncodingCharSet() { return ISO_8859_1; }
@return the ISO_8859 encoding for Datatypes of this type
StringHashMap::getTextEncodingCharSet
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringHashMap.java
Apache-2.0
public MultipleTextEncodedStringNullTerminated(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody); value = new MultipleTextEncodedStringNullTerminated.Values(); }
Creates a new ObjectStringSizeTerminated datatype. @param identifier identifies the frame type @param frameBody
MultipleTextEncodedStringNullTerminated::MultipleTextEncodedStringNullTerminated
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public int getSize() { return size; }
Returns the size in bytes of this datatype when written to file @return size of this datatype
MultipleTextEncodedStringNullTerminated::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public boolean canBeEncoded() { for (ListIterator<String> li = ((Values) value).getList().listIterator(); li.hasNext();) { TextEncodedStringNullTerminated next = new TextEncodedStringNullTerminated(identifier, frameBody, li.next()); if (!next.canBeEncoded()) { return false; } } return true; }
Check the value can be encoded with the specified encoding @return
MultipleTextEncodedStringNullTerminated::canBeEncoded
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException { logger.finer("Reading MultipleTextEncodedStringNullTerminated from array from offset:" + offset); //Continue until unable to read a null terminated String while (true) { try { //Read String TextEncodedStringNullTerminated next = new TextEncodedStringNullTerminated(identifier, frameBody); next.readByteArray(arr, offset); if (next.getSize() == 0) { break; } else { //Add to value ((Values) value).add((String) next.getValue()); //Add to size calculation size += next.getSize(); //Increment Offset to start of next datatype. offset += next.getSize(); } } catch (InvalidDataTypeException idte) { break; } if (size == 0) { logger.warning("No null terminated Strings found"); throw new InvalidDataTypeException("No null terminated Strings found"); } } logger.finer("Read MultipleTextEncodedStringNullTerminated:" + value + " size:" + size); }
Read Null Terminated Strings from the array starting at offset, continue until unable to find any null terminated Strings or until reached the end of the array. The offset should be set to byte after the last null terminated String found. @param arr to read the Strings from @param offset in the array to start reading from @throws InvalidDataTypeException if unable to find any null terminated Strings
MultipleTextEncodedStringNullTerminated::readByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public byte[] writeByteArray() { logger.finer("Writing MultipleTextEncodedStringNullTerminated"); int localSize = 0; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try { for (ListIterator<String> li = ((Values) value).getList().listIterator(); li.hasNext();) { TextEncodedStringNullTerminated next = new TextEncodedStringNullTerminated(identifier, frameBody, li.next()); buffer.write(next.writeByteArray()); localSize += next.getSize(); } } catch (IOException ioe) { //This should never happen because the write is internal with the JVM it is not to a file logger.log(Level.SEVERE, "IOException in MultipleTextEncodedStringNullTerminated when writing byte array", ioe); throw new RuntimeException(ioe); } //Update size member variable size = localSize; logger.finer("Written MultipleTextEncodedStringNullTerminated"); return buffer.toByteArray(); }
For every String write to bytebuffer @return bytebuffer that should be written to file to persist this datatype.
MultipleTextEncodedStringNullTerminated::writeByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public void add(String value) { valueList.add(value); }
Add String Data type to the value list @param value to add to the list
Values::add
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public List<String> getList() { return valueList; }
Return the list of values @return the list of values
Values::getList
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public int getNumberOfValues() { return valueList.size(); }
@return no of values
Values::getNumberOfValues
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public String toString() { StringBuffer sb = new StringBuffer(); for (ListIterator<String> li = valueList.listIterator(); li.hasNext();) { String next = li.next(); sb.append(next); if (li.hasNext()) { sb.append(","); } } return sb.toString(); }
Return the list of values as a single string separated by a comma @return a string representation of the value
Values::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/MultipleTextEncodedStringNullTerminated.java
Apache-2.0
public Lyrics3Image(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody); }
Creates a new ObjectLyrics3Image datatype. @param identifier @param frameBody
Lyrics3Image::Lyrics3Image
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public void setDescription(String description) { this.description = description; }
@param description
Lyrics3Image::setDescription
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public String getDescription() { return this.description; }
@return
Lyrics3Image::getDescription
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public void setFilename(String filename) { this.filename = filename; }
@param filename
Lyrics3Image::setFilename
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public String getFilename() { return this.filename; }
@return
Lyrics3Image::getFilename
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public int getSize() { int size; size = filename.length() + 2 + description.length() + 2; if (time != null) { size += time.getSize(); } return size; }
@return
Lyrics3Image::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public void setTimeStamp(Lyrics3TimeStamp time) { this.time = time; }
@param time
Lyrics3Image::setTimeStamp
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public Lyrics3TimeStamp getTimeStamp() { return this.time; }
@return
Lyrics3Image::getTimeStamp
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public boolean equals(Object obj) { if (!(obj instanceof Lyrics3Image object)) { return false; } if (!this.description.equals(object.description)) { return false; } if (!this.filename.equals(object.filename)) { return false; } if (this.time == null) { if (object.time != null) { return false; } } else { if (!this.time.equals(object.time)) { return false; } } return super.equals(obj); }
@param obj @return
Lyrics3Image::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public void readString(String imageString, int offset) { if (imageString == null) { throw new NullPointerException("Image string is null"); } if ((offset < 0) || (offset >= imageString.length())) { throw new IndexOutOfBoundsException("Offset to image string is out of bounds: offset = " + offset + ", string.length()" + imageString.length()); } if (imageString != null) { String timestamp; int delim; delim = imageString.indexOf("||", offset); filename = imageString.substring(offset, delim); offset = delim + 2; delim = imageString.indexOf("||", offset); description = imageString.substring(offset, delim); offset = delim + 2; timestamp = imageString.substring(offset); if (timestamp.length() == 7) { time = new Lyrics3TimeStamp("Time Stamp"); time.readString(timestamp); } } }
@param imageString @param offset @throws NullPointerException @throws IndexOutOfBoundsException
Lyrics3Image::readString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public String toString() { String str; str = "filename = " + filename + ", description = " + description; if (time != null) { str += (", timestamp = " + time); } return str + "\n"; }
@return
Lyrics3Image::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public String writeString() { String str; if (filename == null) { str = "||"; } else { str = filename + "||"; } if (description == null) { str += "||"; } else { str += (description + "||"); } if (time != null) { str += time.writeString(); } return str; }
@return
Lyrics3Image::writeString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/Lyrics3Image.java
Apache-2.0
public SynchronisedTempoCodeList(final SynchronisedTempoCodeList copy) { super(copy); }
Mandatory, concretely-typed copy constructor, as required by {@link org.jaudiotagger.tag.datatype.AbstractDataTypeList#AbstractDataTypeList(org.jaudiotagger.tag.datatype.AbstractDataTypeList)}. @param copy instance to copy
SynchronisedTempoCodeList::SynchronisedTempoCodeList
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/SynchronisedTempoCodeList.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/SynchronisedTempoCodeList.java
Apache-2.0
public NumberVariableLength(String identifier, AbstractTagFrameBody frameBody, int minimumSize) { super(identifier, frameBody); //Set minimum length, which can be zero if optional this.minLength = minimumSize; }
Creates a new ObjectNumberVariableLength datatype, set minimum length to zero if this datatype is optional. @param identifier @param frameBody @param minimumSize
NumberVariableLength::NumberVariableLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public int getMaximumLenth() { return MAXIMUM_NO_OF_DIGITS; }
Return the maximum number of digits that can be used to express the number @return the maximum number of digits that can be used to express the number
NumberVariableLength::getMaximumLenth
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public int getMinimumLength() { return minLength; }
Return the minimum number of digits that can be used to express the number @return the minimum number of digits that can be used to express the number
NumberVariableLength::getMinimumLength
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public void setMinimumSize(int minimumSize) { if (minimumSize > 0) { this.minLength = minimumSize; } }
@param minimumSize
NumberVariableLength::setMinimumSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public int getSize() { if (value == null) { return 0; } else { int current; long temp = ID3Tags.getWholeNumber(value); int size = 0; for (int i = MINIMUM_NO_OF_DIGITS; i <= MAXIMUM_NO_OF_DIGITS; i++) { current = (byte) temp & 0xFF; if (current != 0) { size = i; } temp >>= MAXIMUM_NO_OF_DIGITS; } return (minLength > size) ? minLength : size; } }
@return the number of bytes required to write this to a file
NumberVariableLength::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public boolean equals(Object obj) { if (!(obj instanceof NumberVariableLength object)) { return false; } return this.minLength == object.minLength && super.equals(obj); }
@param obj @return
NumberVariableLength::equals
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException { //Coding error, should never happen if (arr == null) { throw new NullPointerException("Byte array is null"); } //Coding error, should never happen as far as I can see if (offset < 0) { throw new IllegalArgumentException("negativer offset into an array offset:" + offset); } //If optional then set value to zero, this will mean that if this frame is written back to file it will be created //with this additional datatype wheras it didnt exist but I think this is probably an advantage the frame is //more likely to be parsed by other applications if it contains optional fields. //if not optional problem with this frame if (offset >= arr.length) { if (minLength == 0) { value = (long) 0; return; } else { throw new InvalidDataTypeException("Offset to byte array is out of bounds: offset = " + offset + ", array.length = " + arr.length); } } long lvalue = 0; //Read the bytes (starting from offset), the most significant byte of the number being constructed is read first, //we then shift the resulting long one byte over to make room for the next byte for (int i = offset; i < arr.length; i++) { lvalue <<= 8; lvalue += (arr[i] & 0xff); } value = lvalue; }
Read from Byte Array @param arr @param offset @throws NullPointerException @throws IndexOutOfBoundsException
NumberVariableLength::readByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public String toString() { if (value == null) { return ""; } else { return value.toString(); } }
@return String representation of the number
NumberVariableLength::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public byte[] writeByteArray() { int size = getSize(); byte[] arr; if (size == 0) { arr = new byte[0]; } else { long temp = ID3Tags.getWholeNumber(value); arr = new byte[size]; //keeps shifting the number downwards and masking the last 8 bist to get the value for the next byte //to be written for (int i = size - 1; i >= 0; i--) { arr[i] = (byte) (temp & 0xFF); temp >>= 8; } } return arr; }
Write to Byte Array @return the datatype converted to a byte array
NumberVariableLength::writeByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/NumberVariableLength.java
Apache-2.0
public EventTimingCodeList(final EventTimingCodeList copy) { super(copy); }
Mandatory, concretely-typed copy constructor, as required by {@link AbstractDataTypeList#AbstractDataTypeList(AbstractDataTypeList)}. @param copy instance to copy
EventTimingCodeList::EventTimingCodeList
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/EventTimingCodeList.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/EventTimingCodeList.java
Apache-2.0
public StringDateTime(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody); }
Creates a new ObjectStringDateTime datatype. @param identifier @param frameBody
StringDateTime::StringDateTime
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringDateTime.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringDateTime.java
Apache-2.0
public void setValue(Object value) { if (value != null) { this.value = value.toString().replace(' ', 'T'); } }
@param value
StringDateTime::setValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringDateTime.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringDateTime.java
Apache-2.0
public Object getValue() { if (value != null) { return value.toString().replace(' ', 'T'); } else { return null; } }
@return
StringDateTime::getValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringDateTime.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringDateTime.java
Apache-2.0
public int getSize() { return size; }
Returns the size in bytes of this dataType when written to file @return size of this dataType
PairedTextEncodedStringNullTerminated::getSize
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public boolean canBeEncoded() { for (Pair entry : ((ValuePairs) value).mapping) { TextEncodedStringNullTerminated next = new TextEncodedStringNullTerminated(identifier, frameBody, entry.getValue()); if (!next.canBeEncoded()) { return false; } } return true; }
Check the value can be encoded with the specified encoding @return
PairedTextEncodedStringNullTerminated::canBeEncoded
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException { logger.finer("Reading PairTextEncodedStringNullTerminated from array from offset:" + offset); //Continue until unable to read a null terminated String while (true) { try { //Read Key TextEncodedStringNullTerminated key = new TextEncodedStringNullTerminated(identifier, frameBody); key.readByteArray(arr, offset); size += key.getSize(); offset += key.getSize(); if (key.getSize() == 0) { break; } try { //Read Value TextEncodedStringNullTerminated result = new TextEncodedStringNullTerminated(identifier, frameBody); result.readByteArray(arr, offset); size += result.getSize(); offset += result.getSize(); if (result.getSize() == 0) { break; } //Add to value ((ValuePairs) value).add((String) key.getValue(),(String) result.getValue()); } catch (InvalidDataTypeException idte) { //Value may not be null terminated if it is the last value //Read Value if(offset>=arr.length) { break; } TextEncodedStringSizeTerminated result = new TextEncodedStringSizeTerminated(identifier, frameBody); result.readByteArray(arr, offset); size += result.getSize(); offset += result.getSize(); if (result.getSize() == 0) { break; } //Add to value ((ValuePairs) value).add((String) key.getValue(),(String) result.getValue()); break; } } catch (InvalidDataTypeException idte) { break; } if (size == 0) { logger.warning("No null terminated Strings found"); throw new InvalidDataTypeException("No null terminated Strings found"); } } logger.finer("Read PairTextEncodedStringNullTerminated:" + value + " size:" + size); }
Read Null Terminated Strings from the array starting at offset, continue until unable to find any null terminated Strings or until reached the end of the array. The offset should be set to byte after the last null terminated String found. @param arr to read the Strings from @param offset in the array to start reading from @throws InvalidDataTypeException if unable to find any null terminated Strings
PairedTextEncodedStringNullTerminated::readByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public byte[] writeByteArray() { logger.finer("Writing PairTextEncodedStringNullTerminated"); int localSize = 0; ByteArrayOutputStream buffer = new ByteArrayOutputStream(); try { for (Pair pair : ((ValuePairs) value).mapping) { { TextEncodedStringNullTerminated next = new TextEncodedStringNullTerminated(identifier, frameBody, pair.getKey()); buffer.write(next.writeByteArray()); localSize += next.getSize(); } { TextEncodedStringNullTerminated next = new TextEncodedStringNullTerminated(identifier, frameBody, pair.getValue()); buffer.write(next.writeByteArray()); localSize += next.getSize(); } } } catch (IOException ioe) { //This should never happen because the write is internal with the JVM it is not to a file logger.log(Level.SEVERE, "IOException in MultipleTextEncodedStringNullTerminated when writing byte array", ioe); throw new RuntimeException(ioe); } //Update size member variable size = localSize; logger.finer("Written PairTextEncodedStringNullTerminated"); return buffer.toByteArray(); }
For every String write to byteBuffer @return byteBuffer that should be written to file to persist this dataType.
PairedTextEncodedStringNullTerminated::writeByteArray
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public void add(String key, String value) { mapping.add(new Pair(key,value)); }
Add String Data type to the value list @param value to add to the list
ValuePairs::add
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public List<Pair> getMapping() { return mapping; }
Return the list of values @return the list of values
ValuePairs::getMapping
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public int getNumberOfValues() { return mapping.size(); }
@return no of values
ValuePairs::getNumberOfValues
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public String toString() { StringBuffer sb = new StringBuffer(); for(Pair next:mapping) { sb.append(next.getKey()+':'+next.getValue()+','); } if(sb.length()>0) { sb.setLength(sb.length() - 1); } return sb.toString(); }
Return the list of values as a single string separated by a colon,comma @return a string representation of the value
ValuePairs::toString
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public int getNumberOfPairs() { return mapping.size(); }
@return no of values
ValuePairs::getNumberOfPairs
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/PairedTextEncodedStringNullTerminated.java
Apache-2.0
public StringDate(String identifier, AbstractTagFrameBody frameBody) { super(identifier, frameBody, 8); }
Creates a new ObjectStringDate datatype. @param identifier @param frameBody
StringDate::StringDate
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringDate.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringDate.java
Apache-2.0
public void setValue(Object value) { if (value != null) { this.value = ID3Tags.stripChar(value.toString(), '-'); } }
@param value
StringDate::setValue
java
ZTFtrue/MonsterMusic
app/src/main/java/org/jaudiotagger/tag/datatype/StringDate.java
https://github.com/ZTFtrue/MonsterMusic/blob/master/app/src/main/java/org/jaudiotagger/tag/datatype/StringDate.java
Apache-2.0