de.humatic.dsj.util
Class AtomParser

java.lang.Object
  extended by de.humatic.dsj.util.AtomParser

public class AtomParser
extends java.lang.Object


Field Summary
static java.lang.String[] ftypes
          Array holding defined ftyp tags.
 
Method Summary
 void close()
           
static AtomParser createForFile(java.io.File atomFile)
          Creates an AtomParser instance to parse data from the given file.
static AtomParser createForType(java.lang.String ftyp)
          Creates an AtomParser instance for the given type to read from raw data.
 void dump()
          Dumps the atom tree read from the file the parser has been initialized with to the current log stream.
 void dump(Atom atom)
          Dumps the given Atom and all its child atoms to the current log stream.
 void dump(byte[] rawData, int startPos)
          Dumps the atom tree read from the given byte array at %startPos to the current log stream.
protected  void finalize()
           
 Atom getAtom(java.lang.String atomID, Atom parentAtom)
          Returns the atom with the given ID from parentAtom's data or null if not found
 Atom getAtom(java.lang.String atomID, byte[] data, int offset)
          Returns the first atom with the given ID within the given raw data.
 Atom getAtom(java.lang.String atomID, int offset)
          Returns the first atom with the given ID starting at offset within the file the parser has been initialized with.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ftypes

public static java.lang.String[] ftypes
Array holding defined ftyp tags. see mp4ra.org for details.

Method Detail

createForType

public static AtomParser createForType(java.lang.String ftyp)
                                throws DSJException
Creates an AtomParser instance for the given type to read from raw data.

Throws:
DSJException

createForFile

public static AtomParser createForFile(java.io.File atomFile)
                                throws java.io.IOException
Creates an AtomParser instance to parse data from the given file. If there is no ftyp atom in the file an exception is thrown.

Throws:
java.io.IOException

close

public void close()

finalize

protected void finalize()
Overrides:
finalize in class java.lang.Object

getAtom

public Atom getAtom(java.lang.String atomID,
                    byte[] data,
                    int offset)
Returns the first atom with the given ID within the given raw data.


getAtom

public Atom getAtom(java.lang.String atomID,
                    int offset)
             throws java.lang.Exception
Returns the first atom with the given ID starting at offset within the file the parser has been initialized with.

Throws:
java.lang.Exception

getAtom

public Atom getAtom(java.lang.String atomID,
                    Atom parentAtom)
Returns the atom with the given ID from parentAtom's data or null if not found


dump

public void dump()
          throws java.lang.Exception
Dumps the atom tree read from the file the parser has been initialized with to the current log stream.

Throws:
java.lang.Exception

dump

public void dump(byte[] rawData,
                 int startPos)
          throws java.lang.Exception
Dumps the atom tree read from the given byte array at %startPos to the current log stream.

Throws:
java.lang.Exception

dump

public void dump(Atom atom)
Dumps the given Atom and all its child atoms to the current log stream.