com.palserv.XMidi
Class XM

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by com.palserv.XMidi.XM
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class XM
extends org.xml.sax.helpers.DefaultHandler

Convert an XMidi file (XML) to a midi file.

This class can be used in two ways:

  1. From the command line.
  2. From another java class:
    1. Create an array of Strings which will correspond to the command line arguments.
    2. Pass the array to the constructor:
       XM xm = new XM(args);
       
    3. Invoke the main conversion method:
       xm.xMidiToMidi();
       

Even though the XMidi format has a DTD (XMidi.dtd) associated with it, this program does quite a bit of its own validation. This may be somewhat redundant, but it will allow the program to work on an XMidi file which does not name a DTD. The validation forces many of the same things as the DTD, although there are differences.


Constructor Summary
XM(java.lang.String[] args)
          public constructor Takes "command line" arguments.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Process each element's contents.
 void endElement(java.lang.String uri, java.lang.String localName, java.lang.String qName)
          Process the end of each (XML) element.
static void main(java.lang.String[] args)
          This method is for command line invocation.
 void startElement(java.lang.String uri, java.lang.String localName, java.lang.String qName, org.xml.sax.Attributes attrs)
          Process each (XML) element when it is encountered.
 void xMidiToMidi()
          Convert an XMidi file (XML) to a midi file.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XM

public XM(java.lang.String[] args)
public constructor Takes "command line" arguments. see the Util.getCmdLine method for details. Also, see the main package description for details about external parsers.

Parameters:
args - - command line arguments (as in main)
Method Detail

xMidiToMidi

public void xMidiToMidi()
Convert an XMidi file (XML) to a midi file. Use a SAX parser for speed.


startElement

public void startElement(java.lang.String uri,
                         java.lang.String localName,
                         java.lang.String qName,
                         org.xml.sax.Attributes attrs)
Process each (XML) element when it is encountered.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler

endElement

public void endElement(java.lang.String uri,
                       java.lang.String localName,
                       java.lang.String qName)
Process the end of each (XML) element.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler

characters

public void characters(char[] ch,
                       int start,
                       int length)
Process each element's contents.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler

main

public static void main(java.lang.String[] args)
This method is for command line invocation. See the Util.getCmdLine method for details of the command line syntax.

Parameters:
args - - command line