|
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | ||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |
java.lang.Objectjp.crestmuse.cmx.commands.CMXCommand
public abstract class CMXCommand
The abstract class CMXCommand is the superclass of classes that wraps commands executed on a command line.
コマンドラインから実行するクラスの抽象上位クラスです. 非リアルタイム型のコマンドを作る際には, この抽象クラスを継承して作成します. このクラスにはファイルの読み書きをはじめとする, 共通に用いられる処理が 最初から実装されていますので, ユーザは自分がつくろうとしているコマンド独自の 処理だけを実装すればよいことになります.
具体的なコマンド作成手順は以下の通りです.
CMXCommandクラスを継承してコマンドを作成する上で最低限作る必要があるのは, runメソッドとmainメソッドです. runメソッドは, CMXCommandクラスでは抽象クラスとして定義されており, 指定されたファイルを読み込んだ後の処理内容をここで記述します. 本クラスで定義されているstartメソッドを実行することで, 指定された各ファイルに対して, ファイルを読み込んでrunメソッドを実行して 結果をファイルに書き出すという処理を行います. ですので, mainメソッドではstartメソッドを呼ぶことだけすればよいことに なります. mainメソッドの典型的な記述内容は以下の通りです.
public static void main(String[] args) { MyCommand c = new MyCommand(); try { c.start(args); } catch (Exception e) { c.showErrorMessage(e); System.exit(1); } }
この他に, 前処理を記述するためのpreprocメソッド,後処理を記述するための postprocメソッド,各コマンド独自のオプション処理を追加するための setOptionsLocal, setBoolOptionsLocalメソッドがあります.
コンストラクタの概要 | |
---|---|
CMXCommand()
Constructor |
メソッドの概要 | |
---|---|
protected void |
appendHelpMessage(java.lang.String s)
|
protected void |
exitWithMessage(java.lang.String s)
|
protected static java.lang.String |
getBaseName(java.lang.String filename)
Returns the filename from which both the directory and extension are removed. |
protected static java.lang.String |
getBaseName(java.lang.String filename,
java.lang.String ext)
Returns the filename from which both the directory and extension are removed. |
static ConfigXMLWrapper |
getConfigXMLWrapper()
|
protected java.lang.String |
getDestDir()
|
protected java.lang.String |
getFileName()
Returns the name of the currently processing file. |
protected java.lang.String |
getHelpMessage()
OBSOLETE! |
protected java.lang.String |
getOutFileName()
|
protected java.lang.String |
getVersion()
Returns the program version. |
protected CMXFileWrapper |
indata()
Returns the input document. |
void |
init(CMXFileWrapper f)
ファイルを読み込んだ直後にすべき処理がある場合には, このメソッドをオーバーライドします. |
protected void |
newOutputData(java.lang.String toptagname)
Creates an empty document with the specified top-tag name and assigns it to the outdata instance. |
protected CMXFileWrapper |
outdata()
Returns the output document. |
protected void |
postproc()
Please override this method if your command require post-processing. |
protected void |
preproc()
Please override this method if your command require pre-processing. |
protected CMXFileWrapper |
readInputData(java.lang.String filename)
Reads the specified file and returns a CMXFileWrapper object. |
protected static java.lang.String |
removeDirName(java.lang.String filename)
Returns the filename from which the directory is removed. |
protected static java.lang.String |
removeExt(java.lang.String filename)
Returns the filename from which the extension is removed. |
protected static java.lang.String |
removeExt(java.lang.String filename,
java.lang.String ext)
Returns the filename from which the extension is removed. |
protected abstract void |
run()
Please to override this method to define the main processing. |
protected boolean |
setBoolOptionsLocal(java.lang.String option)
Please override this method to support yes/no options in a subclass. |
protected boolean |
setOptionsLocal(java.lang.String option,
java.lang.String value)
Please override this method to support non-yes/no options in your subclass. |
protected void |
setOutfilename(java.lang.String outfilename)
Set the output filename. |
protected void |
setOutFileName(java.lang.String outfilename)
|
protected void |
setOutputData(CMXFileWrapper outdata)
Assigns the specified CMXFileWrapper object to the output object. |
protected void |
showErrorMessage(java.lang.Exception e)
Shows the error message. |
void |
start(java.lang.String[] args)
以下の処理を行います. |
クラス java.lang.Object から継承されたメソッド |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
コンストラクタの詳細 |
---|
public CMXCommand()
メソッドの詳細 |
---|
protected void setOutfilename(java.lang.String outfilename)
protected void setOutFileName(java.lang.String outfilename)
protected java.lang.String getOutFileName()
protected final CMXFileWrapper indata()
Returns the input document.
入力ドキュメントを返します. runメソッドをオーバーライドする際に, runメソッド内で読み込んだデータに アクセスする際に用いることを想定しています.
protected final CMXFileWrapper outdata()
Returns the output document.
出力ドキュメントを返します. runメソッドをオーバーライドする際に, ファイルに書き込むべきデータを CMXFileWrapperオブジェクトに追加する際に用いることを想定しています.
protected final void newOutputData(java.lang.String toptagname) throws InvalidFileTypeException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException
InvalidFileTypeException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
protected final void setOutputData(CMXFileWrapper outdata)
protected java.lang.String getVersion()
protected boolean setBoolOptionsLocal(java.lang.String option)
protected boolean setOptionsLocal(java.lang.String option, java.lang.String value)
Please override this method to support non-yes/no options in your subclass.
サブクラスで独自の非YES/NO型オプションをサポートする場合には, このメソッドをオーバーライドしてください. このメソッドがオプションを受け入れたらtrue, 受け入れなかったらfalseを返さなければなりません.
protected java.lang.String getDestDir()
protected CMXFileWrapper readInputData(java.lang.String filename) throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, javax.xml.transform.TransformerException
指定されたファイル名を読み込んでCMXFileWrapperオブジェクトを 返します. 具体的には, CMXFileWrapper.readfile(filename)を実行しています. 通常はこのメソッドは使用しませんが, コマンドの都合により, 上記のメソッドが使えない場合(スタンダードMIDIファイル をMIDI XMLドキュメントとして読み込む場合)にオーバーライドしてください. (通常, ユーザがこのメソッドを呼び出す必要はありません.)
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.transform.TransformerException
public void init(CMXFileWrapper f)
CMXInitializer
内の init
public final void start(java.lang.String[] args) throws java.io.IOException, org.xml.sax.SAXException, javax.xml.parsers.ParserConfigurationException, javax.xml.transform.TransformerException, jp.crestmuse.cmx.commands.InvalidOptionException, InvalidFileTypeException
java.io.IOException
org.xml.sax.SAXException
javax.xml.parsers.ParserConfigurationException
javax.xml.transform.TransformerException
jp.crestmuse.cmx.commands.InvalidOptionException
InvalidFileTypeException
protected abstract void run() throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, javax.xml.transform.TransformerException, InvalidFileTypeException
Please to override this method to define the main processing.
このメソッドをオーバーライドして, コマンドのメイン処理を記述してください.
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.transform.TransformerException
InvalidFileTypeException
protected void preproc() throws java.io.IOException, jp.crestmuse.cmx.commands.InvalidOptionException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, javax.xml.transform.TransformerException
Please override this method if your command require pre-processing. The default implementation does nothing.
前処理が必要な場合は, このメソッドをオーバーライドしてください. デフォルトの実装では何もしません.
java.io.IOException
jp.crestmuse.cmx.commands.InvalidOptionException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.transform.TransformerException
protected void postproc() throws java.io.IOException, javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, javax.xml.transform.TransformerException
Please override this method if your command require post-processing. The default implementation does nothing.
後処理が必要な場合は, このメソッドをオーバーライドしてください. デフォルトの実装では何もしません.
java.io.IOException
javax.xml.parsers.ParserConfigurationException
org.xml.sax.SAXException
javax.xml.transform.TransformerException
protected final java.lang.String getFileName()
Returns the name of the currently processing file.
現在処理中のファイル名を返します. runメソッド内で現在処理中のファイル名が必要になったとき(たとえば拡張子だけが 異なるファイルを追加で読み込む場合など)に用いることを想定しています.
public static ConfigXMLWrapper getConfigXMLWrapper()
protected java.lang.String getHelpMessage()
Shows the help message.
ヘルプメッセージを表示します. 独自のヘルプメッセージに変更したい場合は, ここをオーバーライドしてください. (通常はユーザが呼び出す必要はありません.)
protected void appendHelpMessage(java.lang.String s)
protected void showErrorMessage(java.lang.Exception e)
Shows the error message.
エラーメッセージを表示します. 独自のエラーメッセージに変更したい場合は, ここをオーバーライドしてください. (通常はユーザが呼び出す必要はありません.)
protected void exitWithMessage(java.lang.String s)
protected static java.lang.String removeExt(java.lang.String filename)
protected static java.lang.String removeExt(java.lang.String filename, java.lang.String ext)
protected static java.lang.String getBaseName(java.lang.String filename)
protected static java.lang.String getBaseName(java.lang.String filename, java.lang.String ext)
protected static java.lang.String removeDirName(java.lang.String filename)
|
|||||||||
前のクラス 次のクラス | フレームあり フレームなし | ||||||||
概要: 入れ子 | フィールド | コンストラクタ | メソッド | 詳細: フィールド | コンストラクタ | メソッド |