Package org.jaudiotagger.tag.id3.framebody

Examples of org.jaudiotagger.tag.id3.framebody.FrameBodyLINK

@author : Paul Taylor @author : Eric Farng @version $Id: FrameBodyLINK.java 832 2009-11-12 13:25:38Z paultaylor $

        throw new CannotReadException(ErrorMessage.FLAC_NO_FLAC_HEADER_FOUND.getMsg());
    }

    private boolean isId3v24Tag() throws IOException {
        int id3tagsize;
        ID3v24Tag id3tag = new ID3v24Tag();
        ByteBuffer bb = ByteBuffer.allocate(AbstractID3v2Tag.TAG_HEADER_LENGTH);
        raf.seek(0);
        raf.getChannel().read(bb);
        if (id3tag.seek(bb)) {
            id3tagsize = id3tag.readSize(bb);
            raf.seek(id3tagsize);
            //FLAC Stream immediately after end of id3 tag
            if (isFlacHeader()) {
                return true;
            }
View Full Code Here


                newField = new Lyrics3v2Field(new FieldFrameBodyLYR(lyricOld.getLyric()));
                fieldMap.put(newField.getIdentifier(), newField);
            } else {
                Lyrics3v2Field newField;
                Iterator<AbstractID3v2Frame> iterator;
                iterator = (new ID3v24Tag(mp3tag)).iterator();

                while (iterator.hasNext()) {
                    try {
                        newField = new Lyrics3v2Field(iterator.next());
View Full Code Here

      else if (frame.getBody() instanceof FrameBodyPOPM) {
        FrameBodyPOPM body = (FrameBodyPOPM) frame.getBody();
        track.getTrackData().addRating(String.valueOf(body.getRating()));
      }
      else if (frame.getBody() instanceof AbstractFrameBodyTextInfo) {
        AbstractFrameBodyTextInfo body = (AbstractFrameBodyTextInfo) frame.getBody();
        for (int i = 0; i < body.getNumberOfValues(); i++) {
          track.getTrackData().addTagFieldValues(key, body.getValueAtIndex(i));
        }
      }
    }
  }
View Full Code Here

     *
     * @param frame
     * @throws TagException
     */
    public Lyrics3v2Field(AbstractID3v2Frame frame) throws TagException {
        AbstractFrameBodyTextInfo textFrame;
        String text;
        String frameIdentifier = frame.getIdentifier();
        if (frameIdentifier.startsWith("USLT")) {
            frameBody = new FieldFrameBodyLYR("");
            ((FieldFrameBodyLYR) frameBody).addLyric((FrameBodyUSLT) frame.getBody());
        } else if (frameIdentifier.startsWith("SYLT")) {
            frameBody = new FieldFrameBodyLYR("");
            ((FieldFrameBodyLYR) frameBody).addLyric((FrameBodySYLT) frame.getBody());
        } else if (frameIdentifier.startsWith("COMM")) {
            text = ((FrameBodyCOMM) frame.getBody()).getText();
            frameBody = new FieldFrameBodyINF(text);
        } else if (frameIdentifier.equals("TCOM")) {
            textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
            frameBody = new FieldFrameBodyAUT("");
            if ((textFrame != null) && (textFrame.getText().length() > 0)) {
                frameBody = new FieldFrameBodyAUT(textFrame.getText());
            }
        } else if (frameIdentifier.equals("TALB")) {
            textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
            if ((textFrame != null) && (textFrame.getText().length() > 0)) {
                frameBody = new FieldFrameBodyEAL(textFrame.getText());
            }
        } else if (frameIdentifier.equals("TPE1")) {
            textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
            if ((textFrame != null) && (textFrame.getText().length() > 0)) {
                frameBody = new FieldFrameBodyEAR(textFrame.getText());
            }
        } else if (frameIdentifier.equals("TIT2")) {
            textFrame = (AbstractFrameBodyTextInfo) frame.getBody();
            if ((textFrame != null) && (textFrame.getText().length() > 0)) {
                frameBody = new FieldFrameBodyETT(textFrame.getText());
            }
        } else {
            throw new TagException("Cannot createField Lyrics3v2 field from given ID3v2 frame");
        }
    }
View Full Code Here

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

            throws InvalidFrameException, InvalidDataTypeException {
        //Use reflection to map id to frame body, which makes things much easier
        //to keep things up to date,although slight performance hit.
        //logger.finest("Creating framebody:start");

        AbstractID3v2FrameBody frameBody;
        try {
            Class<AbstractID3v2FrameBody> c = (Class<AbstractID3v2FrameBody>) Class.forName("org.jaudiotagger.tag.id3.framebody.FrameBody" + identifier);
            Class<?>[] constructorParameterTypes = {Class.forName("java.nio.ByteBuffer"), Integer.TYPE};
            Object[] constructorParameterValues = {byteBuffer, frameSize};
            Constructor<AbstractID3v2FrameBody> construct = c.getConstructor(constructorParameterTypes);
            frameBody = (construct.newInstance(constructorParameterValues));
        }
        //No class defined for this frame type,use FrameUnsupported
        catch (ClassNotFoundException cex) {
            //logger.info(getLoggingFilename() + ":" + "Identifier not recognised:" + identifier + " using FrameBodyUnsupported");
            try {
                frameBody = new FrameBodyUnsupported(byteBuffer, frameSize);
            }
            //Should only throw InvalidFrameException but unfortunately legacy hierachy forces
            //read method to declare it can throw InvalidtagException
            catch (InvalidFrameException ife) {
                throw ife;
            } catch (InvalidTagException te) {
                throw new InvalidFrameException(te.getMessage());
            }
        }
        //An error has occurred during frame instantiation, if underlying cause is an unchecked exception or error
        //propagate it up otherwise mark this frame as invalid
        catch (InvocationTargetException ite) {
            logger.severe(getLoggingFilename() + ":" + "An error occurred within abstractID3v2FrameBody for identifier:" + identifier + ":" + ite.getCause().getMessage());
            if (ite.getCause() instanceof Error) {
                throw (Error) ite.getCause();
            } else if (ite.getCause() instanceof RuntimeException) {
                throw (RuntimeException) ite.getCause();
            } else if (ite.getCause() instanceof InvalidFrameException) {
                throw (InvalidFrameException) ite.getCause();
            } else if (ite.getCause() instanceof InvalidDataTypeException) {
                throw (InvalidDataTypeException) ite.getCause();
            } else {
                throw new InvalidFrameException(ite.getCause().getMessage());
            }
        }
        //No Such Method should not happen
        catch (NoSuchMethodException sme) {
            logger.log(Level.SEVERE, getLoggingFilename() + ":" + "No such method:" + sme.getMessage(), sme);
            throw new RuntimeException(sme.getMessage());
        }
        //Instantiate Interface/Abstract should not happen
        catch (InstantiationException ie) {
            logger.log(Level.SEVERE, getLoggingFilename() + ":" + "Instantiation exception:" + ie.getMessage(), ie);
            throw new RuntimeException(ie.getMessage());
        }
        //Private Constructor shouild not happen
        catch (IllegalAccessException iae) {
            logger.log(Level.SEVERE, getLoggingFilename() + ":" + "Illegal access exception :" + iae.getMessage(), iae);
            throw new RuntimeException(iae.getMessage());
        }
        //logger.finest(getLoggingFilename() + ":" + "Created framebody:end" + frameBody.getIdentifier());
        frameBody.setHeader(this);
        return frameBody;
    }
View Full Code Here

    //TODO using reflection is rather slow perhaps we should change this
    protected AbstractID3v2FrameBody readBody(String identifier, AbstractID3v2FrameBody body) throws InvalidFrameException {
        /* Use reflection to map id to frame body, which makes things much easier
         * to keep things up to date, although slight performance hit.
         */
        AbstractID3v2FrameBody frameBody;
        try {
            Class<AbstractID3v2FrameBody> c = (Class<AbstractID3v2FrameBody>) Class.forName("org.jaudiotagger.tag.id3.framebody.FrameBody" + identifier);
            Class<?>[] constructorParameterTypes = {body.getClass()};
            Object[] constructorParameterValues = {body};
            Constructor<AbstractID3v2FrameBody> construct = c.getConstructor(constructorParameterTypes);
            frameBody = (construct.newInstance(constructorParameterValues));
        } catch (ClassNotFoundException cex) {
            //logger.info("Identifier not recognised:" + identifier + " unable to create framebody");
            throw new InvalidFrameException("FrameBody" + identifier + " does not exist");
        }
        //If suitable constructor does not exist
        catch (NoSuchMethodException sme) {
            logger.log(Level.SEVERE, "No such method:" + sme.getMessage(), sme);
            throw new InvalidFrameException("FrameBody" + identifier + " does not have a constructor that takes:" + body.getClass().getName());
        } catch (InvocationTargetException ite) {
            logger.severe("An error occurred within abstractID3v2FrameBody");
            logger.log(Level.SEVERE, "Invocation target exception:" + ite.getCause().getMessage(), ite.getCause());
            if (ite.getCause() instanceof Error) {
                throw (Error) ite.getCause();
            } else if (ite.getCause() instanceof RuntimeException) {
                throw (RuntimeException) ite.getCause();
            } else {
                throw new InvalidFrameException(ite.getCause().getMessage());
            }
        }

        //Instantiate Interface/Abstract should not happen
        catch (InstantiationException ie) {
            logger.log(Level.SEVERE, "Instantiation exception:" + ie.getMessage(), ie);
            throw new RuntimeException(ie.getMessage());
        }
        //Private Constructor shouild not happen
        catch (IllegalAccessException iae) {
            logger.log(Level.SEVERE, "Illegal access exception :" + iae.getMessage(), iae);
            throw new RuntimeException(iae.getMessage());
        }
//logger.finer("frame Body created" + frameBody.getIdentifier());
        frameBody.setHeader(this);
        return frameBody;
    }
View Full Code Here

        else if (FieldKey.DISC_TOTAL.equals(key)) {
          track.getTrackData().addDiscTotal(body.getDiscTotal());
        }
      }
      else if (frame.getBody() instanceof FrameBodyCOMM) {
        FrameBodyCOMM body = (FrameBodyCOMM) frame.getBody();
        track.getTrackData().addComment(body.getText());
      }
      else if (frame.getBody() instanceof FrameBodyPOPM) {
        FrameBodyPOPM body = (FrameBodyPOPM) frame.getBody();
        track.getTrackData().addRating(String.valueOf(body.getRating()));
      }
      else if (frame.getBody() instanceof AbstractFrameBodyTextInfo) {
        AbstractFrameBodyTextInfo body = (AbstractFrameBodyTextInfo) frame.getBody();
        for (int i = 0; i < body.getNumberOfValues(); i++) {
          track.getTrackData().addTagFieldValues(key, body.getValueAtIndex(i));
        }
      }
    }
  }
View Full Code Here

                identifier = frame.getIdentifier();
                //logger.info("DEPRECATED:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier);
            }
            //or was it still deprecated, if so leave as is
            else {
                this.frameBody = new FrameBodyDeprecated((FrameBodyDeprecated) frame.getBody());
                identifier = frame.getIdentifier();
                //logger.info("DEPRECATED:Orig id is:" + frame.getIdentifier() + ":New id is:" + identifier);
            }
        }
        // Unknown Frame e.g NCON
View Full Code Here

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

TOP

Related Classes of org.jaudiotagger.tag.id3.framebody.FrameBodyLINK

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.