public void read(ByteBuffer byteBuffer) throws InvalidFrameException, InvalidDataTypeException {
  String identifier=readIdentifier(byteBuffer);
  byte[] buffer=new byte[getFrameSizeSize()];
  if (!isValidID3v2FrameIdentifier(identifier)) {
    logger.config("Invalid identifier:" + identifier);
    byteBuffer.position(byteBuffer.position() - (getFrameIdSize() - 1));
    throw new InvalidFrameIdentifierException(getLoggingFilename() + ":" + identifier+ ":is not a valid ID3v2.20 frame");
  }
  byteBuffer.get(buffer,0,getFrameSizeSize());
  frameSize=decodeSize(buffer);
  if (frameSize < 0) {
    throw new InvalidFrameException(identifier + " has invalid size of:" + frameSize);
  }
 else   if (frameSize == 0) {
    logger.warning("Empty Frame:" + identifier);
    throw new EmptyFrameException(identifier + " is empty frame");
  }
 else   if (frameSize > byteBuffer.remaining()) {
    logger.warning("Invalid Frame size larger than size before mp3 audio:" + identifier);
    throw new InvalidFrameException(identifier + " is invalid frame");
  }
 else {
    logger.fine("Frame Size Is:" + frameSize);
    String id=ID3Tags.convertFrameID22To24(identifier);
    if (id == null) {
      id=ID3Tags.convertFrameID22To23(identifier);
      if (id == null) {
        if (ID3Tags.isID3v22FrameIdentifier(identifier)) {
          id=identifier;
        }
 else {
          id=UNSUPPORTED_ID;
        }
      }
    }
    logger.fine("Identifier was:" + identifier + " reading using:"+ id);
    ByteBuffer frameBodyBuffer=byteBuffer.slice();
    frameBodyBuffer.limit(frameSize);
    try {
      frameBody=readBody(id,frameBodyBuffer,frameSize);
    }
  finally {
      byteBuffer.position(byteBuffer.position() + frameSize);
    }
  }
}

public void read ( ByteBuffer byteBuffer ) throws InvalidFrameException , InvalidDataTypeException { String identifier = readIdentifier ( byteBuffer ) ; byte [ ] buffer = new byte [ getFrameSizeSize ( ) ] ; if ( ! isValidID3v2FrameIdentifier ( identifier ) ) { logger . config ( "Invalid identifier:" + identifier ) ; byteBuffer . position ( byteBuffer . position ( ) - ( getFrameIdSize ( ) - 1 ) ) ; throw new InvalidFrameIdentifierException ( getLoggingFilename ( ) + ":" + identifier + ":is not a valid ID3v2.20 frame" ) ; } byteBuffer . get ( buffer , 0 , getFrameSizeSize ( ) ) ; frameSize = decodeSize ( buffer ) ; if ( frameSize < 0 ) { throw new InvalidFrameException ( identifier + " has invalid size of:" + frameSize ) ; } else if ( frameSize == 0 ) { logger . warning ( "Empty Frame:" + identifier ) ; throw new EmptyFrameException ( identifier + " is empty frame" ) ; } else if ( frameSize > byteBuffer . remaining ( ) ) { logger . warning ( "Invalid Frame size larger than size before mp3 audio:" + identifier ) ; throw new InvalidFrameException ( identifier + " is invalid frame" ) ; } else { logger . fine ( "Frame Size Is:" + frameSize ) ; String id = ID3Tags . convertFrameID22To24 ( identifier ) ; if ( id == null ) { id = ID3Tags . convertFrameID22To23 ( identifier ) ; if ( id == null ) { if ( ID3Tags . isID3v22FrameIdentifier ( identifier ) ) { id = identifier ; } else { id = UNSUPPORTED_ID ; } } } logger . fine ( "Identifier was:" + identifier + " reading using:" + id ) ; ByteBuffer frameBodyBuffer = byteBuffer . slice ( ) ; frameBodyBuffer . limit ( frameSize ) ; try { frameBody = readBody ( id , frameBodyBuffer , frameSize ) ; } finally { byteBuffer . position ( byteBuffer . position ( ) + frameSize ) ; } } }
read frame from file . read the frame header then delegate reading of data to frame body .
