Package org.jaudiotagger.tag

Examples of org.jaudiotagger.tag.InvalidDataTypeException


        //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));
            }
        }
    }
View Full Code Here


            //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");
            }
View Full Code Here

     * @param arr    this is the buffer for the frame
     * @param offset this is where to start reading in the buffer for this field
     */
    public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException {
        if (offset >= arr.length) {
            throw new InvalidDataTypeException("Unable to find null terminated string");
        }
        int bufferSize;
//
        //logger.finer("Reading from array starting from offset:" + offset);
        int size;

        //Get the Specified Decoder
        String charSetName = getTextEncodingCharSet();
        CharsetDecoder decoder = Charset.forName(charSetName).newDecoder();

        //We only want to load up to null terminator, data after this is part of different
        //field and it may not be possible to decode it so do the check before we do
        //do the decoding,encoding dependent.
        ByteBuffer buffer = ByteBuffer.wrap(arr, offset, arr.length - offset);
        int endPosition = 0;

        //Latin-1 and UTF-8 strings are terminated by a single-byte null,
        //while UTF-16 and its variants need two bytes for the null terminator.
        final boolean nullIsOneByte = (charSetName.equals(TextEncoding.CHARSET_ISO_8859_1) || charSetName.equals(TextEncoding.CHARSET_UTF_8));

        boolean isNullTerminatorFound = false;
        while (buffer.hasRemaining()) {
            byte nextByte = buffer.get();
            if (nextByte == 0x00) {
                if (nullIsOneByte) {
                    buffer.mark();
                    buffer.reset();
                    endPosition = buffer.position() - 1;
//                    logger.finest("Null terminator found starting at:" + endPosition);

                    isNullTerminatorFound = true;
                    break;
                } else {
                    // Looking for two-byte null
                    if (buffer.hasRemaining()) {
                        nextByte = buffer.get();
                        if (nextByte == 0x00) {
                            buffer.mark();
                            buffer.reset();
                            endPosition = buffer.position() - 2;
//                            logger.finest("UTF16:Null terminator found starting  at:" + endPosition);
                            isNullTerminatorFound = true;
                            break;
                        } else {
                            //Nothing to do, we have checked 2nd value of pair it was not a null terminator
                            //so will just start looking again in next invocation of loop
                        }
                    } else {
                        buffer.mark();
                        buffer.reset();
                        endPosition = buffer.position() - 1;
                        //logger.warning("UTF16:Should be two null terminator marks but only found one starting at:" + endPosition);

                        isNullTerminatorFound = true;
                        break;
                    }
                }
            } else {
                //If UTF16, we should only be looking on 2 byte boundaries
                if (!nullIsOneByte) {
                    if (buffer.hasRemaining()) {
                        buffer.get();
                    }
                }
            }
        }

        if (!isNullTerminatorFound) {
            throw new InvalidDataTypeException("Unable to find null terminated string");
        }
//

        //logger.finest("End Position is:" + endPosition + "Offset:" + offset);

View Full Code Here

                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);
    }
View Full Code Here

        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;
View Full Code Here

    public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException {
        if (arr == null) {
            throw new NullPointerException("Byte array is null");
        }
        if ((offset < 0) || (offset >= arr.length)) {
            throw new InvalidDataTypeException("Offset to byte array is out of bounds: offset = " + offset + ", array.length = " + arr.length);
        }

        if (offset + size > arr.length) {
            throw new InvalidDataTypeException("Offset plus size to byte array is out of bounds: offset = "
                    + offset + ", size = " + size + " + arr.length " + arr.length);
        }

        long lvalue = 0;
        for (int i = offset; i < (offset + size); i++) {
View Full Code Here

                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);
    }
View Full Code Here

TOP

Related Classes of org.jaudiotagger.tag.InvalidDataTypeException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.