チェンジセット 4

差分発生行の前後
無視リスト:
更新日時:
2010/05/11 20:15:55 (2 年 前)
更新者:
h
ログメッセージ:

refs #2 #8 #9 #7 #6
現状のソースをコミット。一部完了。一部未完了。
関連づいてない完了チケットのチェンジセットもまとめて。
パッケージ階層も大幅に変更。

パス:
trunk/src/org/rayflood/mikuvat
ファイル:
4 追加
20 変更
24 移動

凡例:

変更なし
追加
削除
  • trunk/src/org/rayflood/mikuvat/Mikuvat.java

    r2 r4  
    1212import org.rayflood.mikuvat.plugin.PluginLoader; 
    1313 
     14/** 
     15 * ミクバット - VSQ Adjustment Tool 調整の難しいVSQパラメータを、ある程度オートで調整するツールです。 
     16 * 調整機能そのものはプラグインで実装されており、拡張可能です。 プラグインの機能については各プラグインのヘルプを参照してください。 
     17 * 
     18 * コマンド GUIツールを起動します。 java -jar mikuvat.jar このヘルプ画面を表示します。 java -jar mikuvat.jar 
     19 * --help プラグインのヘルプを表示します。 java -jar mikuvat.jar PLUGIN オプションを渡してプラグインを起動します。 
     20 * java -jar mikuvat.jar PLUGIN [OPTION]... 
     21 */ 
    1422public class Mikuvat{ 
    1523        public static final String MIKUVAT_APPNAME = "ミクバット"; 
    16         public static final String MIKUVAT_VERSION = "0.1"; 
     24        public static final String MIKUVAT_VERSION = "0.2"; 
    1725        public static final String MIKUVAT_TITLE = MIKUVAT_APPNAME + " - ver " + MIKUVAT_VERSION; 
    1826 
     
    2028        public static ImageIcon ICON; 
    2129 
     30        /** 
     31         * @param args 
     32         * @throws Exception 
     33         */ 
    2234        public static void main(String args[]) throws Exception{ 
    2335                Mikuvat mikuvat = new Mikuvat(); 
     
    2537        } 
    2638 
     39        /** 
     40         * @param args 
     41         * @throws Exception 
     42         */ 
    2743        public void start(String args[]) throws Exception{ 
    2844                Map<String, PluginInstance> pluginInstance = PluginLoader.load(); 
     
    6884        } 
    6985 
     86        /** 
     87         * @param resource 
     88         */ 
    7089        public static void printTextResource(String resource){ 
    7190                System.out.println(getTextResource(resource)); 
    7291        } 
    7392 
     93        /** 
     94         * @param resource 
     95         * @return textResource 
     96         */ 
    7497        public static String getTextResource(String resource){ 
    75                 StringBuffer sb = new StringBuffer(); 
     98                StringBuilder sb = new StringBuilder(); 
    7699                try{ 
    77100                        BufferedReader br = new BufferedReader(new InputStreamReader( 
  • trunk/src/org/rayflood/mikuvat/Utilities.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat; 
    22 
    3 import java.io.BufferedReader; 
    4 import java.io.StringReader; 
    53import java.math.BigDecimal; 
    6 import java.nio.charset.Charset; 
    74import java.util.ArrayList; 
    8 import java.util.LinkedHashMap; 
    95import java.util.List; 
    10 import java.util.Map; 
    116import java.util.SortedMap; 
    127import java.util.TreeMap; 
    138import java.util.regex.Pattern; 
    149 
    15 import javax.sound.midi.MetaMessage; 
    16 import javax.sound.midi.MidiEvent; 
    17 import javax.sound.midi.MidiMessage; 
    18 import javax.sound.midi.Track; 
     10import org.rayflood.mikuvat.io.vsq.VibratoBP; 
    1911 
    20 public class VSQDecoder{ 
     12public class Utilities{ 
    2113        public static final Pattern SPLITEQUAL = Pattern.compile("="); 
    2214        public static final Pattern SPLITCOMMA = Pattern.compile(","); 
    2315        public static final Pattern SPLITDQUOTE = Pattern.compile("\\\""); 
    24         public static final Pattern MMHEADER = Pattern.compile("^DM:\\d+:$"); 
    25         public static final Pattern SECTIONLINE = Pattern.compile("^\\[.+\\]$"); 
    26         public static final Charset WIN31J = Charset.forName("Windows-31J"); 
    27         public static final int TEXTLENGTH = 119; 
    2816 
    2917        public static String[] splitEqual(String s){ 
     
    8674 
    8775        public static String getByteArrayString(byte[] data){ 
    88                 StringBuffer sb = new StringBuffer(); 
     76                StringBuilder sb = new StringBuilder(); 
    8977                if(data != null && data.length > 0){ 
    9078                        sb.append(String.format("%X", data[0])); 
     
    9482                } 
    9583                return sb.toString(); 
    96         } 
    97  
    98         public static Map<String, List<String>> decode(Track tr) throws Exception{ 
    99                 List<Byte> v = new ArrayList<Byte>(); 
    100                 for(int i = 1; i < tr.size(); i++){ 
    101                         MidiMessage m = tr.get(i).getMessage(); 
    102                         if(m instanceof MetaMessage){ 
    103                                 byte b[] = ((MetaMessage)m).getData(); 
    104                                 if(b.length == 0){ 
    105                                         continue; 
    106                                 } 
    107                                 int h = 1; 
    108                                 String mmheader; 
    109                                 do{ 
    110                                         h++; 
    111                                         mmheader = new String(b, 0, h * 4, WIN31J); 
    112                                 }while(!MMHEADER.matcher(mmheader).matches()); 
    113                                 for(int k = h * 4; k < b.length; k++){ 
    114                                         if(b[k] != 0x00){ 
    115                                                 v.add(new Byte(b[k])); 
    116                                         } 
    117                                 } 
    118                         } 
    119                 } 
    120                 byte b[] = new byte[v.size()]; 
    121                 for(int i = 0; i < v.size(); i++){ 
    122                         b[i] = v.get(i); 
    123                 } 
    124                 String textevent = new String(b, WIN31J); 
    125  
    126                 Map<String, List<String>> sections = new LinkedHashMap<String, List<String>>(); 
    127                 BufferedReader br = new BufferedReader(new StringReader(textevent)); 
    128                 String bf; 
    129                 String sn = ""; 
    130                 List<String> sv = new ArrayList<String>(); 
    131                 do{ 
    132                         bf = br.readLine(); 
    133                         if(bf == null || SECTIONLINE.matcher(bf).matches()){ 
    134                                 if(sn.length() > 0 && !sections.containsKey(sn)){ 
    135                                         sections.put(sn.substring(1, sn.length() - 1), sv); 
    136                                 } 
    137                                 sn = bf; 
    138                                 sv = new ArrayList<String>(); 
    139                         } 
    140                         else if(bf.length() > 0){ 
    141                                 sv.add(bf); 
    142                         } 
    143                 }while(bf != null); 
    144  
    145                 return sections; 
    146         } 
    147  
    148         public static List<MidiEvent> encode(List<String> trackSections) throws Exception{ 
    149                 String te = ""; 
    150                 for(int i = 0; i < trackSections.size(); i++){ 
    151                         String vts = trackSections.get(i); 
    152                         te += vts + "\n"; 
    153                 } 
    154  
    155                 List<MidiEvent> tme = new ArrayList<MidiEvent>(); 
    156                 byte b[] = te.getBytes(WIN31J); 
    157                 for(int j = 0; j <= b.length / TEXTLENGTH; j++){ 
    158                         int h = (int)StrictMath.ceil((double)Integer.toString(j).length() / 4.0); 
    159                         String mef = "DM:%0" + h * 4 + "d:"; 
    160                         byte header[] = String.format(mef, j).getBytes(WIN31J); 
    161                         List<Byte> mbl = new ArrayList<Byte>(); 
    162                         for(int k = 0; k < header.length; k++){ 
    163                                 mbl.add(header[k]); 
    164                         } 
    165                         for(int k = 0; k < TEXTLENGTH; k++){ 
    166                                 int bi = j * TEXTLENGTH + k; 
    167                                 if(bi >= b.length){ 
    168                                         break; 
    169                                 } 
    170                                 mbl.add(b[bi]); 
    171                         } 
    172                         byte mb[] = new byte[mbl.size()]; 
    173                         for(int k = 0; k < mbl.size(); k++){ 
    174                                 mb[k] = mbl.get(k); 
    175                         } 
    176                         MetaMessage mm = new MetaMessage(); 
    177                         mm.setMessage(1, mb, mb.length); 
    178                         tme.add(new MidiEvent(mm, 0L)); 
    179                 } 
    180  
    181                 return tme; 
    18284        } 
    18385 
  • trunk/src/org/rayflood/mikuvat/gui/AnoteDialog.java

    r2 r4  
    55import java.awt.Window; 
    66 
    7 import org.rayflood.mikuvat.io.AnoteEvent; 
    8 import org.rayflood.mikuvat.io.LyricHandle; 
    9 import org.rayflood.mikuvat.io.VibratoHandle; 
     7import org.rayflood.mikuvat.io.vsq.AnoteEvent; 
     8import org.rayflood.mikuvat.io.vsq.LyricHandle; 
     9import org.rayflood.mikuvat.io.vsq.VibratoHandle; 
    1010 
    1111public class AnoteDialog extends PropertyDialog{ 
  • trunk/src/org/rayflood/mikuvat/gui/AnotePanel.java

    r2 r4  
    11package org.rayflood.mikuvat.gui; 
    22 
    3 import static org.rayflood.mikuvat.io.AnoteEvent.ACCENT_MAX; 
    4 import static org.rayflood.mikuvat.io.AnoteEvent.ACCENT_MIN; 
    5 import static org.rayflood.mikuvat.io.AnoteEvent.BENDDEPTH_MAX; 
    6 import static org.rayflood.mikuvat.io.AnoteEvent.BENDDEPTH_MIN; 
    7 import static org.rayflood.mikuvat.io.AnoteEvent.BENDLENGTH_MAX; 
    8 import static org.rayflood.mikuvat.io.AnoteEvent.BENDLENGTH_MIN; 
    9 import static org.rayflood.mikuvat.io.AnoteEvent.DECAY_MAX; 
    10 import static org.rayflood.mikuvat.io.AnoteEvent.DECAY_MIN; 
    11 import static org.rayflood.mikuvat.io.AnoteEvent.NOTE_PARAMLIST; 
    12 import static org.rayflood.mikuvat.io.AnoteEvent.PORTAMENTOUSE_PARAMLIST; 
    13 import static org.rayflood.mikuvat.io.AnoteEvent.VELOCITY_MAX; 
    14 import static org.rayflood.mikuvat.io.AnoteEvent.VELOCITY_MIN; 
     3import static org.rayflood.mikuvat.io.vsq.AnoteEvent.ACCENT_MAX; 
     4import static org.rayflood.mikuvat.io.vsq.AnoteEvent.ACCENT_MIN; 
     5import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDDEPTH_MAX; 
     6import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDDEPTH_MIN; 
     7import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDLENGTH_MAX; 
     8import static org.rayflood.mikuvat.io.vsq.AnoteEvent.BENDLENGTH_MIN; 
     9import static org.rayflood.mikuvat.io.vsq.AnoteEvent.DECAY_MAX; 
     10import static org.rayflood.mikuvat.io.vsq.AnoteEvent.DECAY_MIN; 
     11import static org.rayflood.mikuvat.io.vsq.AnoteEvent.NOTE_PARAMLIST; 
     12import static org.rayflood.mikuvat.io.vsq.AnoteEvent.PORTAMENTOUSE_PARAMLIST; 
     13import static org.rayflood.mikuvat.io.vsq.AnoteEvent.VELOCITY_MAX; 
     14import static org.rayflood.mikuvat.io.vsq.AnoteEvent.VELOCITY_MIN; 
    1515 
    1616import java.awt.BorderLayout; 
     
    2626import javax.swing.event.ChangeListener; 
    2727 
    28 import org.rayflood.mikuvat.io.AnoteEvent; 
    29 import org.rayflood.mikuvat.io.LyricHandle; 
    30 import org.rayflood.mikuvat.io.LyricNote; 
    31 import org.rayflood.mikuvat.io.VibratoHandle; 
     28import org.rayflood.mikuvat.io.vsq.AnoteEvent; 
     29import org.rayflood.mikuvat.io.vsq.LyricHandle; 
     30import org.rayflood.mikuvat.io.vsq.LyricNote; 
     31import org.rayflood.mikuvat.io.vsq.VibratoHandle; 
    3232 
    3333public class AnotePanel extends PropertyPanel{ 
  • trunk/src/org/rayflood/mikuvat/gui/BPLineDialog.java

    r2 r4  
    55import java.awt.Window; 
    66 
    7 import org.rayflood.mikuvat.io.EventBPTime; 
     7import org.rayflood.mikuvat.io.vsq.EventBPTime; 
    88 
    99public class BPLineDialog extends PropertyDialog{ 
  • trunk/src/org/rayflood/mikuvat/gui/BPLinePanel.java

    r2 r4  
    11package org.rayflood.mikuvat.gui; 
    22 
    3 import static org.rayflood.mikuvat.io.EventBPTime.BREATHINESS_MAX; 
    4 import static org.rayflood.mikuvat.io.EventBPTime.BREATHINESS_MIN; 
    5 import static org.rayflood.mikuvat.io.EventBPTime.BRIGHTNESS_MAX; 
    6 import static org.rayflood.mikuvat.io.EventBPTime.BRIGHTNESS_MIN; 
    7 import static org.rayflood.mikuvat.io.EventBPTime.CLEARNESS_MAX; 
    8 import static org.rayflood.mikuvat.io.EventBPTime.CLEARNESS_MIN; 
    9 import static org.rayflood.mikuvat.io.EventBPTime.DYNAMICS_MAX; 
    10 import static org.rayflood.mikuvat.io.EventBPTime.DYNAMICS_MIN; 
    11 import static org.rayflood.mikuvat.io.EventBPTime.GENDERFACTOR_MAX; 
    12 import static org.rayflood.mikuvat.io.EventBPTime.GENDERFACTOR_MIN; 
    13 import static org.rayflood.mikuvat.io.EventBPTime.OPENING_MAX; 
    14 import static org.rayflood.mikuvat.io.EventBPTime.OPENING_MIN; 
    15 import static org.rayflood.mikuvat.io.EventBPTime.PITCHBENDSENS_MAX; 
    16 import static org.rayflood.mikuvat.io.EventBPTime.PITCHBENDSENS_MIN; 
    17 import static org.rayflood.mikuvat.io.EventBPTime.PITCHBEND_MAX; 
    18 import static org.rayflood.mikuvat.io.EventBPTime.PITCHBEND_MIN; 
    19 import static org.rayflood.mikuvat.io.EventBPTime.PORTAMENTOTIMING_MAX; 
    20 import static org.rayflood.mikuvat.io.EventBPTime.PORTAMENTOTIMING_MIN; 
     3import static org.rayflood.mikuvat.io.vsq.EventBPTime.BREATHINESS_MAX; 
     4import static org.rayflood.mikuvat.io.vsq.EventBPTime.BREATHINESS_MIN; 
     5import static org.rayflood.mikuvat.io.vsq.EventBPTime.BRIGHTNESS_MAX; 
     6import static org.rayflood.mikuvat.io.vsq.EventBPTime.BRIGHTNESS_MIN; 
     7import static org.rayflood.mikuvat.io.vsq.EventBPTime.CLEARNESS_MAX; 
     8import static org.rayflood.mikuvat.io.vsq.EventBPTime.CLEARNESS_MIN; 
     9import static org.rayflood.mikuvat.io.vsq.EventBPTime.DYNAMICS_MAX; 
     10import static org.rayflood.mikuvat.io.vsq.EventBPTime.DYNAMICS_MIN; 
     11import static org.rayflood.mikuvat.io.vsq.EventBPTime.GENDERFACTOR_MAX; 
     12import static org.rayflood.mikuvat.io.vsq.EventBPTime.GENDERFACTOR_MIN; 
     13import static org.rayflood.mikuvat.io.vsq.EventBPTime.OPENING_MAX; 
     14import static org.rayflood.mikuvat.io.vsq.EventBPTime.OPENING_MIN; 
     15import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBENDSENS_MAX; 
     16import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBENDSENS_MIN; 
     17import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBEND_MAX; 
     18import static org.rayflood.mikuvat.io.vsq.EventBPTime.PITCHBEND_MIN; 
     19import static org.rayflood.mikuvat.io.vsq.EventBPTime.PORTAMENTOTIMING_MAX; 
     20import static org.rayflood.mikuvat.io.vsq.EventBPTime.PORTAMENTOTIMING_MIN; 
    2121 
    2222import java.awt.BorderLayout; 
     
    2626import javax.swing.SpinnerNumberModel; 
    2727 
    28 import org.rayflood.mikuvat.io.EventBPTime; 
     28import org.rayflood.mikuvat.io.vsq.EventBPTime; 
    2929 
    3030public class BPLinePanel extends PropertyPanel{ 
  • trunk/src/org/rayflood/mikuvat/gui/MasterDialog.java

    r2 r4  
    33import java.awt.Window; 
    44 
    5 import org.rayflood.mikuvat.io.MasterSection; 
    6 import org.rayflood.mikuvat.io.MixerSection; 
     5import org.rayflood.mikuvat.io.vsq.MasterSection; 
     6import org.rayflood.mikuvat.io.vsq.MixerSection; 
    77import static org.rayflood.mikuvat.gui.MasterPanel.*; 
    88 
  • trunk/src/org/rayflood/mikuvat/gui/MasterPanel.java

    r2 r4  
    11package org.rayflood.mikuvat.gui; 
    22 
    3 import static org.rayflood.mikuvat.io.MasterSection.PREMEASURE_MAX; 
    4 import static org.rayflood.mikuvat.io.MasterSection.PREMEASURE_MIN; 
    5 import static org.rayflood.mikuvat.io.MixerSection.FEDER_MAX; 
    6 import static org.rayflood.mikuvat.io.MixerSection.FEDER_MIN; 
    7 import static org.rayflood.mikuvat.io.MixerSection.OUTPUTMODE_PARAMLIST; 
    8 import static org.rayflood.mikuvat.io.MixerSection.PANPOT_MAX; 
    9 import static org.rayflood.mikuvat.io.MixerSection.PANPOT_MIN; 
     3import static org.rayflood.mikuvat.io.vsq.MasterSection.PREMEASURE_MAX; 
     4import static org.rayflood.mikuvat.io.vsq.MasterSection.PREMEASURE_MIN; 
     5import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MAX; 
     6import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MIN; 
     7import static org.rayflood.mikuvat.io.vsq.MixerSection.OUTPUTMODE_PARAMLIST; 
     8import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MAX; 
     9import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MIN; 
    1010 
    1111import java.awt.BorderLayout; 
     
    1919import javax.swing.SpinnerNumberModel; 
    2020 
    21 import org.rayflood.mikuvat.io.MasterSection; 
    22 import org.rayflood.mikuvat.io.MixerSection; 
    23 import org.rayflood.mikuvat.io.MixerSetting; 
     21import org.rayflood.mikuvat.io.vsq.MasterSection; 
     22import org.rayflood.mikuvat.io.vsq.MixerSection; 
     23import org.rayflood.mikuvat.io.vsq.MixerSetting; 
    2424 
    2525public class MasterPanel extends PropertyPanel{ 
  • trunk/src/org/rayflood/mikuvat/gui/MikuvatFrame.java

    r2 r4  
    3131 
    3232import org.rayflood.mikuvat.MikuvatProperties; 
    33 import org.rayflood.mikuvat.io.VSQFile; 
     33import org.rayflood.mikuvat.io.vsq.VSQFile; 
    3434import org.rayflood.mikuvat.plugin.PluginInstance; 
    3535import org.rayflood.mikuvat.plugin.PluginInterface; 
  • trunk/src/org/rayflood/mikuvat/gui/ResoBPLineDialog.java

    r2 r4  
    55import java.awt.Window; 
    66 
    7 import org.rayflood.mikuvat.io.EventBPTime; 
     7import org.rayflood.mikuvat.io.vsq.EventBPTime; 
    88 
    99public class ResoBPLineDialog extends PropertyDialog{ 
  • trunk/src/org/rayflood/mikuvat/gui/ResoBPLinePanel.java

    r2 r4  
    11package org.rayflood.mikuvat.gui; 
    22 
    3 import static org.rayflood.mikuvat.io.EventBPTime.RESO1AMP_MAX; 
    4 import static org.rayflood.mikuvat.io.EventBPTime.RESO1AMP_MIN; 
    5 import static org.rayflood.mikuvat.io.EventBPTime.RESO1BW_MAX; 
    6 import static org.rayflood.mikuvat.io.EventBPTime.RESO1BW_MIN; 
    7 import static org.rayflood.mikuvat.io.EventBPTime.RESO1FREQ_MAX; 
    8 import static org.rayflood.mikuvat.io.EventBPTime.RESO1FREQ_MIN; 
    9 import static org.rayflood.mikuvat.io.EventBPTime.RESO2AMP_MAX; 
    10 import static org.rayflood.mikuvat.io.EventBPTime.RESO2AMP_MIN; 
    11 import static org.rayflood.mikuvat.io.EventBPTime.RESO2BW_MAX; 
    12 import static org.rayflood.mikuvat.io.EventBPTime.RESO2BW_MIN; 
    13 import static org.rayflood.mikuvat.io.EventBPTime.RESO2FREQ_MAX; 
    14 import static org.rayflood.mikuvat.io.EventBPTime.RESO2FREQ_MIN; 
    15 import static org.rayflood.mikuvat.io.EventBPTime.RESO3AMP_MAX; 
    16 import static org.rayflood.mikuvat.io.EventBPTime.RESO3AMP_MIN; 
    17 import static org.rayflood.mikuvat.io.EventBPTime.RESO3BW_MAX; 
    18 import static org.rayflood.mikuvat.io.EventBPTime.RESO3BW_MIN; 
    19 import static org.rayflood.mikuvat.io.EventBPTime.RESO3FREQ_MAX; 
    20 import static org.rayflood.mikuvat.io.EventBPTime.RESO3FREQ_MIN; 
    21 import static org.rayflood.mikuvat.io.EventBPTime.RESO4AMP_MAX; 
    22 import static org.rayflood.mikuvat.io.EventBPTime.RESO4AMP_MIN; 
    23 import static org.rayflood.mikuvat.io.EventBPTime.RESO4BW_MAX; 
    24 import static org.rayflood.mikuvat.io.EventBPTime.RESO4BW_MIN; 
    25 import static org.rayflood.mikuvat.io.EventBPTime.RESO4FREQ_MAX; 
    26 import static org.rayflood.mikuvat.io.EventBPTime.RESO4FREQ_MIN; 
     3import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1AMP_MAX; 
     4import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1AMP_MIN; 
     5import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1BW_MAX; 
     6import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1BW_MIN; 
     7import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1FREQ_MAX; 
     8import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO1FREQ_MIN; 
     9import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2AMP_MAX; 
     10import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2AMP_MIN; 
     11import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2BW_MAX; 
     12import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2BW_MIN; 
     13import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2FREQ_MAX; 
     14import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO2FREQ_MIN; 
     15import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3AMP_MAX; 
     16import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3AMP_MIN; 
     17import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3BW_MAX; 
     18import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3BW_MIN; 
     19import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3FREQ_MAX; 
     20import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO3FREQ_MIN; 
     21import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4AMP_MAX; 
     22import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4AMP_MIN; 
     23import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4BW_MAX; 
     24import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4BW_MIN; 
     25import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4FREQ_MAX; 
     26import static org.rayflood.mikuvat.io.vsq.EventBPTime.RESO4FREQ_MIN; 
    2727 
    2828import java.awt.BorderLayout; 
     
    3232import javax.swing.SpinnerNumberModel; 
    3333 
    34 import org.rayflood.mikuvat.io.EventBPTime; 
     34import org.rayflood.mikuvat.io.vsq.EventBPTime; 
    3535 
    3636public class ResoBPLinePanel extends PropertyPanel{ 
  • trunk/src/org/rayflood/mikuvat/gui/TrackDialog.java

    r2 r4  
    66import java.awt.Window; 
    77 
    8 import org.rayflood.mikuvat.io.CommonSection; 
    9 import org.rayflood.mikuvat.io.MixerSetting; 
     8import org.rayflood.mikuvat.io.vsq.CommonSection; 
     9import org.rayflood.mikuvat.io.vsq.MixerSetting; 
    1010 
    1111public class TrackDialog extends PropertyDialog{ 
  • trunk/src/org/rayflood/mikuvat/gui/TrackPanel.java

    r2 r4  
    11package org.rayflood.mikuvat.gui; 
    22 
    3 import static org.rayflood.mikuvat.io.MixerSection.FEDER_MAX; 
    4 import static org.rayflood.mikuvat.io.MixerSection.FEDER_MIN; 
    5 import static org.rayflood.mikuvat.io.MixerSection.PANPOT_MAX; 
    6 import static org.rayflood.mikuvat.io.MixerSection.PANPOT_MIN; 
     3import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MAX; 
     4import static org.rayflood.mikuvat.io.vsq.MixerSection.FEDER_MIN; 
     5import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MAX; 
     6import static org.rayflood.mikuvat.io.vsq.MixerSection.PANPOT_MIN; 
    77 
    88import java.awt.BorderLayout; 
     
    1616import javax.swing.SpinnerNumberModel; 
    1717 
    18 import org.rayflood.mikuvat.io.CommonSection; 
    19 import org.rayflood.mikuvat.io.MixerSetting; 
     18import org.rayflood.mikuvat.io.vsq.CommonSection; 
     19import org.rayflood.mikuvat.io.vsq.MixerSetting; 
    2020 
    2121public class TrackPanel extends PropertyPanel{ 
  • trunk/src/org/rayflood/mikuvat/gui/VSQFileFilter.java

    r2 r4  
    88        public boolean accept(File f){ 
    99                if(f != null){ 
    10                         String name = f.getName(); 
    11                         int per = name.lastIndexOf("."); 
    12                         if(per > 0){ 
    13                                 String suffix = name.substring(per); 
    14                                 if(".vsq".equalsIgnoreCase(suffix)){ 
    15                                         return true; 
    16                                 } 
    17                                 if(".mid".equalsIgnoreCase(suffix)){ 
    18                                         return true; 
     10                        if(f.isDirectory()){ 
     11                                return true; 
     12                        } 
     13                        else if(f.isFile()){ 
     14                                String name = f.getName(); 
     15                                int per = name.lastIndexOf("."); 
     16                                if(per > 0){ 
     17                                        String suffix = name.substring(per); 
     18                                        if(".vsq".equalsIgnoreCase(suffix)){ 
     19                                                return true; 
     20                                        } 
     21                                        if(".mid".equalsIgnoreCase(suffix)){ 
     22                                                return true; 
     23                                        } 
    1924                                } 
    2025                        } 
  • trunk/src/org/rayflood/mikuvat/gui/VibratoBPTable.java

    r2 r4  
    11package org.rayflood.mikuvat.gui; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.getVibratoBPList; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.getVibratoBPMap; 
    5 import static org.rayflood.mikuvat.io.VibratoBP.Y_MAX; 
    6 import static org.rayflood.mikuvat.io.VibratoBP.Y_MIN; 
     3import static org.rayflood.mikuvat.Utilities.getVibratoBPList; 
     4import static org.rayflood.mikuvat.Utilities.getVibratoBPMap; 
     5import static org.rayflood.mikuvat.io.vsq.VibratoBP.Y_MAX; 
     6import static org.rayflood.mikuvat.io.vsq.VibratoBP.Y_MIN; 
    77 
    88import java.awt.BorderLayout; 
     
    3030import javax.swing.table.DefaultTableModel; 
    3131 
    32 import org.rayflood.mikuvat.io.VibratoBP; 
     32import org.rayflood.mikuvat.io.vsq.VibratoBP; 
    3333 
    3434public class VibratoBPTable extends JPanel{ 
  • trunk/src/org/rayflood/mikuvat/gui/VibratoDialog.java

    r2 r4  
    66import java.util.List; 
    77 
    8 import org.rayflood.mikuvat.io.VibratoBP; 
    9 import org.rayflood.mikuvat.io.VibratoHandle; 
     8import org.rayflood.mikuvat.io.vsq.VibratoBP; 
     9import org.rayflood.mikuvat.io.vsq.VibratoHandle; 
    1010 
    1111public class VibratoDialog extends PropertyDialog{ 
  • trunk/src/org/rayflood/mikuvat/gui/VibratoHandleButton.java

    r2 r4  
    88import javax.swing.JOptionPane; 
    99 
    10 import org.rayflood.mikuvat.io.VibratoHandle; 
     10import org.rayflood.mikuvat.io.vsq.VibratoHandle; 
    1111 
    1212public class VibratoHandleButton extends JButton implements VibratoHandleInput{ 
  • trunk/src/org/rayflood/mikuvat/gui/VibratoHandleInput.java

    r2 r4  
    33import java.awt.Component; 
    44 
    5 import org.rayflood.mikuvat.io.VibratoHandle; 
     5import org.rayflood.mikuvat.io.vsq.VibratoHandle; 
    66 
    77public interface VibratoHandleInput{ 
  • trunk/src/org/rayflood/mikuvat/gui/VibratoHandleLabel.java

    r2 r4  
    55import javax.swing.JLabel; 
    66 
    7 import org.rayflood.mikuvat.io.VibratoHandle; 
     7import org.rayflood.mikuvat.io.vsq.VibratoHandle; 
    88 
    99public class VibratoHandleLabel extends JLabel implements VibratoHandleInput{ 
  • trunk/src/org/rayflood/mikuvat/gui/VibratoPanel.java

    r2 r4  
    11package org.rayflood.mikuvat.gui; 
    22 
    3 import static org.rayflood.mikuvat.io.VibratoHandle.CAPTION_PARAMLIST; 
    4 import static org.rayflood.mikuvat.io.VibratoHandle.DEPTH_MAX; 
    5 import static org.rayflood.mikuvat.io.VibratoHandle.DEPTH_MIN; 
    6 import static org.rayflood.mikuvat.io.VibratoHandle.RATE_MAX; 
    7 import static org.rayflood.mikuvat.io.VibratoHandle.RATE_MIN; 
     3import static org.rayflood.mikuvat.io.vsq.VibratoHandle.CAPTION_PARAMLIST; 
     4import static org.rayflood.mikuvat.io.vsq.VibratoHandle.DEPTH_MAX; 
     5import static org.rayflood.mikuvat.io.vsq.VibratoHandle.DEPTH_MIN; 
     6import static org.rayflood.mikuvat.io.vsq.VibratoHandle.RATE_MAX; 
     7import static org.rayflood.mikuvat.io.vsq.VibratoHandle.RATE_MIN; 
    88 
    99import java.awt.BorderLayout; 
     
    1818import javax.swing.event.ChangeListener; 
    1919 
    20 import org.rayflood.mikuvat.io.VibratoBP; 
    21 import org.rayflood.mikuvat.io.VibratoHandle; 
     20import org.rayflood.mikuvat.io.vsq.VibratoBP; 
     21import org.rayflood.mikuvat.io.vsq.VibratoHandle; 
    2222 
    2323public class VibratoPanel extends PropertyPanel{ 
  • trunk/src/org/rayflood/mikuvat/io/BaseObject.java

    r2 r4  
    99import java.io.File; 
    1010import java.io.FileInputStream; 
     11import java.io.FileNotFoundException; 
    1112import java.io.FileOutputStream; 
     13import java.io.IOException; 
    1214import java.io.InputStream; 
    1315import java.io.ObjectInputStream; 
     
    2123import java.util.zip.ZipOutputStream; 
    2224 
    23 public abstract class ImmutableObject implements Serializable, Cloneable, Comparable<ImmutableObject>{ 
    24         private static final long serialVersionUID = 768886758398033337L; 
    25  
    26         public abstract ImmutableObject setDefault(); 
    27  
    28         public abstract ImmutableObject delete(); 
    29  
     25/** 
     26 * BaseObjectはデータを格納するオブジェクトのベースとなるクラスです。<br> 
     27 * 標準でSerializable, Cloneableを実装しており、派生クラスで定義しなくても使用可能です。<br> 
     28 * シリアライズによるインスタンスのファイル化もサポートしています。<br> 
     29 * <br> 
     30 * Serializableを実装するため、オブジェクト内のフィールドは全て直列化可能なオブジェクトを使ってください。<br> 
     31 * Comparableは派生クラスでオーバーライドしてください。<br> 
     32 * @see java.io.Serializable 
     33 * @see java.lang.Cloneable 
     34 * @see java.lang.Comparable 
     35 */ 
     36public abstract class BaseObject implements Serializable, Cloneable, Comparable<BaseObject>{ 
     37 
     38        private static final long serialVersionUID = 5225438162616635387L; 
     39 
     40        /** 
     41         * このクラスのデフォルト値をセットします。<br> 
     42         * 通常は、デフォルト値がセットされたオブジェクトを返すgetDefault()メソッドも用意します。<br> 
     43         * <pre> 
     44         * public SomeObject extends BaseObject{ 
     45         *     public static SomeObject getDefault(){ 
     46         *         SomeObject someObject = new SomeObject(); 
     47         *         someObject.setDefault(); 
     48         *         return someObject; 
     49         *     } 
     50         * } 
     51         * </pre> 
     52         * 派生クラスでそれぞれの内容にあったsetDefault()メソッドをオーバーライドしてください。<br> 
     53         * @return このクラスのデフォルト値がセットされたオブジェクト 
     54         */ 
     55        public abstract BaseObject setDefault(); 
     56 
     57        /** 
     58         * このオブジェクトの内容を完全に削除します。<br> 
     59         * <br> 
     60         * 派生クラスでそれぞれの内容にあったdelete()メソッドをオーバーライドしてください。<br> 
     61         * また、このメソッド実行後はisDeleted()メソッドがtrueになるようにしてください。<br> 
     62         * @see BaseObject#isDeleted() 
     63         * @return 内容が完全に削除されたこのオブジェクト 
     64         */ 
     65        public abstract BaseObject delete(); 
     66 
     67        /** 
     68         * オブジェクトの内容が論理的に正しいか調べます。<br> 
     69         * 通常は、オブジェクトをファイルに出力しても問題ないかのチェックに使います。<br> 
     70         * <br> 
     71         * 派生クラスでそれぞれの内容にあったvalidate()メソッドをオーバーライドしてください。<br> 
     72         * @return 内容が論理的に正しい場合はtrue、正しくない場合はfalse 
     73         */ 
     74        public abstract boolean validate() throws InvalidBaseObjectException; 
     75 
     76        /** 
     77         * オブジェクトの内容が完全に削除されているか調べます。<br> 
     78         * 通常は、オブジェクトをファイルに出力する際に、省いても良いかのチェックに使います。<br> 
     79         * <br> 
     80         * 派生クラスでそれぞれの内容にあったisDeleted()メソッドをオーバーライドしてください。<br> 
     81         * @see BaseObject#delete() 
     82         * @return 削除されている場合はtrue、されていない場合はfalse 
     83         */ 
    3084        public abstract boolean isDeleted(); 
    3185 
    32         public ImmutableObject cover(Object obj){ 
     86        /** 
     87         * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 
     88         * ただし、指定されたオブジェクトのうち、値が何も設定されていないフィールドは上書きしません。<br> 
     89         * <br> 
     90         * このメソッドは通常、over()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 
     91         * @param obj 上書きするオブジェクト 
     92         * @return 上書きされたこのオブジェクト 
     93         * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 
     94         */ 
     95        public BaseObject cover(BaseObject obj){ 
    3396                return over(obj, true, false); 
    3497        } 
    3598 
    36         public ImmutableObject heap(Object obj){ 
     99        /** 
     100         * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 
     101         * 上書きする対象は、フィールドに<strong>何らかの値が設定されているもの</strong>のみです。値が設定されていないフィールドには上書きしません。<br> 
     102         * また、指定されたオブジェクトのうち、値が何も設定されていないフィールドは上書きしません。<br> 
     103         * <br> 
     104         * このメソッドは通常、over()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 
     105         * @param obj 上書きするオブジェクト 
     106         * @return 上書きされたこのオブジェクト 
     107         * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 
     108         */ 
     109        public BaseObject heap(BaseObject obj){ 
    37110                return over(obj, false, true); 
    38111        } 
    39112 
    40         public ImmutableObject lay(Object obj){ 
     113        /** 
     114         * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 
     115         * 上書きする対象は、フィールドに<strong>何も値が設定されていないもの</strong>のみです。値が設定されているフィールドには上書きしません。<br> 
     116         * また、指定されたオブジェクトのうち、値が何も設定されていないフィールドは上書きしません。<br> 
     117         * <br> 
     118         * このメソッドは通常、over()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 
     119         * @param obj 上書きするオブジェクト 
     120         * @return 上書きされたこのオブジェクト 
     121         * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 
     122         */ 
     123        public BaseObject lay(BaseObject obj){ 
    41124                return over(obj, false, false); 
    42125        } 
    43126 
    44         public abstract ImmutableObject over(Object obj, boolean fill, boolean has); 
    45  
     127        /** 
     128         * 指定されたオブジェクトでこのオブジェクトを上書きします。<br> 
     129         * ただし、指定されたオブジェクトのフィールドがnullの場合は上書きしません。<br> 
     130         * 派生クラスでそれぞれの内容にあったover()メソッドをオーバーライドしてください。<br> 
     131         * <pre> 
     132         * public SomeObject extends BaseObject{ 
     133         *     String aString; 
     134         *     public SomeObject over(Object obj, boolean fill, boolean has){ 
     135         *         SomeObject someObject = ((SomeObject)obj).clone(); 
     136         *         if(someObject.hasAString() && (fill || has == hasAString())){ 
     137         *             setAString(someObject.getAString()); 
     138         *         } 
     139         *         return this; 
     140         *     } 
     141         * } 
     142         * </pre> 
     143         * @see BaseObject#cover(BaseObject) 
     144         * @see BaseObject#heap(BaseObject) 
     145         * @see BaseObject#lay(BaseObject) 
     146         * @param obj 上書きするオブジェクト 
     147         * @param fill trueは、このオブジェクトのフィールドの状態に関係なく上書きする。 
     148         * @param has trueは、このオブジェクトのフィールドがnullではない場合に上書きする。falseはnullの場合に上書きする。 
     149         * @return 上書きされたこのオブジェクト 
     150         * @throws ClassCastException 指定されたオブジェクトの型が、このオブジェクトと一致しない場合 
     151         */ 
     152        public abstract BaseObject over(BaseObject obj, boolean fill, boolean has); 
     153 
     154        /** 
     155         * オブジェクトの文字列表現を返します。<br> 
     156         * 通常、toString()メソッドはこのオブジェクトを「テキストで表現する」文字列を返します。<br> 
     157         * <br> 
     158         * 派生クラスでそれぞれの内容にあったtoString()メソッドをオーバーライドしてください。<br> 
     159         * @see java.lang.Object#toString() 
     160         */ 
     161        @Override 
    46162        public abstract String toString(); 
    47163 
    48         public abstract boolean isReadied(); 
    49  
     164        /** 
     165         * このオブジェクトと「等価」になるオブジェクトがあるかどうかを示します。<br> 
     166         * <br> 
     167         * このメソッドはお互いのオブジェクトをシリアライズしてバイト配列を取得し、そのバイト配列同士を比較します。<br> 
     168         * そのため、オブジェクト同士の、型を含めた完全一致チェックを行います。<br> 
     169         * @param obj 比較対象の参照オブジェクト 
     170         * @return 引数に指定されたオブジェクトとこのオブジェクトが等しい場合は true、そうでない場合は false 
     171         * @see java.lang.Object#equals(java.lang.Object) 
     172         * @see java.io.Serializable 
     173         */ 
     174        @Override 
    50175        public boolean equals(Object obj){ 
    51                 if(obj == null || !(obj instanceof ImmutableObject) ||  !getClass().getName().equals(obj.getClass().getName())){ 
     176                if(obj == null || !getClass().getName().equals(obj.getClass().getName())){ 
    52177                        return false; 
    53178                } 
    54179                try{ 
    55                         return Arrays.equals(encodeBytes(), ((ImmutableObject)obj).encodeBytes()); 
     180                        return Arrays.equals(encodeBytes(), ((BaseObject)obj).encodeBytes()); 
    56181                } 
    57182                catch(Exception e){ 
     
    60185        } 
    61186 
    62         public abstract int compareTo(ImmutableObject obj); 
    63  
     187        /** 
     188         * このオブジェクトのコピーを作成して返します。<br> 
     189         * <br> 
     190         * 直列化してバイト配列を取得し、そのバイト配列から新たなインスタンスを作成するため、クラスに関係なく、常に「ディープコピー」が作成されます。<br> 
     191         * このメソッドの戻り値はObjectクラスになっており、アクセス権限もprotectedになっているため、使う場合は派生クラスでオーバーライドしてください。<br> 
     192         * <pre> 
     193         * public SomeObject extends BaseObject{ 
     194         *     public SomeObject clone(){ 
     195         *         return (SomeObject)super.clone(); 
     196         *     } 
     197         * } 
     198         * </pre> 
     199         * @see BaseObject#encodeBytes() 
     200         * @see BaseObject#decodeBytes(byte[]) 
     201         * @return このインスタンスの複製 
     202         * @see java.lang.Object#clone() 
     203         * @see java.io.Serializable 
     204         */ 
     205        @Override 
     206        protected BaseObject clone(){ 
     207                try{ 
     208                        return decodeBytes(encodeBytes()); 
     209                } 
     210                catch(Exception e){ 
     211                        throw new RuntimeException(e); 
     212                } 
     213        } 
     214 
     215        /** 
     216         * このオブジェクトと指定されたオブジェクトの順序を比較します。<br> 
     217         * このオブジェクトが指定されたオブジェクトより小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数を返します。<br> 
     218         * <br> 
     219         * 派生クラスでそれぞれの内容にあったcompareTo()メソッドをオーバーライドしてください。<br> 
     220         * @see BaseObject#compare(Comparable, Comparable) 
     221         * @param obj 比較対象の Object 
     222         * @return このオブジェクトが指定されたオブジェクトより小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数 
     223         * @see java.lang.Comparable#compareTo(java.lang.Object) 
     224         */ 
     225        public abstract int compareTo(BaseObject obj); 
     226 
     227        /** 
     228         * 2つのオブジェクトの順序を比較します。<br> 
     229         * 一方のオブジェクトが他方のオブジェクトより小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数を返します。<br> 
     230         * <br> 
     231         * オブジェクトがnullだった場合は、nullの方が小さいと判定します。両方nullの場合は等しいと判定します。<br> 
     232         * 引数のオブジェクトはパラメータ化されていないため、オブジェクトの型が合わない場合はClassCastExceptionが発生します。<br> 
     233         * このメソッドは通常、compareTo()メソッドで使われるので、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 
     234         * @see BaseObject#compareTo(BaseObject) 
     235         * @param o1 一方のオブジェクト 
     236         * @param o2 他方のオブジェクト 
     237         * @return o1がo2より小さい場合は負の整数、等しい場合はゼロ、大きい場合は正の整数 
     238         * @throws ClassCastException 指定されたオブジェクトの型が原因で、この Object と比較できない場合 
     239         */ 
     240        @SuppressWarnings("unchecked") 
    64241        protected static int compare(Comparable o1, Comparable o2){ 
    65242                if(o1 == null && o2 == null){ 
     
    75252        } 
    76253 
    77         public static Comparator<ImmutableObject> getComparator(){ 
    78                 return new Comparator<ImmutableObject>(){ 
    79                         public int compare(ImmutableObject o1, ImmutableObject o2){ 
     254        /** 
     255         * オブジェクトのコレクションで「全体順序付け」を行う比較関数です。<br> 
     256         * コンパレータ (Comparator) をソートメソッド (Collections.sort など) に渡すと、ソート順を正確に制御できます。<br> 
     257         * <br> 
     258         * このコンパレータはオブジェクトを「昇順」にソートします。比較はcompareTo()メソッドで行います。<br> 
     259         * compare()メソッドと同じく、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 
     260         * @see BaseObject#getComparatorR() 
     261         * @return 昇順コンパレータ 
     262         * @see java.util.Comparator 
     263         */ 
     264        public static Comparator<BaseObject> getComparator(){ 
     265                return new Comparator<BaseObject>(){ 
     266                        public int compare(BaseObject o1, BaseObject o2){ 
    80267                                return o1.compareTo(o2); 
    81268                        } 
     
    83270        } 
    84271 
    85         public static Comparator<ImmutableObject> getComparatorR(){ 
    86                 return new Comparator<ImmutableObject>(){ 
    87                         public int compare(ImmutableObject o1, ImmutableObject o2){ 
     272        /** 
     273         * オブジェクトのコレクションで「全体順序付け」を行う比較関数です。<br> 
     274         * コンパレータ (Comparator) をソートメソッド (Collections.sort など) に渡すと、ソート順を正確に制御できます。<br> 
     275         * <br> 
     276         * このコンパレータはオブジェクトを「降順」にソートします。比較はcompareTo()メソッドの戻り値 * -1 です。<br> 
     277         * compare()メソッドと同じく、特別な理由がない限り派生クラスでオーバーライドする必要はありません。<br> 
     278         * @see BaseObject#getComparator() 
     279         * @return 降順コンパレータ 
     280         * @see java.util.Comparator 
     281         */ 
     282        public static Comparator<BaseObject> getComparatorR(){ 
     283                return new Comparator<BaseObject>(){ 
     284                        public int compare(BaseObject o1, BaseObject o2){ 
    88285                                return o1.compareTo(o2) * -1; 
    89286                        } 
     
    91288        } 
    92289 
    93         protected Object clone(){ 
    94                 try{ 
    95                         return decodeBytes(encodeBytes()); 
    96                 } 
    97                 catch(Exception e){ 
    98                         throw new RuntimeException(e); 
    99                 } 
    100         } 
    101  
    102         private static Object decodeBytes(byte[] buf) throws Exception{ 
    103                 return unserialize(new ByteArrayInputStream(buf)); 
    104         } 
    105  
    106         private static Object unserialize(InputStream in) throws Exception{ 
    107                 ObjectInputStream ois = new ObjectInputStream(in); 
    108                 return ois.readObject(); 
    109         } 
    110  
    111         private byte[] encodeBytes() throws Exception{ 
     290        /** 
     291         * このオブジェクトを直列化し、指定された出力ストリームに書き込みます。<br> 
     292         * 出力ストリームは自動的に閉じられるため、再利用できません。<br> 
     293         * @see BaseObject#unserialize(InputStream) 
     294         * @param out 出力ストリーム 
     295         * @throws IOException 
     296         */ 
     297        private void serialize(OutputStream out) throws IOException{ 
     298                ObjectOutputStream oos = null; 
     299                try{ 
     300                        oos = new ObjectOutputStream(out); 
     301                        oos.writeObject(this); 
     302                } 
     303                finally{ 
     304                        if(oos != null){ 
     305                                oos.close(); 
     306                        } 
     307                        else{ 
     308                                out.close(); 
     309                        } 
     310                } 
     311        } 
     312 
     313        /** 
     314         * 指定された入力ストリームからオブジェクトを読み込みます。<br> 
     315         * 入力ストリームは自動的に閉じられるため、再利用できません。<br> 
     316         * @see BaseObject#serialize(OutputStream) 
     317         * @param in 入力ストリーム 
     318         * @return 読み込まれたオブジェクト 
     319         * @throws IOException 
     320         * @throws ClassNotFoundException 
     321         */ 
     322        private static BaseObject unserialize(InputStream in) throws IOException, ClassNotFoundException{ 
     323                ObjectInputStream ois = null; 
     324                try{ 
     325                        ois = new ObjectInputStream(in); 
     326                        return (BaseObject)ois.readObject(); 
     327                } 
     328                finally{ 
     329                        if(ois != null){ 
     330                                ois.close(); 
     331                        } 
     332                        else{ 
     333                                in.close(); 
     334                        } 
     335                } 
     336        } 
     337 
     338        /** 
     339         * このオブジェクトを直列化し、バイト配列に変換します。<br> 
     340         * @see BaseObject#decodeBytes(byte[]) 
     341         * @return オブジェクトから直列化されたバイト配列 
     342         * @throws IOException 
     343         */ 
     344        protected byte[] encodeBytes() throws IOException{ 
    112345                ByteArrayOutputStream byteOut = new ByteArrayOutputStream(); 
    113346                serialize(byteOut); 
     
    115348        } 
    116349 
    117         private void serialize(OutputStream out) throws Exception{ 
    118                 ObjectOutputStream oos = new ObjectOutputStream(out); 
    119                 oos.writeObject(this); 
    120                 oos.close(); 
    121         } 
    122  
    123         protected static Object load(String file) throws Exception{ 
     350        /** 
     351         * オブジェクトを直列化したバイト配列を、元のオブジェクトに変換します。<br> 
     352         * @see BaseObject#encodeBytes() 
     353         * @param buf オブジェクトから変換されたバイト配列 
     354         * @return 読み込まれたオブジェクト 
     355         * @throws IOException 
     356         * @throws ClassNotFoundException 
     357         */ 
     358        protected static BaseObject decodeBytes(byte[] buf) throws IOException, ClassNotFoundException{ 
     359                return unserialize(new ByteArrayInputStream(buf)); 
     360        } 
     361 
     362        /** 
     363         * このオブジェクトを直列化し、指定された出力ファイルに書き込みます。<br> 
     364         * アクセス権限がprotectedになっているため、使う場合は派生クラスでオーバーライドしてください。<br> 
     365         * store(String)メソッド、zip(File)メソッド、zip(String)メソッドについても同様です。<br> 
     366         * <pre> 
     367         * public SomeObject extends BaseObject{ 
     368         *     public void store(File file) throws FileNotFoundException, IOException{ 
     369         *         super.store(File file); 
     370         *     } 
     371         * } 
     372         * </pre> 
     373         * @see BaseObject#load(File) 
     374         * @param file 出力ファイル 
     375         * @throws FileNotFoundException 
     376         * @throws IOException 
     377         */ 
     378        protected void store(File file) throws FileNotFoundException, IOException{ 
     379                serialize(new BufferedOutputStream(new FileOutputStream(file))); 
     380        } 
     381 
     382        /** 
     383         * ファイル名をStringとして受ける以外はstore(File)と同じです。<br> 
     384         * @see BaseObject#store(File) 
     385         * @param file 出力ファイル 
     386         * @throws FileNotFoundException 
     387         * @throws IOException 
     388         */ 
     389        protected void store(String file) throws FileNotFoundException, IOException{ 
     390                store(new File(file)); 
     391        } 
     392 
     393        /** 
     394         * 入力ファイルからオブジェクトを読み込みます。<br> 
     395         * このメソッドの戻り値はObjectクラスになっており、アクセス権限もprotectedになっているため、使う場合は派生クラスでオーバーライドしてください。<br> 
     396         * load(String)メソッド、unzip(File)メソッド、unzip(String)メソッドについても同様です。<br> 
     397         * <pre> 
     398         * public SomeObject extends BaseObject{ 
     399         *     public static SomeObject load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     400         *         return (SomeObject)BaseObject.load(File file); 
     401         *     } 
     402         * } 
     403         * </pre> 
     404         * @see BaseObject#store(File) 
     405         * @param file 入力ファイル 
     406         * @return 読み込まれたオブジェクト 
     407         * @throws FileNotFoundException 
     408         * @throws IOException 
     409         * @throws ClassNotFoundException 
     410         */ 
     411        protected static BaseObject load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     412                return unserialize(new BufferedInputStream(new FileInputStream(file))); 
     413        } 
     414 
     415        /** 
     416         * ファイル名をStringとして受ける以外はload(File)と同じです。<br> 
     417         * @see BaseObject#load(File) 
     418         * @throws FileNotFoundException 
     419         * @throws IOException 
     420         * @throws ClassNotFoundException 
     421         */ 
     422        protected static BaseObject load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
    124423                return load(new File(file)); 
    125424        } 
    126425 
    127         protected static Object load(File file) throws Exception{ 
    128                 return unserialize(new BufferedInputStream(new FileInputStream(file))); 
    129         } 
    130  
    131         protected void store(String file) throws Exception{ 
    132                 store(new File(file)); 
    133         } 
    134  
    135         protected void store(File file) throws Exception{ 
    136                 serialize(new BufferedOutputStream(new FileOutputStream(file))); 
    137         } 
    138  
    139         protected static Object unzip(String file) throws Exception{ 
    140                 return unzip(new File(file)); 
    141         } 
    142  
    143         protected static Object unzip(File file) throws Exception{ 
    144                 ZipInputStream zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(file))); 
    145                 zis.getNextEntry(); 
    146                 return unserialize(zis); 
    147         } 
    148  
    149         protected void zip(String file) throws Exception{ 
    150                 zip(new File(file)); 
    151         } 
    152  
    153         protected void zip(File file) throws Exception{ 
    154                 ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file))); 
    155                 zos.putNextEntry(new ZipEntry(getClass().getName())); 
    156                 serialize(zos); 
    157         } 
    158  
    159         protected static Object decodeXML(String xml) throws Exception{ 
     426        /** 
     427         * このオブジェクトを直列化し、指定されたzipファイルに書き込みます。<br> 
     428         * zipエントリは1つだけで、クラス名がそのままエントリ名になります。<br> 
     429         * 派生クラスでの実装方法はstore(File)を参照してください。<br> 
     430         * @see BaseObject#store(File) 
     431         * @see BaseObject#unzip(File) 
     432         * @param zip zipファイル 
     433         * @throws IOException 
     434         */ 
     435        protected void zip(File zip) throws IOException{ 
     436                ZipOutputStream zos = null; 
     437                try{ 
     438                        zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zip))); 
     439                        zos.putNextEntry(new ZipEntry(getClass().getName())); 
     440                        serialize(zos); 
     441                } 
     442                finally{ 
     443                        if(zos != null){ 
     444                                zos.close(); 
     445                        } 
     446                } 
     447        } 
     448 
     449        /** 
     450         * ファイル名をStringとして受ける以外はzip(File)と同じです。<br> 
     451         * @see BaseObject#zip(File) 
     452         * @param zip zipファイル 
     453         * @throws IOException 
     454         */ 
     455        protected void zip(String zip) throws IOException{ 
     456                zip(new File(zip)); 
     457        } 
     458 
     459        /** 
     460         * zipファイルからオブジェクトを読み込みます。<br> 
     461         * 最初のエントリのみ読み込み、オブジェクトを返した後、zipファイルを閉じます。<br> 
     462         * エントリ名とクラス名が一致しているかはチェックしません。<br> 
     463         * 派生クラスでの実装方法はload(File)を参照してください。<br> 
     464         * @see BaseObject#load(File) 
     465         * @see BaseObject#zip(File) 
     466         * @param zip zipファイル 
     467         * @return 読み込まれたオブジェクト 
     468         * @throws IOException 
     469         * @throws ClassNotFoundException 
     470         */ 
     471        protected static BaseObject unzip(File zip) throws IOException, ClassNotFoundException{ 
     472                ZipInputStream zis = null; 
     473                try{ 
     474                        zis = new ZipInputStream(new BufferedInputStream(new FileInputStream(zip))); 
     475                        zis.getNextEntry(); 
     476                        return unserialize(zis); 
     477                } 
     478                finally{ 
     479                        if(zis != null){ 
     480                                zis.close(); 
     481                        } 
     482                } 
     483        } 
     484 
     485        /** 
     486         * ファイル名をStringとして受ける以外はunzip(File)と同じです。<br> 
     487         * @see BaseObject#unzip(File) 
     488         * @param zip zipファイル 
     489         * @return 読み込まれたオブジェクト 
     490         * @throws IOException 
     491         * @throws ClassNotFoundException 
     492         */ 
     493        protected static BaseObject unzip(String zip) throws IOException, ClassNotFoundException{ 
     494                return unzip(new File(zip)); 
     495        } 
     496 
     497        /** 
     498         * このオブジェクトのJavaBeanテキスト表現を生成し、指定された出力ストリームに書き込みます。<br> 
     499         * 出力ストリームは自動的に閉じられるため、再利用できません。<br> 
     500         * @see BaseObject#decodeXML(InputStream) 
     501         * @param out 出力ストリーム 
     502         * @throws IOException 
     503         * @see java.beans.XMLEncoder 
     504         */ 
     505        private void encodeXML(OutputStream out) throws IOException{ 
     506                XMLEncoder e = null; 
     507                try{ 
     508                        e = new XMLEncoder(out); 
     509                        e.writeObject(this); 
     510                } 
     511                finally{ 
     512                        if(e != null){ 
     513                                e.close(); 
     514                        } 
     515                        else{ 
     516                                out.close(); 
     517                        } 
     518                } 
     519        } 
     520 
     521        /** 
     522         * 指定された入力ストリームからJavaBeanテキスト表現を取得し、オブジェクトを読み込みます。<br> 
     523         * 入力ストリームは自動的に閉じられるため、再利用できません。<br> 
     524         * @see BaseObject#encodeXML(OutputStream) 
     525         * @param in 入力ストリーム 
     526         * @return 読み込まれたオブジェクト 
     527         * @throws IOException 
     528         * @see java.beans.XMLDecoder 
     529         */ 
     530        private static BaseObject decodeXML(InputStream in) throws IOException{ 
     531                XMLDecoder d = null; 
     532                try{ 
     533                        d = new XMLDecoder(in); 
     534                        BaseObject result = (BaseObject)d.readObject(); 
     535                        return result; 
     536                } 
     537                finally{ 
     538                        if(d != null){ 
     539                                d.close(); 
     540                        } 
     541                        else{ 
     542                                in.close(); 
     543                        } 
     544                } 
     545        } 
     546 
     547        /** 
     548         * XMLEncoderを使って、オブジェクトをxmlファイルに書き込みます。<br> 
     549         * <br> 
     550         * ※注:このメソッドはオブジェクトがJavaBeanの仕様に準じる必要があるため、必ずしもstore(File)メソッド、zip(File)メソッドの代替にはなり得ません。<br> 
     551         * 例えばBigDecimalはXMLEncoderで保存することが出来ません。<br> 
     552         * 詳細については、『The Swing Connection』の記事「<a target="_blank" href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>」を参照してください。<br> 
     553         * @see BaseObject#decodeXML(File) 
     554         * @param xml xmlファイル 
     555         * @throws FileNotFoundException 
     556         * @throws IOException 
     557         * @see java.beans.XMLEncoder 
     558         */ 
     559        protected void encodeXML(File xml) throws FileNotFoundException, IOException{ 
     560                encodeXML(new BufferedOutputStream(new FileOutputStream(xml))); 
     561        } 
     562 
     563        /** 
     564         * ファイル名をStringとして受ける以外はencodeXML(File)と同じです。<br> 
     565         * @see BaseObject#encodeXML(File) 
     566         * @param xml xmlファイル 
     567         * @throws FileNotFoundException 
     568         * @throws IOException 
     569         */ 
     570        protected void encodeXML(String xml) throws FileNotFoundException, IOException{ 
     571                encodeXML(new File(xml)); 
     572        } 
     573 
     574        /** 
     575         * XMLDecoderを使って、xmlファイルからオブジェクトを読み込みます。<br> 
     576         * <br> 
     577         * ※注:このメソッドはオブジェクトがJavaBeanの仕様に準じる必要があるため、必ずしもload(File)メソッド、unzip(File)メソッドの代替にはなり得ません。<br> 
     578         * 例えばBigDecimalはXMLEncoderで保存することが出来ません。<br> 
     579         * 詳細については、『The Swing Connection』の記事「<a target="_blank" href="http://java.sun.com/products/jfc/tsc/articles/persistence4">Using XMLEncoder</a>」を参照してください。<br> 
     580         * @see BaseObject#encodeXML(File) 
     581         * @param xml xmlファイル 
     582         * @return 読み込まれたオブジェクト 
     583         * @throws FileNotFoundException 
     584         * @throws IOException 
     585         * @see java.beans.XMLDecoder 
     586         */ 
     587        protected static BaseObject decodeXML(File xml) throws FileNotFoundException, IOException{ 
     588                return decodeXML(new BufferedInputStream(new FileInputStream(xml))); 
     589        } 
     590 
     591        /** 
     592         * ファイル名をStringとして受ける以外はdecodeXML(File)と同じです。<br> 
     593         * @see BaseObject#decodeXML(File) 
     594         * @param xml xmlファイル 
     595         * @return 読み込まれたオブジェクト 
     596         * @throws FileNotFoundException 
     597         * @throws IOException 
     598         */ 
     599        protected static BaseObject decodeXML(String xml) throws FileNotFoundException, IOException{ 
    160600                return decodeXML(new File(xml)); 
    161601        } 
    162  
    163         protected static Object decodeXML(File xml) throws Exception{ 
    164                 XMLDecoder d = new XMLDecoder(new BufferedInputStream(new FileInputStream(xml))); 
    165                 Object result = d.readObject(); 
    166                 d.close(); 
    167                 return result; 
    168         } 
    169  
    170         protected void encodeXML(String xml) throws Exception{ 
    171                 encodeXML(new File(xml)); 
    172         } 
    173  
    174         protected void encodeXML(File xml) throws Exception{ 
    175                 XMLEncoder e = new XMLEncoder(new BufferedOutputStream(new FileOutputStream(xml))); 
    176                 e.writeObject(this); 
    177                 e.close(); 
    178         } 
    179602} 
  • trunk/src/org/rayflood/mikuvat/io/midi/MidiData.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.midi; 
    22 
    33import java.io.File; 
     4import java.io.FileNotFoundException; 
     5import java.io.IOException; 
    46 
     7import javax.sound.midi.InvalidMidiDataException; 
    58import javax.sound.midi.MetaMessage; 
    69import javax.sound.midi.MidiMessage; 
     
    811import javax.sound.midi.SysexMessage; 
    912 
    10 public abstract class MidiData extends ImmutableObject{ 
     13import org.rayflood.mikuvat.io.BaseObject; 
     14 
     15public abstract class MidiData extends BaseObject{ 
    1116        private static final long serialVersionUID = 2907770619042609302L; 
    1217 
    13         public int compareTo(ImmutableObject obj){ 
     18        public int compareTo(BaseObject obj){ 
    1419                MidiData midiData = (MidiData)obj; 
    1520                return compare(getClass().getName(), midiData.getClass().getName()); 
     
    3035        } 
    3136 
    32         public abstract MidiMessage getMidiEvent() throws Exception; 
     37        public abstract MidiMessage getMidiEvent() throws InvalidMidiDataException; 
    3338 
    34         public abstract void setMidiEvent(MidiMessage mm); 
     39        protected abstract void setMidiEvent(MidiMessage mm); 
    3540 
    3641        public MidiData clone(){ 
     
    3843        } 
    3944 
    40         public static MidiData load(String file) throws Exception{ 
    41                 return (MidiData)ImmutableObject.load(file); 
     45        public static MidiData load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     46                return (MidiData)BaseObject.load(file); 
    4247        } 
    4348 
    44         public static MidiData load(File file) throws Exception{ 
    45                 return (MidiData)ImmutableObject.load(file); 
     49        public static MidiData load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     50                return (MidiData)BaseObject.load(file); 
    4651        } 
    4752 
    48         public void store(String file) throws Exception{ 
     53        public void store(String file) throws FileNotFoundException, IOException { 
    4954                super.store(file); 
    5055        } 
    5156 
    52         public void store(File file) throws Exception{ 
     57        public void store(File file) throws FileNotFoundException, IOException{ 
    5358                super.store(file); 
    5459        } 
    5560 
    56         public static MidiData unzip(String file) throws Exception{ 
    57                 return (MidiData)ImmutableObject.unzip(file); 
     61        public static MidiData unzip(String file) throws IOException, ClassNotFoundException{ 
     62                return (MidiData)BaseObject.unzip(file); 
    5863        } 
    5964 
    60         public static MidiData unzip(File file) throws Exception{ 
    61                 return (MidiData)ImmutableObject.unzip(file); 
     65        public static MidiData unzip(File file) throws IOException, ClassNotFoundException{ 
     66                return (MidiData)BaseObject.unzip(file); 
    6267        } 
    6368 
    64         public void zip(String file) throws Exception{ 
     69        public void zip(String file) throws IOException{ 
    6570                super.zip(file); 
    6671        } 
    6772 
    68         public void zip(File file) throws Exception{ 
     73        public void zip(File file) throws IOException{ 
    6974                super.zip(file); 
    7075        } 
  • trunk/src/org/rayflood/mikuvat/io/midi/MidiMeta.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.midi; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.getByteArrayString; 
     3import static org.rayflood.mikuvat.Utilities.getByteArrayString; 
    44 
    55import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    68import java.util.ArrayList; 
    79import java.util.List; 
    810 
     11import javax.sound.midi.InvalidMidiDataException; 
    912import javax.sound.midi.MetaMessage; 
    1013import javax.sound.midi.MidiMessage; 
     14 
     15import org.rayflood.mikuvat.io.BaseObject; 
    1116 
    1217public class MidiMeta extends MidiData{ 
     
    1520        private byte[] data; 
    1621 
    17         public MidiMeta(MidiMessage mm){ 
     22        protected MidiMeta(MidiMessage mm){ 
    1823                setMidiEvent(mm); 
     24        } 
     25 
     26        public MidiMeta(MetaMessage meta){ 
     27                setMidiEvent(meta); 
    1928        } 
    2029 
     
    2433        } 
    2534 
    26         public MetaMessage getMidiEvent() throws Exception{ 
     35        public MetaMessage getMidiEvent() throws InvalidMidiDataException{ 
    2736                MetaMessage meta = new MetaMessage(); 
    2837                meta.setMessage(getType(), getData(), getData().length); 
     
    3039        } 
    3140 
    32         public void setMidiEvent(MidiMessage mm){ 
    33                 MetaMessage meta = (MetaMessage)mm; 
     41        protected void setMidiEvent(MidiMessage mm){ 
     42                setMidiEvent((MetaMessage)mm); 
     43        } 
     44 
     45        public void setMidiEvent(MetaMessage meta){ 
    3446                setType(meta.getType()); 
    3547                setData(meta.getData()); 
     
    4153                sl.add("Data=" + getByteArrayString(getData())); 
    4254 
    43                 StringBuffer sb = new StringBuffer(); 
     55                StringBuilder sb = new StringBuilder(); 
    4456                sb.append("MidiMeta={"); 
    4557                if(!sl.isEmpty()){ 
     
    5365        } 
    5466 
    55         public boolean isReadied(){ 
     67        public boolean validate(){ 
    5668                return true; 
    5769        } 
    5870 
    59         public int compareTo(ImmutableObject obj){ 
     71        public int compareTo(BaseObject obj){ 
    6072                MidiMeta midiMeta = (MidiMeta)obj; 
    6173                return compare(getType(), midiMeta.getType()); 
    6274        } 
    6375 
    64         public MidiMeta over(Object obj, boolean fill, boolean has){ 
     76        public MidiMeta over(BaseObject obj, boolean fill, boolean has){ 
    6577                MidiMeta midiMeta = ((MidiMeta)obj).clone(); 
    6678                setType(midiMeta.getType()); 
     
    112124        } 
    113125 
    114         public static MidiMeta load(String file) throws Exception{ 
    115                 return (MidiMeta)ImmutableObject.load(file); 
     126        public static MidiMeta load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     127                return (MidiMeta)BaseObject.load(file); 
    116128        } 
    117129 
    118         public static MidiMeta load(File file) throws Exception{ 
    119                 return (MidiMeta)ImmutableObject.load(file); 
     130        public static MidiMeta load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     131                return (MidiMeta)BaseObject.load(file); 
    120132        } 
    121133 
    122         public void store(String file) throws Exception{ 
     134        public void store(String file) throws FileNotFoundException, IOException{ 
    123135                super.store(file); 
    124136        } 
    125137 
    126         public void store(File file) throws Exception{ 
     138        public void store(File file) throws FileNotFoundException, IOException{ 
    127139                super.store(file); 
    128140        } 
    129141 
    130         public static MidiMeta unzip(String file) throws Exception{ 
    131                 return (MidiMeta)ImmutableObject.unzip(file); 
     142        public static MidiMeta unzip(String file) throws IOException, ClassNotFoundException{ 
     143                return (MidiMeta)BaseObject.unzip(file); 
    132144        } 
    133145 
    134         public static MidiMeta unzip(File file) throws Exception{ 
    135                 return (MidiMeta)ImmutableObject.unzip(file); 
     146        public static MidiMeta unzip(File file) throws IOException, ClassNotFoundException{ 
     147                return (MidiMeta)BaseObject.unzip(file); 
    136148        } 
    137149 
    138         public void zip(String file) throws Exception{ 
     150        public void zip(String file) throws IOException{ 
    139151                super.zip(file); 
    140152        } 
    141153 
    142         public void zip(File file) throws Exception{ 
     154        public void zip(File file) throws IOException{ 
    143155                super.zip(file); 
    144156        } 
  • trunk/src/org/rayflood/mikuvat/io/midi/MidiShort.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.midi; 
    22 
    33import java.io.File; 
     4import java.io.FileNotFoundException; 
     5import java.io.IOException; 
    46import java.util.ArrayList; 
    57import java.util.List; 
    68 
     9import javax.sound.midi.InvalidMidiDataException; 
    710import javax.sound.midi.MidiMessage; 
    811import javax.sound.midi.ShortMessage; 
     12 
     13import org.rayflood.mikuvat.io.BaseObject; 
    914 
    1015public class MidiShort extends MidiData{ 
     
    1520        private int data2; 
    1621 
    17         public MidiShort(MidiMessage mm){ 
     22        protected MidiShort(MidiMessage mm){ 
    1823                setMidiEvent(mm); 
     24        } 
     25 
     26        public MidiShort(ShortMessage shortm){ 
     27                setMidiEvent(shortm); 
    1928        } 
    2029 
     
    2635        } 
    2736 
    28         public ShortMessage getMidiEvent() throws Exception{ 
     37        public ShortMessage getMidiEvent() throws InvalidMidiDataException{ 
    2938                ShortMessage message = new ShortMessage(); 
    3039                message.setMessage(getCommand(), getChannel(), getData1(), getData2()); 
     
    3241        } 
    3342 
    34         public void setMidiEvent(MidiMessage mm){ 
    35                 ShortMessage message = (ShortMessage)mm; 
    36                 setCommand(message.getCommand()); 
    37                 setChannel(message.getChannel()); 
    38                 setData1(message.getData1()); 
    39                 setData2(message.getData2()); 
     43        protected void setMidiEvent(MidiMessage mm){ 
     44                setMidiEvent((ShortMessage)mm); 
     45        } 
     46 
     47        public void setMidiEvent(ShortMessage shortm){ 
     48                setCommand(shortm.getCommand()); 
     49                setChannel(shortm.getChannel()); 
     50                setData1(shortm.getData1()); 
     51                setData2(shortm.getData2()); 
    4052        } 
    4153 
     
    4759                sl.add("Data2=" + getData2()); 
    4860 
    49                 StringBuffer sb = new StringBuffer(); 
     61                StringBuilder sb = new StringBuilder(); 
    5062                sb.append("MidiShort={"); 
    5163                if(!sl.isEmpty()){ 
     
    5971        } 
    6072 
    61         public boolean isReadied(){ 
     73        public boolean validate(){ 
    6274                return true; 
    6375        } 
    6476 
    65         public int compareTo(ImmutableObject obj){ 
     77        public int compareTo(BaseObject obj){ 
    6678                MidiShort midiShort = (MidiShort)obj; 
    6779                int c = compare(this.getCommand(), midiShort.getCommand()); 
     
    7284        } 
    7385 
    74         public MidiShort over(Object obj, boolean fill, boolean has){ 
     86        public MidiShort over(BaseObject obj, boolean fill, boolean has){ 
    7587                MidiShort midiShort = ((MidiShort)obj).clone(); 
    7688                setCommand(midiShort.getCommand()); 
     
    142154        } 
    143155 
    144         public static MidiShort load(String file) throws Exception{ 
    145                 return (MidiShort)ImmutableObject.load(file); 
     156        public static MidiShort load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     157                return (MidiShort)BaseObject.load(file); 
    146158        } 
    147159 
    148         public static MidiShort load(File file) throws Exception{ 
    149                 return (MidiShort)ImmutableObject.load(file); 
     160        public static MidiShort load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     161                return (MidiShort)BaseObject.load(file); 
    150162        } 
    151163 
    152         public void store(String file) throws Exception{ 
     164        public void store(String file) throws FileNotFoundException, IOException{ 
    153165                super.store(file); 
    154166        } 
    155167 
    156         public void store(File file) throws Exception{ 
     168        public void store(File file) throws FileNotFoundException, IOException{ 
    157169                super.store(file); 
    158170        } 
    159171 
    160         public static MidiShort unzip(String file) throws Exception{ 
    161                 return (MidiShort)ImmutableObject.unzip(file); 
     172        public static MidiShort unzip(String file) throws IOException, ClassNotFoundException{ 
     173                return (MidiShort)BaseObject.unzip(file); 
    162174        } 
    163175 
    164         public static MidiShort unzip(File file) throws Exception{ 
    165                 return (MidiShort)ImmutableObject.unzip(file); 
     176        public static MidiShort unzip(File file) throws IOException, ClassNotFoundException{ 
     177                return (MidiShort)BaseObject.unzip(file); 
    166178        } 
    167179 
    168         public void zip(String file) throws Exception{ 
     180        public void zip(String file) throws IOException{ 
    169181                super.zip(file); 
    170182        } 
    171183 
    172         public void zip(File file) throws Exception{ 
     184        public void zip(File file) throws IOException{ 
    173185                super.zip(file); 
    174186        } 
  • trunk/src/org/rayflood/mikuvat/io/midi/MidiSysex.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.midi; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.getByteArrayString; 
     3import static org.rayflood.mikuvat.Utilities.getByteArrayString; 
    44 
    55import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    68import java.util.ArrayList; 
    79import java.util.List; 
    810 
     11import javax.sound.midi.InvalidMidiDataException; 
    912import javax.sound.midi.MidiMessage; 
    1013import javax.sound.midi.SysexMessage; 
     14 
     15import org.rayflood.mikuvat.io.BaseObject; 
    1116 
    1217public class MidiSysex extends MidiData{ 
     
    1520        private byte[] data; 
    1621 
    17         public MidiSysex(MidiMessage mm){ 
     22        protected MidiSysex(MidiMessage mm){ 
    1823                setMidiEvent(mm); 
     24        } 
     25 
     26        public MidiSysex(SysexMessage sysex){ 
     27                setMidiEvent(sysex); 
    1928        } 
    2029 
     
    2433        } 
    2534 
    26         public SysexMessage getMidiEvent() throws Exception{ 
     35        public SysexMessage getMidiEvent() throws InvalidMidiDataException{ 
    2736                SysexMessage sysex = new SysexMessage(); 
    2837                sysex.setMessage(getStatus(), getData(), getData().length); 
     
    3039        } 
    3140 
    32         public void setMidiEvent(MidiMessage mm){ 
    33                 SysexMessage sysex = (SysexMessage)mm; 
     41        protected void setMidiEvent(MidiMessage mm){ 
     42                setMidiEvent((SysexMessage)mm); 
     43        } 
     44 
     45        public void setMidiEvent(SysexMessage sysex){ 
    3446                setStatus(sysex.getStatus()); 
    3547                setData(sysex.getData()); 
     
    4153                sl.add("Data=" + getByteArrayString(getData())); 
    4254 
    43                 StringBuffer sb = new StringBuffer(); 
     55                StringBuilder sb = new StringBuilder(); 
    4456                sb.append("MidiSysex={"); 
    4557                if(!sl.isEmpty()){ 
     
    5365        } 
    5466 
    55         public boolean isReadied(){ 
     67        public boolean validate(){ 
    5668                return true; 
    5769        } 
    5870 
    59         public int compareTo(ImmutableObject obj){ 
     71        public int compareTo(BaseObject obj){ 
    6072                MidiSysex midiSysex = (MidiSysex)obj; 
    6173                return compare(getStatus(), midiSysex.getStatus()); 
    6274        } 
    6375 
    64         public MidiSysex over(Object obj, boolean fill, boolean has){ 
     76        public MidiSysex over(BaseObject obj, boolean fill, boolean has){ 
    6577                MidiSysex midiSysex = ((MidiSysex)obj).clone(); 
    6678                setStatus(midiSysex.getStatus()); 
     
    112124        } 
    113125 
    114         public static MidiSysex load(String file) throws Exception{ 
    115                 return (MidiSysex)ImmutableObject.load(file); 
     126        public static MidiSysex load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     127                return (MidiSysex)BaseObject.load(file); 
    116128        } 
    117129 
    118         public static MidiSysex load(File file) throws Exception{ 
    119                 return (MidiSysex)ImmutableObject.load(file); 
     130        public static MidiSysex load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     131                return (MidiSysex)BaseObject.load(file); 
    120132        } 
    121133 
    122         public void store(String file) throws Exception{ 
     134        public void store(String file) throws FileNotFoundException, IOException{ 
    123135                super.store(file); 
    124136        } 
    125137 
    126         public void store(File file) throws Exception{ 
     138        public void store(File file) throws FileNotFoundException, IOException{ 
    127139                super.store(file); 
    128140        } 
    129141 
    130         public static MidiSysex unzip(String file) throws Exception{ 
    131                 return (MidiSysex)ImmutableObject.unzip(file); 
     142        public static MidiSysex unzip(String file) throws IOException, ClassNotFoundException{ 
     143                return (MidiSysex)BaseObject.unzip(file); 
    132144        } 
    133145 
    134         public static MidiSysex unzip(File file) throws Exception{ 
    135                 return (MidiSysex)ImmutableObject.unzip(file); 
     146        public static MidiSysex unzip(File file) throws IOException, ClassNotFoundException{ 
     147                return (MidiSysex)BaseObject.unzip(file); 
    136148        } 
    137149 
    138         public void zip(String file) throws Exception{ 
     150        public void zip(String file) throws IOException{ 
    139151                super.zip(file); 
    140152        } 
    141153 
    142         public void zip(File file) throws Exception{ 
     154        public void zip(File file) throws IOException{ 
    143155                super.zip(file); 
    144156        } 
  • trunk/src/org/rayflood/mikuvat/io/midi/MidiTrack.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.midi; 
    22 
    33import java.io.File; 
     4import java.io.FileNotFoundException; 
     5import java.io.IOException; 
    46import java.util.ArrayList; 
    57import java.util.List; 
    68import java.util.TreeMap; 
    79 
     10import javax.sound.midi.InvalidMidiDataException; 
    811import javax.sound.midi.MidiEvent; 
    912import javax.sound.midi.MidiMessage; 
    1013import javax.sound.midi.Track; 
    1114 
    12 public class MidiTrack extends ImmutableObject{ 
     15import org.rayflood.mikuvat.io.BaseObject; 
     16 
     17public class MidiTrack extends BaseObject{ 
    1318        private static final long serialVersionUID = -1866741348212885469L; 
    1419        private TreeMap<Long, ArrayList<MidiData>> trackdata; 
     
    1924        } 
    2025 
    21         public ArrayList<MidiEvent> getMidiEvent(long tick) throws Exception{ 
    22                 ArrayList<MidiData> list = getMidiData(tick); 
    23                 ArrayList<MidiEvent> mes = new ArrayList<MidiEvent>(); 
     26        public List<MidiEvent> getMidiEvent(long tick) throws InvalidMidiDataException { 
     27                List<MidiData> list = getMidiData(tick); 
     28                List<MidiEvent> mes = new ArrayList<MidiEvent>(); 
    2429                for(int i = 0; i < list.size(); i++){ 
    2530                        mes.add(new MidiEvent(list.get(i).getMidiEvent(), tick)); 
     
    2833        } 
    2934 
    30         public ArrayList<MidiMessage> getMidiMessage(long tick) throws Exception{ 
    31                 ArrayList<MidiData> list = getMidiData(tick); 
    32                 ArrayList<MidiMessage> mms = new ArrayList<MidiMessage>(); 
     35        public List<MidiMessage> getMidiMessage(long tick) throws InvalidMidiDataException{ 
     36                List<MidiData> list = getMidiData(tick); 
     37                List<MidiMessage> mms = new ArrayList<MidiMessage>(); 
    3338                for(int i = 0; i < list.size(); i++){ 
    3439                        mms.add(list.get(i).getMidiEvent()); 
     
    3742        } 
    3843 
    39         public ArrayList<MidiData> getMidiData(long tick){ 
     44        public List<MidiData> getMidiData(long tick){ 
    4045                return hasMidiData(tick) ? trackdata.get(tick) : new ArrayList<MidiData>(); 
    4146        } 
     
    5055 
    5156        public void addMidiData(long tick, MidiData midiData){ 
    52                 ArrayList<MidiData> list = getMidiData(tick); 
     57                ArrayList<MidiData> list = new ArrayList<MidiData>(getMidiData(tick)); 
    5358                list.add(midiData); 
    5459                trackdata.put(tick, list); 
    5560        } 
    5661 
    57         public void setMidiMessage(long tick, ArrayList<MidiMessage> messages){ 
    58                 ArrayList<MidiData> list = new ArrayList<MidiData>(); 
     62        public void setMidiMessage(long tick, List<MidiMessage> messages){ 
     63                List<MidiData> list = new ArrayList<MidiData>(); 
    5964                for(int i = 0; i < messages.size(); i++){ 
    6065                        list.add(MidiData.newMidiData(messages.get(i))); 
     
    6368        } 
    6469 
    65         public void setMidiData(long tick, ArrayList<MidiData> list){ 
    66                 trackdata.put(tick, list); 
    67         } 
    68  
    69         public void addMidiMessage(long tick, ArrayList<MidiMessage> messages){ 
     70        public void setMidiData(long tick, List<MidiData> list){ 
     71                trackdata.put(tick, new ArrayList<MidiData>(list)); 
     72        } 
     73 
     74        public void addMidiMessage(long tick, List<MidiMessage> messages){ 
    7075                for(int i = 0; i < messages.size(); i++){ 
    7176                        addMidiData(tick, MidiData.newMidiData(messages.get(i))); 
     
    7378        } 
    7479 
    75         public void addMidiData(long tick, ArrayList<MidiData> list){ 
     80        public void addMidiData(long tick, List<MidiData> list){ 
    7681                for(int i = 0; i < list.size(); i++){ 
    7782                        addMidiData(tick, list.get(i)); 
     
    9196        } 
    9297 
    93         public void getTrack(Track t) throws Exception{ 
     98        public void getTrack(Track t) throws InvalidMidiDataException{ 
    9499                Long ticks[] = getTicks(); 
    95100                for(int i = 0; i < ticks.length; i++){ 
    96                         ArrayList<MidiEvent> mes = getMidiEvent(ticks[i]); 
     101                        List<MidiEvent> mes = getMidiEvent(ticks[i]); 
    97102                        for(int j = 0; j < mes.size(); j++){ 
    98103                                t.add(mes.get(j)); 
     
    112117                if(ticks.length > 0){ 
    113118                        for(int i = 0; i < ticks.length; i++){ 
    114                                 ArrayList<MidiData> mes = getMidiData(ticks[i]); 
     119                                List<MidiData> mes = getMidiData(ticks[i]); 
    115120                                if(mes.size() > 0){ 
    116                                         StringBuffer sb = new StringBuffer(); 
     121                                        StringBuilder sb = new StringBuilder(); 
    117122                                        sb.append(mes.get(0).toString()); 
    118123                                        for(int j = 1; j < mes.size(); j++){ 
     
    124129                } 
    125130 
    126                 StringBuffer sb = new StringBuffer(); 
     131                StringBuilder sb = new StringBuilder(); 
    127132                sb.append("MidiTrack={"); 
    128133                if(!sl.isEmpty()){ 
     
    136141        } 
    137142 
    138         public boolean isReadied(){ 
     143        public boolean validate(){ 
    139144                return true; 
    140145        } 
    141146 
    142         public int compareTo(ImmutableObject obj){ 
     147        public int compareTo(BaseObject obj){ 
    143148                if(!(obj instanceof MidiTrack)){ 
    144149                        throw new ClassCastException(); 
     
    147152        } 
    148153 
    149         public MidiTrack over(Object obj, boolean fill, boolean has){ 
     154        public MidiTrack over(BaseObject obj, boolean fill, boolean has){ 
    150155                MidiTrack midiTrack = ((MidiTrack)obj).clone(); 
    151156                Long ticks[] = midiTrack.getTicks(); 
     
    153158                        long tick = ticks[i]; 
    154159                        if(fill || has == hasMidiData(tick)){ 
    155                                 ArrayList<MidiData> list = midiTrack.getMidiData(tick); 
     160                                List<MidiData> list = midiTrack.getMidiData(tick); 
    156161                                for(int j = 0; j < list.size(); j++){ 
    157162                                        addMidiData(tick, list.get(j)); 
     
    190195        } 
    191196 
    192         public static MidiTrack load(String file) throws Exception{ 
    193                 return (MidiTrack)ImmutableObject.load(file); 
    194         } 
    195  
    196         public static MidiTrack load(File file) throws Exception{ 
    197                 return (MidiTrack)ImmutableObject.load(file); 
    198         } 
    199  
    200         public void store(String file) throws Exception{ 
     197        public static MidiTrack load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     198                return (MidiTrack)BaseObject.load(file); 
     199        } 
     200 
     201        public static MidiTrack load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     202                return (MidiTrack)BaseObject.load(file); 
     203        } 
     204 
     205        public void store(String file) throws FileNotFoundException, IOException{ 
    201206                super.store(file); 
    202207        } 
    203208 
    204         public void store(File file) throws Exception{ 
     209        public void store(File file) throws FileNotFoundException, IOException{ 
    205210                super.store(file); 
    206211        } 
    207212 
    208         public static MidiTrack unzip(String file) throws Exception{ 
    209                 return (MidiTrack)ImmutableObject.unzip(file); 
    210         } 
    211  
    212         public static MidiTrack unzip(File file) throws Exception{ 
    213                 return (MidiTrack)ImmutableObject.unzip(file); 
    214         } 
    215  
    216         public void zip(String file) throws Exception{ 
     213        public static MidiTrack unzip(String file) throws IOException, ClassNotFoundException{ 
     214                return (MidiTrack)BaseObject.unzip(file); 
     215        } 
     216 
     217        public static MidiTrack unzip(File file) throws IOException, ClassNotFoundException{ 
     218                return (MidiTrack)BaseObject.unzip(file); 
     219        } 
     220 
     221        public void zip(String file) throws IOException{ 
    217222                super.zip(file); 
    218223        } 
    219224 
    220         public void zip(File file) throws Exception{ 
     225        public void zip(File file) throws IOException{ 
    221226                super.zip(file); 
    222227        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/AnoteEvent.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.setSectionBracket; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
     4import static org.rayflood.mikuvat.Utilities.setSectionBracket; 
    55 
    66import java.io.File; 
     7import java.io.FileNotFoundException; 
     8import java.io.IOException; 
    79import java.util.ArrayList; 
    810import java.util.List; 
    911import java.util.Map; 
     12 
     13import org.rayflood.mikuvat.io.BaseObject; 
     14import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
    1015 
    1116public class AnoteEvent extends Event{ 
     
    292297                } 
    293298 
    294                 StringBuffer sb = new StringBuffer(); 
     299                StringBuilder sb = new StringBuilder(); 
    295300                sb.append("AnoteEvent={"); 
    296301                if(!sl.isEmpty()){ 
     
    304309        } 
    305310 
    306         public boolean isReadied(){ 
     311        public boolean validate() throws InvalidBaseObjectException{ 
    307312                boolean ready = true; 
    308313                ready &= hasLength(); 
     
    314319                ready &= hasDecay(); 
    315320                ready &= hasAccent(); 
    316                 ready &= hasLyricHandle() && getLyricHandle().isReadied(); 
    317                 ready &= !hasVibratoHandle() || getVibratoHandle().isReadied(); 
     321                ready &= hasLyricHandle() && getLyricHandle().validate(); 
     322                ready &= !hasVibratoHandle() || getVibratoHandle().validate(); 
     323                if(!ready){ 
     324                        throw new InvalidBaseObjectException(this); 
     325                } 
    318326                return ready; 
    319327        } 
    320328 
    321         public int compareTo(ImmutableObject obj){ 
     329        public int compareTo(BaseObject obj){ 
    322330                AnoteEvent anoteEvent = (AnoteEvent)obj; 
    323331                int c = compare(getLyricHandle(), anoteEvent.getLyricHandle()); 
     
    331339        } 
    332340 
    333         public AnoteEvent over(Object obj, boolean fill, boolean has){ 
     341        public AnoteEvent over(BaseObject obj, boolean fill, boolean has){ 
    334342                AnoteEvent anoteEvent = ((AnoteEvent)obj).clone(); 
    335343                if(anoteEvent.hasLength() && (fill || has == hasLength())){ 
     
    657665        } 
    658666 
    659         public static AnoteEvent load(String file) throws Exception{ 
    660                 return (AnoteEvent)ImmutableObject.load(file); 
    661         } 
    662  
    663         public static AnoteEvent load(File file) throws Exception{ 
    664                 return (AnoteEvent)ImmutableObject.load(file); 
    665         } 
    666  
    667         public void store(String file) throws Exception{ 
     667        public static AnoteEvent load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     668                return (AnoteEvent)BaseObject.load(file); 
     669        } 
     670 
     671        public static AnoteEvent load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     672                return (AnoteEvent)BaseObject.load(file); 
     673        } 
     674 
     675        public void store(String file) throws FileNotFoundException, IOException{ 
    668676                super.store(file); 
    669677        } 
    670678 
    671         public void store(File file) throws Exception{ 
     679        public void store(File file) throws FileNotFoundException, IOException{ 
    672680                super.store(file); 
    673681        } 
    674682 
    675         public static AnoteEvent unzip(String file) throws Exception{ 
    676                 return (AnoteEvent)ImmutableObject.unzip(file); 
    677         } 
    678  
    679         public static AnoteEvent unzip(File file) throws Exception{ 
    680                 return (AnoteEvent)ImmutableObject.unzip(file); 
    681         } 
    682  
    683         public void zip(String file) throws Exception{ 
     683        public static AnoteEvent unzip(String file) throws IOException, ClassNotFoundException{ 
     684                return (AnoteEvent)BaseObject.unzip(file); 
     685        } 
     686 
     687        public static AnoteEvent unzip(File file) throws IOException, ClassNotFoundException{ 
     688                return (AnoteEvent)BaseObject.unzip(file); 
     689        } 
     690 
     691        public void zip(String file) throws IOException{ 
    684692                super.zip(file); 
    685693        } 
    686694 
    687         public void zip(File file) throws Exception{ 
     695        public void zip(File file) throws IOException{ 
    688696                super.zip(file); 
    689697        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/CommonSection.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.SPLITCOMMA; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.SPLITCOMMA; 
     4import static org.rayflood.mikuvat.Utilities.splitEqual; 
    55 
    66import java.awt.Color; 
    77import java.io.File; 
     8import java.io.FileNotFoundException; 
     9import java.io.IOException; 
    810import java.util.ArrayList; 
    911import java.util.List; 
    1012 
    11 public class CommonSection extends ImmutableObject{ 
     13import org.rayflood.mikuvat.io.BaseObject; 
     14import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     15 
     16public class CommonSection extends BaseObject{ 
    1217        private static final long serialVersionUID = 8435457526013952633L; 
    1318        public static final String VERSION = "Version"; 
     
    7782                } 
    7883 
    79                 StringBuffer sb = new StringBuffer(); 
     84                StringBuilder sb = new StringBuilder(); 
    8085                sb.append("CommonSection={"); 
    8186                if(!sl.isEmpty()){ 
     
    8994        } 
    9095 
    91         public boolean isReadied(){ 
     96        public boolean validate() throws InvalidBaseObjectException{ 
    9297                boolean ready = true; 
    9398                ready &= hasVersion(); 
     
    96101                ready &= hasDynamicsMode(); 
    97102                ready &= hasPlayMode(); 
     103                if(!ready){ 
     104                        throw new InvalidBaseObjectException(this); 
     105                } 
    98106                return ready; 
    99107        } 
    100108 
    101         public int compareTo(ImmutableObject obj){ 
     109        public int compareTo(BaseObject obj){ 
    102110                CommonSection commonSection = (CommonSection)obj; 
    103111                int c = compare(getName(), commonSection.getName()); 
     
    108116        } 
    109117 
    110         public CommonSection over(Object obj, boolean fill, boolean has){ 
     118        public CommonSection over(BaseObject obj, boolean fill, boolean has){ 
    111119                CommonSection commonSection = ((CommonSection)obj).clone(); 
    112120                if(commonSection.hasVersion() && (fill || has == hasVersion())){ 
     
    276284        } 
    277285 
    278         public static CommonSection load(String file) throws Exception{ 
    279                 return (CommonSection)ImmutableObject.load(file); 
    280         } 
    281  
    282         public static CommonSection load(File file) throws Exception{ 
    283                 return (CommonSection)ImmutableObject.load(file); 
    284         } 
    285  
    286         public void store(String file) throws Exception{ 
     286        public static CommonSection load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     287                return (CommonSection)BaseObject.load(file); 
     288        } 
     289 
     290        public static CommonSection load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     291                return (CommonSection)BaseObject.load(file); 
     292        } 
     293 
     294        public void store(String file) throws FileNotFoundException, IOException{ 
    287295                super.store(file); 
    288296        } 
    289297 
    290         public void store(File file) throws Exception{ 
     298        public void store(File file) throws FileNotFoundException, IOException{ 
    291299                super.store(file); 
    292300        } 
    293301 
    294         public static CommonSection unzip(String file) throws Exception{ 
    295                 return (CommonSection)ImmutableObject.unzip(file); 
    296         } 
    297  
    298         public static CommonSection unzip(File file) throws Exception{ 
    299                 return (CommonSection)ImmutableObject.unzip(file); 
    300         } 
    301  
    302         public void zip(String file) throws Exception{ 
     302        public static CommonSection unzip(String file) throws IOException, ClassNotFoundException{ 
     303                return (CommonSection)BaseObject.unzip(file); 
     304        } 
     305 
     306        public static CommonSection unzip(File file) throws IOException, ClassNotFoundException{ 
     307                return (CommonSection)BaseObject.unzip(file); 
     308        } 
     309 
     310        public void zip(String file) throws IOException{ 
    303311                super.zip(file); 
    304312        } 
    305313 
    306         public void zip(File file) throws Exception{ 
     314        public void zip(File file) throws IOException{ 
    307315                super.zip(file); 
    308316        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/EOSEvent.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.vsq; 
    22 
    33import java.io.File; 
     4import java.io.FileNotFoundException; 
     5import java.io.IOException; 
    46import java.util.List; 
    57import java.util.Map; 
     8 
     9import org.rayflood.mikuvat.io.BaseObject; 
    610 
    711public class EOSEvent extends Event{ 
     
    2024        } 
    2125 
    22         public boolean isReadied(){ 
     26        public boolean validate(){ 
    2327                return true; 
    2428        } 
    2529 
    26         public int compareTo(ImmutableObject obj){ 
     30        public int compareTo(BaseObject obj){ 
    2731                if(!(obj instanceof EOSEvent)){ 
    2832                        throw new ClassCastException(); 
     
    3135        } 
    3236 
    33         public EOSEvent over(Object obj, boolean fill, boolean has){ 
     37        public EOSEvent over(BaseObject obj, boolean fill, boolean has){ 
    3438                if(!(obj instanceof EOSEvent)){ 
    3539                        throw new ClassCastException(); 
     
    5458        } 
    5559 
    56         public static EOSEvent load(String file) throws Exception{ 
    57                 return (EOSEvent)ImmutableObject.load(file); 
     60        public static EOSEvent load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     61                return (EOSEvent)BaseObject.load(file); 
    5862        } 
    5963 
    60         public static EOSEvent load(File file) throws Exception{ 
    61                 return (EOSEvent)ImmutableObject.load(file); 
     64        public static EOSEvent load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     65                return (EOSEvent)BaseObject.load(file); 
    6266        } 
    6367 
    64         public void store(String file) throws Exception{ 
     68        public void store(String file) throws FileNotFoundException, IOException{ 
    6569                super.store(file); 
    6670        } 
    6771 
    68         public void store(File file) throws Exception{ 
     72        public void store(File file) throws FileNotFoundException, IOException{ 
    6973                super.store(file); 
    7074        } 
    7175 
    72         public static EOSEvent unzip(String file) throws Exception{ 
    73                 return (EOSEvent)ImmutableObject.unzip(file); 
     76        public static EOSEvent unzip(String file) throws IOException, ClassNotFoundException{ 
     77                return (EOSEvent)BaseObject.unzip(file); 
    7478        } 
    7579 
    76         public static EOSEvent unzip(File file) throws Exception{ 
    77                 return (EOSEvent)ImmutableObject.unzip(file); 
     80        public static EOSEvent unzip(File file) throws IOException, ClassNotFoundException{ 
     81                return (EOSEvent)BaseObject.unzip(file); 
    7882        } 
    7983 
    80         public void zip(String file) throws Exception{ 
     84        public void zip(String file) throws IOException{ 
    8185                super.zip(file); 
    8286        } 
    8387 
    84         public void zip(File file) throws Exception{ 
     88        public void zip(File file) throws IOException{ 
    8589                super.zip(file); 
    8690        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/Event.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.vsq; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     3import static org.rayflood.mikuvat.Utilities.splitEqual; 
    44 
    55import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    68import java.util.HashMap; 
    79import java.util.List; 
    810import java.util.Map; 
    911 
    10 public abstract class Event extends ImmutableObject{ 
     12import org.rayflood.mikuvat.io.BaseObject; 
     13 
     14public abstract class Event extends BaseObject{ 
    1115        private static final long serialVersionUID = 3144497610281730738L; 
    1216        public static final String TYPE = "Type"; 
     
    1519        public static final String EOS = "EOS"; 
    1620 
    17         public int compareTo(ImmutableObject obj){ 
     21        public int compareTo(BaseObject obj){ 
    1822                Event event = (Event)obj; 
    1923                return compare(getClass().getName(), event.getClass().getName()); 
     
    5862        } 
    5963 
    60         public static Event load(String file) throws Exception{ 
    61                 return (Event)ImmutableObject.load(file); 
     64        public static Event load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     65                return (Event)BaseObject.load(file); 
    6266        } 
    6367 
    64         public static Event load(File file) throws Exception{ 
    65                 return (Event)ImmutableObject.load(file); 
     68        public static Event load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     69                return (Event)BaseObject.load(file); 
    6670        } 
    6771 
    68         public void store(String file) throws Exception{ 
     72        public void store(String file) throws FileNotFoundException, IOException{ 
    6973                super.store(file); 
    7074        } 
    7175 
    72         public void store(File file) throws Exception{ 
     76        public void store(File file) throws FileNotFoundException, IOException{ 
    7377                super.store(file); 
    7478        } 
    7579 
    76         public static Event unzip(String file) throws Exception{ 
    77                 return (Event)ImmutableObject.unzip(file); 
     80        public static Event unzip(String file) throws IOException, ClassNotFoundException{ 
     81                return (Event)BaseObject.unzip(file); 
    7882        } 
    7983 
    80         public static Event unzip(File file) throws Exception{ 
    81                 return (Event)ImmutableObject.unzip(file); 
     84        public static Event unzip(File file) throws IOException, ClassNotFoundException{ 
     85                return (Event)BaseObject.unzip(file); 
    8286        } 
    8387 
    84         public void zip(String file) throws Exception{ 
     88        public void zip(String file) throws IOException{ 
    8589                super.zip(file); 
    8690        } 
    8791 
    88         public void zip(File file) throws Exception{ 
     92        public void zip(File file) throws IOException{ 
    8993                super.zip(file); 
    9094        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/EventBPTime.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
    44 
    55import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    68import java.util.ArrayList; 
    79import java.util.List; 
    810 
    9 public class EventBPTime extends ImmutableObject{ 
     11import org.rayflood.mikuvat.io.BaseObject; 
     12import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     13 
     14public class EventBPTime extends BaseObject{ 
    1015        private static final long serialVersionUID = 817431318781476681L; 
    1116        public static final int PITCHBEND_MAX = 8191; 
     
    144149                } 
    145150 
    146                 StringBuffer sb = new StringBuffer(); 
     151                StringBuilder sb = new StringBuilder(); 
    147152                sb.append("EventBPTime={"); 
    148153                if(!sl.isEmpty()){ 
     
    156161        } 
    157162 
    158         public boolean isReadied(){ 
    159                 return !hasEvent() || getEvent().isReadied(); 
    160         } 
    161  
    162         public int compareTo(ImmutableObject obj){ 
     163        public boolean validate() throws InvalidBaseObjectException{ 
     164                boolean ready = true; 
     165                ready &= !hasEvent() || getEvent().validate(); 
     166                if(!ready){ 
     167                        throw new InvalidBaseObjectException(this); 
     168                } 
     169                return ready; 
     170        } 
     171 
     172        public int compareTo(BaseObject obj){ 
    163173                EventBPTime eventBPTime = (EventBPTime)obj; 
    164174                int c = compare(getDynamics(), eventBPTime.getDynamics()); 
     
    201211        } 
    202212 
    203         public EventBPTime over(Object obj, boolean fill, boolean has){ 
     213        public EventBPTime over(BaseObject obj, boolean fill, boolean has){ 
    204214                EventBPTime eventBPTime = ((EventBPTime)obj).clone(); 
    205215                if(eventBPTime.hasEvent()){ 
     
    889899        } 
    890900 
    891         public static EventBPTime load(String file) throws Exception{ 
    892                 return (EventBPTime)ImmutableObject.load(file); 
    893         } 
    894  
    895         public static EventBPTime load(File file) throws Exception{ 
    896                 return (EventBPTime)ImmutableObject.load(file); 
    897         } 
    898  
    899         public void store(String file) throws Exception{ 
     901        public static EventBPTime load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     902                return (EventBPTime)BaseObject.load(file); 
     903        } 
     904 
     905        public static EventBPTime load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     906                return (EventBPTime)BaseObject.load(file); 
     907        } 
     908 
     909        public void store(String file) throws FileNotFoundException, IOException{ 
    900910                super.store(file); 
    901911        } 
    902912 
    903         public void store(File file) throws Exception{ 
     913        public void store(File file) throws FileNotFoundException, IOException{ 
    904914                super.store(file); 
    905915        } 
    906916 
    907         public static EventBPTime unzip(String file) throws Exception{ 
    908                 return (EventBPTime)ImmutableObject.unzip(file); 
    909         } 
    910  
    911         public static EventBPTime unzip(File file) throws Exception{ 
    912                 return (EventBPTime)ImmutableObject.unzip(file); 
    913         } 
    914  
    915         public void zip(String file) throws Exception{ 
     917        public static EventBPTime unzip(String file) throws IOException, ClassNotFoundException{ 
     918                return (EventBPTime)BaseObject.unzip(file); 
     919        } 
     920 
     921        public static EventBPTime unzip(File file) throws IOException, ClassNotFoundException{ 
     922                return (EventBPTime)BaseObject.unzip(file); 
     923        } 
     924 
     925        public void zip(String file) throws IOException{ 
    916926                super.zip(file); 
    917927        } 
    918928 
    919         public void zip(File file) throws Exception{ 
     929        public void zip(File file) throws IOException{ 
    920930                super.zip(file); 
    921931        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/IconHandle.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.splitEqual; 
    44 
    55import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    68import java.util.ArrayList; 
    79import java.util.List; 
    810 
    9 public class IconHandle extends ImmutableObject{ 
     11import org.rayflood.mikuvat.io.BaseObject; 
     12import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     13 
     14public class IconHandle extends BaseObject{ 
    1015        private static final long serialVersionUID = 6787028875195143543L; 
    1116        public static final String ICONID = "IconID"; 
     
    9398                } 
    9499 
    95                 StringBuffer sb = new StringBuffer(); 
     100                StringBuilder sb = new StringBuilder(); 
    96101                sb.append("IconHandle={"); 
    97102                if(!sl.isEmpty()){ 
     
    105110        } 
    106111 
    107         public boolean isReadied(){ 
     112        public boolean validate() throws InvalidBaseObjectException{ 
    108113                boolean ready = true; 
    109114                ready &= hasIconID(); 
     
    114119                ready &= hasLanguage(); 
    115120                ready &= hasProgram(); 
     121                if(!ready){ 
     122                        throw new InvalidBaseObjectException(this); 
     123                } 
    116124                return ready; 
    117125        } 
    118126 
    119         public int compareTo(ImmutableObject obj){ 
     127        public int compareTo(BaseObject obj){ 
    120128                IconHandle iconHandle = (IconHandle)obj; 
    121129                return compare(getIconID(), iconHandle.getIconID()); 
    122130        } 
    123131 
    124         public IconHandle over(Object obj, boolean fill, boolean has){ 
     132        public IconHandle over(BaseObject obj, boolean fill, boolean has){ 
    125133                IconHandle iconHandle = ((IconHandle)obj).clone(); 
    126134                if(iconHandle.hasIconID() && (fill || has == hasIconID())){ 
     
    340348        } 
    341349 
    342         public static IconHandle load(String file) throws Exception{ 
    343                 return (IconHandle)ImmutableObject.load(file); 
    344         } 
    345  
    346         public static IconHandle load(File file) throws Exception{ 
    347                 return (IconHandle)ImmutableObject.load(file); 
    348         } 
    349  
    350         public void store(String file) throws Exception{ 
     350        public static IconHandle load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     351                return (IconHandle)BaseObject.load(file); 
     352        } 
     353 
     354        public static IconHandle load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     355                return (IconHandle)BaseObject.load(file); 
     356        } 
     357 
     358        public void store(String file) throws FileNotFoundException, IOException{ 
    351359                super.store(file); 
    352360        } 
    353361 
    354         public void store(File file) throws Exception{ 
     362        public void store(File file) throws FileNotFoundException, IOException{ 
    355363                super.store(file); 
    356364        } 
    357365 
    358         public static IconHandle unzip(String file) throws Exception{ 
    359                 return (IconHandle)ImmutableObject.unzip(file); 
    360         } 
    361  
    362         public static IconHandle unzip(File file) throws Exception{ 
    363                 return (IconHandle)ImmutableObject.unzip(file); 
    364         } 
    365  
    366         public void zip(String file) throws Exception{ 
     366        public static IconHandle unzip(String file) throws IOException, ClassNotFoundException{ 
     367                return (IconHandle)BaseObject.unzip(file); 
     368        } 
     369 
     370        public static IconHandle unzip(File file) throws IOException, ClassNotFoundException{ 
     371                return (IconHandle)BaseObject.unzip(file); 
     372        } 
     373 
     374        public void zip(String file) throws IOException{ 
    367375                super.zip(file); 
    368376        } 
    369377 
    370         public void zip(File file) throws Exception{ 
     378        public void zip(File file) throws IOException{ 
    371379                super.zip(file); 
    372380        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/LyricHandle.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.vsq; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     3import static org.rayflood.mikuvat.Utilities.splitEqual; 
    44 
    55import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    68import java.util.ArrayList; 
    79import java.util.List; 
    810 
    9 public class LyricHandle extends ImmutableObject{ 
     11import org.rayflood.mikuvat.io.BaseObject; 
     12import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     13 
     14public class LyricHandle extends BaseObject{ 
    1015        private static final long serialVersionUID = 3044157326865723314L; 
    1116        private ArrayList<LyricNote> lyricNotes; 
     
    4752                } 
    4853 
    49                 StringBuffer sb = new StringBuffer(); 
     54                StringBuilder sb = new StringBuilder(); 
    5055                sb.append("LyricHandle={"); 
    5156                if(!sl.isEmpty()){ 
     
    5964        } 
    6065 
    61         public boolean isReadied(){ 
     66        public boolean validate() throws InvalidBaseObjectException{ 
    6267                boolean ready = true; 
    63                 ready &= hasLyricNotes() && getLyricNote().isReadied(); 
     68                ready &= hasLyricNotes() && getLyricNote().validate(); 
     69                if(!ready){ 
     70                        throw new InvalidBaseObjectException(this); 
     71                } 
    6472                return ready; 
    6573        } 
    6674 
    67         public int compareTo(ImmutableObject obj){ 
     75        public int compareTo(BaseObject obj){ 
    6876                LyricHandle lyricHandle = (LyricHandle)obj; 
    6977                return compare(getLyricNote(), lyricHandle.getLyricNote()); 
    7078        } 
    7179 
    72         public LyricHandle over(Object obj, boolean fill, boolean has){ 
     80        public LyricHandle over(BaseObject obj, boolean fill, boolean has){ 
    7381                LyricHandle lyricHandle = ((LyricHandle)obj).clone(); 
    7482                if(lyricHandle.hasLyricNotes()){ 
     
    150158        } 
    151159 
    152         public static LyricHandle load(String file) throws Exception{ 
    153                 return (LyricHandle)ImmutableObject.load(file); 
     160        public static LyricHandle load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     161                return (LyricHandle)BaseObject.load(file); 
    154162        } 
    155163 
    156         public static LyricHandle load(File file) throws Exception{ 
    157                 return (LyricHandle)ImmutableObject.load(file); 
     164        public static LyricHandle load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     165                return (LyricHandle)BaseObject.load(file); 
    158166        } 
    159167 
    160         public void store(String file) throws Exception{ 
     168        public void store(String file) throws FileNotFoundException, IOException{ 
    161169                super.store(file); 
    162170        } 
    163171 
    164         public void store(File file) throws Exception{ 
     172        public void store(File file) throws FileNotFoundException, IOException{ 
    165173                super.store(file); 
    166174        } 
    167175 
    168         public static LyricHandle unzip(String file) throws Exception{ 
    169                 return (LyricHandle)ImmutableObject.unzip(file); 
     176        public static LyricHandle unzip(String file) throws IOException, ClassNotFoundException{ 
     177                return (LyricHandle)BaseObject.unzip(file); 
    170178        } 
    171179 
    172         public static LyricHandle unzip(File file) throws Exception{ 
    173                 return (LyricHandle)ImmutableObject.unzip(file); 
     180        public static LyricHandle unzip(File file) throws IOException, ClassNotFoundException{ 
     181                return (LyricHandle)BaseObject.unzip(file); 
    174182        } 
    175183 
    176         public void zip(String file) throws Exception{ 
     184        public void zip(String file) throws IOException{ 
    177185                super.zip(file); 
    178186        } 
    179187 
    180         public void zip(File file) throws Exception{ 
     188        public void zip(File file) throws IOException{ 
    181189                super.zip(file); 
    182190        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/LyricNote.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.SPLITCOMMA; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.SPLITDQUOTE; 
    5 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
    6 import static org.rayflood.mikuvat.io.VSQDecoder.getBigDecimalString; 
    7 import static org.rayflood.mikuvat.io.VSQDecoder.getBooleanValue; 
    8 import static org.rayflood.mikuvat.io.VSQDecoder.getStringValue; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.SPLITCOMMA; 
     4import static org.rayflood.mikuvat.Utilities.SPLITDQUOTE; 
     5import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
     6import static org.rayflood.mikuvat.Utilities.getBigDecimalString; 
     7import static org.rayflood.mikuvat.Utilities.getBooleanValue; 
     8import static org.rayflood.mikuvat.Utilities.getStringValue; 
    99 
    1010import java.io.File; 
     11import java.io.FileNotFoundException; 
     12import java.io.IOException; 
    1113import java.math.BigDecimal; 
    1214import java.util.ArrayList; 
    1315import java.util.List; 
    1416 
    15 public class LyricNote extends ImmutableObject{ 
     17import org.rayflood.mikuvat.io.BaseObject; 
     18import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     19 
     20public class LyricNote extends BaseObject{ 
    1621        private static final long serialVersionUID = -119405351990339359L; 
    1722        public static final BigDecimal A_MAX = new BigDecimal("1.0"); 
     
    7883                } 
    7984                if(hasB()){ 
    80                         StringBuffer sb = new StringBuffer(); 
     85                        StringBuilder sb = new StringBuilder(); 
    8186                        sb.append(b[0]); 
    8287                        for(int i = 1; i < b.length; i++){ 
     
    8994                } 
    9095 
    91                 StringBuffer sb = new StringBuffer(); 
     96                StringBuilder sb = new StringBuilder(); 
    9297                sb.append("LyricNote={"); 
    9398                if(!sl.isEmpty()){ 
     
    101106        } 
    102107 
    103         public boolean isReadied(){ 
     108        public boolean validate() throws InvalidBaseObjectException{ 
    104109                boolean ready = true; 
    105110                ready &= hasCaption(); 
     
    108113                ready &= hasB(); 
    109114                ready &= hasProtect(); 
     115                if(!ready){ 
     116                        throw new InvalidBaseObjectException(this); 
     117                } 
    110118                return ready; 
    111119        } 
    112120 
    113         public int compareTo(ImmutableObject obj){ 
     121        public int compareTo(BaseObject obj){ 
    114122                LyricNote lyricNote = (LyricNote)obj; 
    115123                int c = compare(getCaption(), lyricNote.getCaption()); 
     
    123131        } 
    124132 
    125         public LyricNote over(Object obj, boolean fill, boolean has){ 
     133        public LyricNote over(BaseObject obj, boolean fill, boolean has){ 
    126134                LyricNote lyricNote = ((LyricNote)obj).clone(); 
    127135                if(lyricNote.hasCaption() && (fill || has == hasCaption())){ 
     
    281289        } 
    282290 
    283         public static LyricNote load(String file) throws Exception{ 
    284                 return (LyricNote)ImmutableObject.load(file); 
    285         } 
    286  
    287         public static LyricNote load(File file) throws Exception{ 
    288                 return (LyricNote)ImmutableObject.load(file); 
    289         } 
    290  
    291         public void store(String file) throws Exception{ 
     291        public static LyricNote load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     292                return (LyricNote)BaseObject.load(file); 
     293        } 
     294 
     295        public static LyricNote load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     296                return (LyricNote)BaseObject.load(file); 
     297        } 
     298 
     299        public void store(String file) throws FileNotFoundException, IOException{ 
    292300                super.store(file); 
    293301        } 
    294302 
    295         public void store(File file) throws Exception{ 
     303        public void store(File file) throws FileNotFoundException, IOException{ 
    296304                super.store(file); 
    297305        } 
    298306 
    299         public static LyricNote unzip(String file) throws Exception{ 
    300                 return (LyricNote)ImmutableObject.unzip(file); 
    301         } 
    302  
    303         public static LyricNote unzip(File file) throws Exception{ 
    304                 return (LyricNote)ImmutableObject.unzip(file); 
    305         } 
    306  
    307         public void zip(String file) throws Exception{ 
     307        public static LyricNote unzip(String file) throws IOException, ClassNotFoundException{ 
     308                return (LyricNote)BaseObject.unzip(file); 
     309        } 
     310 
     311        public static LyricNote unzip(File file) throws IOException, ClassNotFoundException{ 
     312                return (LyricNote)BaseObject.unzip(file); 
     313        } 
     314 
     315        public void zip(String file) throws IOException{ 
    308316                super.zip(file); 
    309317        } 
    310318 
    311         public void zip(File file) throws Exception{ 
     319        public void zip(File file) throws IOException{ 
    312320                super.zip(file); 
    313321        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/MasterSection.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.vsq; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     3import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
     4import static org.rayflood.mikuvat.Utilities.splitEqual; 
    55 
    66import java.io.File; 
     7import java.io.FileNotFoundException; 
     8import java.io.IOException; 
    79import java.util.ArrayList; 
    810import java.util.List; 
    911 
    10 public class MasterSection extends ImmutableObject{ 
     12import org.rayflood.mikuvat.io.BaseObject; 
     13import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     14 
     15public class MasterSection extends BaseObject{ 
    1116        private static final long serialVersionUID = 3680414369532973128L; 
    1217 
     
    4449                } 
    4550 
    46                 StringBuffer sb = new StringBuffer(); 
     51                StringBuilder sb = new StringBuilder(); 
    4752                sb.append("MasterSection={"); 
    4853                if(!sl.isEmpty()){ 
     
    5661        } 
    5762 
    58         public boolean isReadied(){ 
     63        public boolean validate() throws InvalidBaseObjectException{ 
    5964                boolean ready = true; 
    6065                ready &= hasPreMeasure(); 
     66                if(!ready){ 
     67                        throw new InvalidBaseObjectException(this); 
     68                } 
    6169                return ready; 
    6270        } 
    6371 
    64         public int compareTo(ImmutableObject obj){ 
     72        public int compareTo(BaseObject obj){ 
    6573                MasterSection masterSection = (MasterSection)obj; 
    6674                return compare(this.getPreMeasure(), masterSection.getPreMeasure()); 
    6775        } 
    6876 
    69         public MasterSection over(Object obj, boolean fill, boolean has){ 
     77        public MasterSection over(BaseObject obj, boolean fill, boolean has){ 
    7078                MasterSection masterSection = ((MasterSection)obj).clone(); 
    7179                if(masterSection.hasPreMeasure() && (fill || has == hasPreMeasure())){ 
     
    129137        } 
    130138 
    131         public static MasterSection load(String file) throws Exception{ 
    132                 return (MasterSection)ImmutableObject.load(file); 
     139        public static MasterSection load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     140                return (MasterSection)BaseObject.load(file); 
    133141        } 
    134142 
    135         public static MasterSection load(File file) throws Exception{ 
    136                 return (MasterSection)ImmutableObject.load(file); 
     143        public static MasterSection load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     144                return (MasterSection)BaseObject.load(file); 
    137145        } 
    138146 
    139         public void store(String file) throws Exception{ 
     147        public void store(String file) throws FileNotFoundException, IOException{ 
    140148                super.store(file); 
    141149        } 
    142150 
    143         public void store(File file) throws Exception{ 
     151        public void store(File file) throws FileNotFoundException, IOException{ 
    144152                super.store(file); 
    145153        } 
    146154 
    147         public static MasterSection unzip(String file) throws Exception{ 
    148                 return (MasterSection)ImmutableObject.unzip(file); 
     155        public static MasterSection unzip(String file) throws IOException, ClassNotFoundException{ 
     156                return (MasterSection)BaseObject.unzip(file); 
    149157        } 
    150158 
    151         public static MasterSection unzip(File file) throws Exception{ 
    152                 return (MasterSection)ImmutableObject.unzip(file); 
     159        public static MasterSection unzip(File file) throws IOException, ClassNotFoundException{ 
     160                return (MasterSection)BaseObject.unzip(file); 
    153161        } 
    154162 
    155         public void zip(String file) throws Exception{ 
     163        public void zip(String file) throws IOException{ 
    156164                super.zip(file); 
    157165        } 
    158166 
    159         public void zip(File file) throws Exception{ 
     167        public void zip(File file) throws IOException{ 
    160168                super.zip(file); 
    161169        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/MixerSection.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.getBooleanValue; 
    5 import static org.rayflood.mikuvat.io.VSQDecoder.getStringValue; 
    6 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
     4import static org.rayflood.mikuvat.Utilities.getBooleanValue; 
     5import static org.rayflood.mikuvat.Utilities.getStringValue; 
     6import static org.rayflood.mikuvat.Utilities.splitEqual; 
    77 
    88import java.io.File; 
     9import java.io.FileNotFoundException; 
     10import java.io.IOException; 
    911import java.util.ArrayList; 
    1012import java.util.HashMap; 
     
    1214import java.util.TreeMap; 
    1315 
    14 public class MixerSection extends ImmutableObject{ 
     16import org.rayflood.mikuvat.io.BaseObject; 
     17import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     18 
     19public class MixerSection extends BaseObject{ 
    1520        private static final long serialVersionUID = 1038661919778326460L; 
    1621        public static final String MASTERFEDER = "MasterFeder"; 
     
    175180                } 
    176181                if(hasMixerSettings()){ 
    177                         StringBuffer sb = new StringBuffer(); 
     182                        StringBuilder sb = new StringBuilder(); 
    178183                        Integer indexes[] = getIndexes(); 
    179184                        sb.append(indexes[0] + "={" + getMixerSetting(indexes[0]).toString() + "}"); 
     
    184189                } 
    185190 
    186                 StringBuffer sb = new StringBuffer(); 
     191                StringBuilder sb = new StringBuilder(); 
    187192                sb.append("MixerSection={"); 
    188193                if(!sl.isEmpty()){ 
     
    196201        } 
    197202 
    198         public boolean isReadied(){ 
     203        public boolean validate() throws InvalidBaseObjectException{ 
    199204                boolean ready = true; 
    200205                ready &= hasMasterFeder(); 
     
    205210                Integer indexes[] = getIndexes(); 
    206211                for(int i = 0; i < indexes.length; i++){ 
    207                         ready &= getMixerSetting(indexes[i]).isReadied(); 
     212                        ready &= getMixerSetting(indexes[i]).validate(); 
    208213                } 
    209214                ready &= (getTracks() == indexes.length); 
     215                if(!ready){ 
     216                        throw new InvalidBaseObjectException(this); 
     217                } 
    210218                return ready; 
    211219        } 
    212220 
    213         public int compareTo(ImmutableObject obj){ 
     221        public int compareTo(BaseObject obj){ 
    214222                MixerSection mixerSection = (MixerSection)obj; 
    215223                int c = compare(getMasterFeder(), mixerSection.getMasterFeder()); 
     
    226234        } 
    227235 
    228         public MixerSection over(Object obj, boolean fill, boolean has){ 
     236        public MixerSection over(BaseObject obj, boolean fill, boolean has){ 
    229237                MixerSection mixerSection = ((MixerSection)obj).clone(); 
    230238                if(mixerSection.hasMasterFeder() && (fill || has == hasMasterFeder())){ 
     
    439447        } 
    440448 
    441         public static MixerSection load(String file) throws Exception{ 
    442                 return (MixerSection)ImmutableObject.load(file); 
    443         } 
    444  
    445         public static MixerSection load(File file) throws Exception{ 
    446                 return (MixerSection)ImmutableObject.load(file); 
    447         } 
    448  
    449         public void store(String file) throws Exception{ 
     449        public static MixerSection load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     450                return (MixerSection)BaseObject.load(file); 
     451        } 
     452 
     453        public static MixerSection load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     454                return (MixerSection)BaseObject.load(file); 
     455        } 
     456 
     457        public void store(String file) throws FileNotFoundException, IOException{ 
    450458                super.store(file); 
    451459        } 
    452460 
    453         public void store(File file) throws Exception{ 
     461        public void store(File file) throws FileNotFoundException, IOException{ 
    454462                super.store(file); 
    455463        } 
    456464 
    457         public static MixerSection unzip(String file) throws Exception{ 
    458                 return (MixerSection)ImmutableObject.unzip(file); 
    459         } 
    460  
    461         public static MixerSection unzip(File file) throws Exception{ 
    462                 return (MixerSection)ImmutableObject.unzip(file); 
    463         } 
    464  
    465         public void zip(String file) throws Exception{ 
     465        public static MixerSection unzip(String file) throws IOException, ClassNotFoundException{ 
     466                return (MixerSection)BaseObject.unzip(file); 
     467        } 
     468 
     469        public static MixerSection unzip(File file) throws IOException, ClassNotFoundException{ 
     470                return (MixerSection)BaseObject.unzip(file); 
     471        } 
     472 
     473        public void zip(String file) throws IOException{ 
    466474                super.zip(file); 
    467475        } 
    468476 
    469         public void zip(File file) throws Exception{ 
     477        public void zip(File file) throws IOException{ 
    470478                super.zip(file); 
    471479        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/MixerSetting.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.getBooleanValue; 
    5 import static org.rayflood.mikuvat.io.VSQDecoder.getStringValue; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
     4import static org.rayflood.mikuvat.Utilities.getBooleanValue; 
     5import static org.rayflood.mikuvat.Utilities.getStringValue; 
    66 
    77import java.io.File; 
     8import java.io.FileNotFoundException; 
     9import java.io.IOException; 
    810import java.util.ArrayList; 
    911import java.util.List; 
    1012 
    11 public class MixerSetting extends ImmutableObject{ 
     13import org.rayflood.mikuvat.io.BaseObject; 
     14import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     15 
     16public class MixerSetting extends BaseObject{ 
    1217        private static final long serialVersionUID = -4879364127354448647L; 
    1318        private Integer feder; 
     
    4752                } 
    4853 
    49                 StringBuffer sb = new StringBuffer(); 
     54                StringBuilder sb = new StringBuilder(); 
    5055                sb.append("MixerSetting={"); 
    5156                if(!sl.isEmpty()){ 
     
    5964        } 
    6065 
    61         public boolean isReadied(){ 
     66        public boolean validate() throws InvalidBaseObjectException{ 
    6267                boolean ready = true; 
    6368                ready &= hasFeder(); 
     
    6570                ready &= hasMute(); 
    6671                ready &= hasSolo(); 
     72                if(!ready){ 
     73                        throw new InvalidBaseObjectException(this); 
     74                } 
    6775                return ready; 
    6876        } 
    6977 
    70         public int compareTo(ImmutableObject obj){ 
     78        public int compareTo(BaseObject obj){ 
    7179                MixerSetting mixerSetting = (MixerSetting)obj; 
    7280                int c = compare(getFeder(), mixerSetting.getFeder()); 
     
    8391        } 
    8492 
    85         public MixerSetting over(Object obj, boolean fill, boolean has){ 
     93        public MixerSetting over(BaseObject obj, boolean fill, boolean has){ 
    8694                MixerSetting mixerSetting = ((MixerSetting)obj).clone(); 
    8795                if(mixerSetting.hasFeder() && (fill || has == hasFeder())){ 
     
    235243        } 
    236244 
    237         public static MixerSetting load(String file) throws Exception{ 
    238                 return (MixerSetting)ImmutableObject.load(file); 
    239         } 
    240  
    241         public static MixerSetting load(File file) throws Exception{ 
    242                 return (MixerSetting)ImmutableObject.load(file); 
    243         } 
    244  
    245         public void store(String file) throws Exception{ 
     245        public static MixerSetting load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     246                return (MixerSetting)BaseObject.load(file); 
     247        } 
     248 
     249        public static MixerSetting load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     250                return (MixerSetting)BaseObject.load(file); 
     251        } 
     252 
     253        public void store(String file) throws FileNotFoundException, IOException{ 
    246254                super.store(file); 
    247255        } 
    248256 
    249         public void store(File file) throws Exception{ 
     257        public void store(File file) throws FileNotFoundException, IOException{ 
    250258                super.store(file); 
    251259        } 
    252260 
    253         public static MixerSetting unzip(String file) throws Exception{ 
    254                 return (MixerSetting)ImmutableObject.unzip(file); 
    255         } 
    256  
    257         public static MixerSetting unzip(File file) throws Exception{ 
    258                 return (MixerSetting)ImmutableObject.unzip(file); 
    259         } 
    260  
    261         public void zip(String file) throws Exception{ 
     261        public static MixerSetting unzip(String file) throws IOException, ClassNotFoundException{ 
     262                return (MixerSetting)BaseObject.unzip(file); 
     263        } 
     264 
     265        public static MixerSetting unzip(File file) throws IOException, ClassNotFoundException{ 
     266                return (MixerSetting)BaseObject.unzip(file); 
     267        } 
     268 
     269        public void zip(String file) throws IOException{ 
    262270                super.zip(file); 
    263271        } 
    264272 
    265         public void zip(File file) throws Exception{ 
     273        public void zip(File file) throws IOException{ 
    266274                super.zip(file); 
    267275        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/SingerEvent.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.vsq; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.setSectionBracket; 
     3import static org.rayflood.mikuvat.Utilities.setSectionBracket; 
    44 
    55import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    68import java.util.ArrayList; 
    79import java.util.List; 
    810import java.util.Map; 
     11 
     12import org.rayflood.mikuvat.io.BaseObject; 
     13import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
    914 
    1015public class SingerEvent extends Event{ 
     
    4752                } 
    4853 
    49                 StringBuffer sb = new StringBuffer(); 
     54                StringBuilder sb = new StringBuilder(); 
    5055                sb.append("SingerEvent={"); 
    5156                if(!sl.isEmpty()){ 
     
    5964        } 
    6065 
    61         public boolean isReadied(){ 
     66        public boolean validate() throws InvalidBaseObjectException{ 
    6267                boolean ready = true; 
    63                 ready &= hasIconHandle() && getIconHandle().isReadied(); 
     68                ready &= hasIconHandle() && getIconHandle().validate(); 
     69                if(!ready){ 
     70                        throw new InvalidBaseObjectException(this); 
     71                } 
    6472                return ready; 
    6573        } 
    6674 
    67         public int compareTo(ImmutableObject obj){ 
     75        public int compareTo(BaseObject obj){ 
    6876                SingerEvent singerEvent = (SingerEvent)obj; 
    6977                return compare(getIconHandle(), singerEvent.getIconHandle()); 
    7078        } 
    7179 
    72         public SingerEvent over(Object obj, boolean fill, boolean has){ 
     80        public SingerEvent over(BaseObject obj, boolean fill, boolean has){ 
    7381                SingerEvent singerEvent = ((SingerEvent)obj).clone(); 
    7482                if(singerEvent.hasIconHandle()){ 
     
    129137        } 
    130138 
    131         public static SingerEvent load(String file) throws Exception{ 
    132                 return (SingerEvent)ImmutableObject.load(file); 
     139        public static SingerEvent load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     140                return (SingerEvent)BaseObject.load(file); 
    133141        } 
    134142 
    135         public static SingerEvent load(File file) throws Exception{ 
    136                 return (SingerEvent)ImmutableObject.load(file); 
     143        public static SingerEvent load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     144                return (SingerEvent)BaseObject.load(file); 
    137145        } 
    138146 
    139         public void store(String file) throws Exception{ 
     147        public void store(String file) throws FileNotFoundException, IOException{ 
    140148                super.store(file); 
    141149        } 
    142150 
    143         public void store(File file) throws Exception{ 
     151        public void store(File file) throws FileNotFoundException, IOException{ 
    144152                super.store(file); 
    145153        } 
    146154 
    147         public static SingerEvent unzip(String file) throws Exception{ 
    148                 return (SingerEvent)ImmutableObject.unzip(file); 
     155        public static SingerEvent unzip(String file) throws IOException, ClassNotFoundException{ 
     156                return (SingerEvent)BaseObject.unzip(file); 
    149157        } 
    150158 
    151         public static SingerEvent unzip(File file) throws Exception{ 
    152                 return (SingerEvent)ImmutableObject.unzip(file); 
     159        public static SingerEvent unzip(File file) throws IOException, ClassNotFoundException{ 
     160                return (SingerEvent)BaseObject.unzip(file); 
    153161        } 
    154162 
    155         public void zip(String file) throws Exception{ 
     163        public void zip(String file) throws IOException{ 
    156164                super.zip(file); 
    157165        } 
    158166 
    159         public void zip(File file) throws Exception{ 
     167        public void zip(File file) throws IOException{ 
    160168                super.zip(file); 
    161169        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/TimeLine.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.setSectionBracket; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.setSectionBracket; 
     4import static org.rayflood.mikuvat.Utilities.splitEqual; 
    55 
    66import java.io.File; 
     7import java.io.FileNotFoundException; 
     8import java.io.IOException; 
    79import java.util.ArrayList; 
    810import java.util.List; 
     
    1012import java.util.TreeMap; 
    1113 
    12 public class TimeLine extends ImmutableObject{ 
     14import org.rayflood.mikuvat.io.BaseObject; 
     15import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     16 
     17public class TimeLine extends BaseObject{ 
    1318        private static final long serialVersionUID = -3486238291169847310L; 
    1419        public static final String PITCHBEND = "PitchBendBPList"; 
     
    580585                } 
    581586                if(hasEventTimes()){ 
    582                         StringBuffer sb = new StringBuffer(); 
     587                        StringBuilder sb = new StringBuilder(); 
    583588                        Long ticks[] = getTicks(); 
    584589                        sb.append(ticks[0] + "={" + getEventBPTime(ticks[0]).toString() + "}"); 
     
    589594                } 
    590595 
    591                 StringBuffer sb = new StringBuffer(); 
     596                StringBuilder sb = new StringBuilder(); 
    592597                sb.append("TimeLine={"); 
    593598                if(!sl.isEmpty()){ 
     
    601606        } 
    602607 
    603         public boolean isReadied(){ 
     608        public boolean validate() throws InvalidBaseObjectException{ 
    604609                boolean ready = true; 
    605                 ready &= hasInitialSinger() && getInitialSinger().isReadied(); 
     610                ready &= hasInitialSinger() && getInitialSinger().validate(); 
    606611                Long ticks[] = getTicks(); 
    607612                for(int i = 0; i < ticks.length; i++){ 
    608                         ready &= getEventBPTime(ticks[i]).isReadied(); 
     613                        ready &= getEventBPTime(ticks[i]).validate(); 
     614                } 
     615                if(!ready){ 
     616                        throw new InvalidBaseObjectException(this); 
    609617                } 
    610618                return ready; 
    611619        } 
    612620 
    613         public int compareTo(ImmutableObject obj){ 
     621        public int compareTo(BaseObject obj){ 
    614622                TimeLine timeLine = (TimeLine)obj; 
    615623                return compare(getInitialSinger(), timeLine.getInitialSinger()); 
    616624        } 
    617625 
    618         public TimeLine over(Object obj, boolean fill, boolean has){ 
     626        public TimeLine over(BaseObject obj, boolean fill, boolean has){ 
    619627                TimeLine timeLine = ((TimeLine)obj).clone(); 
    620628                if(timeLine.hasInitialSinger()){ 
     
    872880        } 
    873881 
    874         public static TimeLine load(String file) throws Exception{ 
    875                 return (TimeLine)ImmutableObject.load(file); 
    876         } 
    877  
    878         public static TimeLine load(File file) throws Exception{ 
    879                 return (TimeLine)ImmutableObject.load(file); 
    880         } 
    881  
    882         public void store(String file) throws Exception{ 
     882        public static TimeLine load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     883                return (TimeLine)BaseObject.load(file); 
     884        } 
     885 
     886        public static TimeLine load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     887                return (TimeLine)BaseObject.load(file); 
     888        } 
     889 
     890        public void store(String file) throws FileNotFoundException, IOException{ 
    883891                super.store(file); 
    884892        } 
    885893 
    886         public void store(File file) throws Exception{ 
     894        public void store(File file) throws FileNotFoundException, IOException{ 
    887895                super.store(file); 
    888896        } 
    889897 
    890         public static TimeLine unzip(String file) throws Exception{ 
    891                 return (TimeLine)ImmutableObject.unzip(file); 
    892         } 
    893  
    894         public static TimeLine unzip(File file) throws Exception{ 
    895                 return (TimeLine)ImmutableObject.unzip(file); 
    896         } 
    897  
    898         public void zip(String file) throws Exception{ 
     898        public static TimeLine unzip(String file) throws IOException, ClassNotFoundException{ 
     899                return (TimeLine)BaseObject.unzip(file); 
     900        } 
     901 
     902        public static TimeLine unzip(File file) throws IOException, ClassNotFoundException{ 
     903                return (TimeLine)BaseObject.unzip(file); 
     904        } 
     905 
     906        public void zip(String file) throws IOException{ 
    899907                super.zip(file); 
    900908        } 
    901909 
    902         public void zip(File file) throws Exception{ 
     910        public void zip(File file) throws IOException{ 
    903911                super.zip(file); 
    904912        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/VSQFile.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.decode; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.encode; 
    5 import static org.rayflood.mikuvat.io.VSQDecoder.setSectionBracket; 
    6  
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.setSectionBracket; 
     4 
     5import java.io.BufferedReader; 
    76import java.io.File; 
     7import java.io.FileNotFoundException; 
     8import java.io.IOException; 
     9import java.io.StringReader; 
     10import java.nio.charset.Charset; 
    811import java.util.ArrayList; 
     12import java.util.LinkedHashMap; 
    913import java.util.List; 
    1014import java.util.Map; 
    11  
    12 import javax.sound.midi.MidiEvent; 
    13 import javax.sound.midi.MidiSystem; 
     15import java.util.regex.Pattern; 
     16 
     17import javax.sound.midi.InvalidMidiDataException; 
    1418import javax.sound.midi.Sequence; 
    15 import javax.sound.midi.Track; 
    16  
    17 public class VSQFile extends ImmutableObject{ 
     19 
     20import org.rayflood.mikuvat.io.BaseObject; 
     21import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     22import org.rayflood.mikuvat.io.midi.MidiData; 
     23import org.rayflood.mikuvat.io.midi.MidiFile; 
     24import org.rayflood.mikuvat.io.midi.MidiMeta; 
     25import org.rayflood.mikuvat.io.midi.MidiTrack; 
     26 
     27public class VSQFile extends MidiFile{ 
    1828        private static final long serialVersionUID = -6314152290164983853L; 
     29        public static final Pattern MMHEADER = Pattern.compile("^DM:\\d+:"); 
     30        public static final Charset WIN31J = Charset.forName("Windows-31J"); 
     31        public static final Pattern SECTIONLINE = Pattern.compile("^\\[.+\\]$"); 
     32        public static final int TEXTLENGTH = 119; 
    1933        public static final String COMMON = "Common"; 
    2034        public static final String MASTER = "Master"; 
     
    2236        public static final String EVENTLIST = "EventList"; 
    2337 
    24         private File vsqFile; 
    25         private Integer fileType; 
    26         private Float divisionType; 
    27         private Integer resolution; 
    28         private MidiTrack conductor; 
    2938        private MasterSection master; 
    3039        private MixerSection mixer; 
    3140        private ArrayList<VSQTrack> tracks; 
    3241 
    33         public VSQFile(String vsq) throws Exception{ 
     42        public VSQFile(String vsq) throws IOException, InvalidMidiDataException{ 
    3443                this(); 
    35                 readVSQFile(vsq); 
    36         } 
    37  
    38         public VSQFile(File vsq) throws Exception{ 
     44                readMidiFile(vsq); 
     45                setVSQSequence(getMidiTracks()); 
     46        } 
     47 
     48        public VSQFile(File vsq) throws IOException, InvalidMidiDataException{ 
    3949                this(); 
    40                 readVSQFile(vsq); 
    41         } 
    42  
    43         public VSQFile(Sequence sq) throws Exception{ 
     50                readMidiFile(vsq); 
     51                setVSQSequence(getMidiTracks()); 
     52        } 
     53 
     54        public VSQFile(Sequence sq) throws IOException{ 
    4455                this(); 
    45                 setVSQSequence(sq); 
    46         } 
    47  
    48         public void readVSQFile(String vsq) throws Exception{ 
     56                setMidiSequence(sq); 
     57                setVSQSequence(getMidiTracks()); 
     58        } 
     59 
     60        public void readVSQFile(String vsq) throws IOException, InvalidMidiDataException{ 
    4961                readVSQFile(new File(vsq)); 
    5062        } 
    5163 
    52         public void readVSQFile(File vsq) throws Exception{ 
    53                 setVsqFile(vsq); 
    54                 setVSQSequence(MidiSystem.getSequence(getVsqFile())); 
    55         } 
    56  
    57         public void writeVSQFile() throws Exception{ 
     64        public void readVSQFile(File vsq) throws IOException, InvalidMidiDataException{ 
     65                super.readMidiFile(vsq); 
     66                setVSQSequence(getMidiTracks()); 
     67        } 
     68 
     69        public void writeVSQFile() throws IOException, InvalidMidiDataException, InvalidBaseObjectException{ 
    5870                writeVSQFile(getVsqFile()); 
    5971        } 
    6072 
    61         public void writeVSQFile(String vsq) throws Exception{ 
     73        public void writeVSQFile(String vsq) throws IOException, InvalidMidiDataException, InvalidBaseObjectException{ 
    6274                writeVSQFile(new File(vsq)); 
    6375        } 
    6476 
    65         public void writeVSQFile(File vsq) throws Exception{ 
    66                 MidiSystem.write(getVSQSequence(), getFileType(), vsq); 
    67         } 
    68  
    69         public void setVSQSequence(Sequence sq) throws Exception{ 
    70                 setFileType(MidiSystem.getMidiFileTypes(sq)[0]); 
    71                 setDivisionType(sq.getDivisionType()); 
    72                 setResolution(sq.getResolution()); 
    73                 Track t[] = sq.getTracks(); 
    74                 setConductor(t[0]); 
    75  
    76                 Map<String, List<String>> sections = decode(t[1]); 
     77        public void writeVSQFile(File vsq) throws IOException, InvalidMidiDataException, InvalidBaseObjectException{ 
     78                setMidiTracks(getVSQSequence()); 
     79                super.writeMidiFile(vsq); 
     80        } 
     81 
     82        public Map<String, List<String>> decode(List<MidiData> md) throws IOException{ 
     83                List<Byte> v = new ArrayList<Byte>(); 
     84                for(int i = 0; i < md.size(); i++){ 
     85                        MidiData m = md.get(i); 
     86                        if(m instanceof MidiMeta){ 
     87                                byte b[] = ((MidiMeta)m).getData(); 
     88                                if(b.length == 0){ 
     89                                        continue; 
     90                                } 
     91                                String mmheader = new String(b); 
     92                                String[] ss = MMHEADER.split(mmheader, 2); 
     93                                if(ss.length > 1){ 
     94                                        for(int k = mmheader.indexOf(ss[1]); k < b.length; k++){ 
     95                                                if(b[k] != 0x00){ 
     96                                                        v.add(b[k]); 
     97                                                } 
     98                                        } 
     99                                } 
     100                        } 
     101                } 
     102                byte b[] = new byte[v.size()]; 
     103                for(int i = 0; i < v.size(); i++){ 
     104                        b[i] = v.get(i); 
     105                } 
     106                String textevent = new String(b, WIN31J); 
     107                System.out.println(textevent); 
     108 
     109                Map<String, List<String>> sections = new LinkedHashMap<String, List<String>>(); 
     110                BufferedReader br = new BufferedReader(new StringReader(textevent)); 
     111                String bf; 
     112                String sn = ""; 
     113                List<String> sv = new ArrayList<String>(); 
     114                do{ 
     115                        bf = br.readLine(); 
     116                        if(bf == null || SECTIONLINE.matcher(bf).matches()){ 
     117                                if(sn.length() > 0 && !sections.containsKey(sn)){ 
     118                                        sections.put(sn.substring(1, sn.length() - 1), sv); 
     119                                } 
     120                                sn = bf; 
     121                                sv = new ArrayList<String>(); 
     122                        } 
     123                        else if(bf.length() > 0){ 
     124                                sv.add(bf); 
     125                        } 
     126                }while(bf != null); 
     127 
     128                return sections; 
     129        } 
     130 
     131        public List<MidiData> encode(List<String> trackSections){ 
     132                String te = ""; 
     133                for(int i = 0; i < trackSections.size(); i++){ 
     134                        String vts = trackSections.get(i); 
     135                        te += vts + "\n"; 
     136                } 
     137 
     138                List<MidiData> tme = new ArrayList<MidiData>(); 
     139                byte b[] = te.getBytes(WIN31J); 
     140                for(int j = 0; j <= b.length / TEXTLENGTH; j++){ 
     141                        int h = (int)StrictMath.ceil((double)Integer.toString(j).length() / 4.0); 
     142                        String mef = "DM:%0" + h * 4 + "d:"; 
     143                        byte header[] = String.format(mef, j).getBytes(WIN31J); 
     144                        List<Byte> mbl = new ArrayList<Byte>(); 
     145                        for(int k = 0; k < header.length; k++){ 
     146                                mbl.add(header[k]); 
     147                        } 
     148                        for(int k = 0; k < TEXTLENGTH; k++){ 
     149                                int bi = j * TEXTLENGTH + k; 
     150                                if(bi >= b.length){ 
     151                                        break; 
     152                                } 
     153                                mbl.add(b[bi]); 
     154                        } 
     155                        byte mb[] = new byte[mbl.size()]; 
     156                        for(int k = 0; k < mbl.size(); k++){ 
     157                                mb[k] = mbl.get(k); 
     158                        } 
     159                        tme.add(new MidiMeta(1, mb)); 
     160                } 
     161 
     162                return tme; 
     163        } 
     164 
     165        public void setVSQSequence(ArrayList<MidiTrack> t) throws IOException{ 
     166                Map<String, List<String>> sections = decode(t.get(0).getMidiData(0L)); 
    77167                setMaster(new MasterSection(sections.get(MASTER))); 
    78168                setMixer(new MixerSection(sections.get(MIXER))); 
    79                 addTrack(new VSQTrack(t[1].get(0), getMixerSetting(0), sections)); 
    80                 for(int i = 2; i < t.length; i++){ 
    81                         addTrack(new VSQTrack(t[i].get(0), getMixerSetting(i - 1), decode(t[i]))); 
    82                 } 
    83         } 
    84  
    85         public Sequence getVSQSequence() throws Exception{ 
    86                 Sequence sq = new Sequence(getDivisionType(), getResolution()); 
    87                 Track mt = sq.createTrack(); 
    88                 getConductor(mt); 
     169                addVSQTrack(new VSQTrack(getMixerSetting(0), sections)); 
     170                for(int i = 1; i < t.size(); i++){ 
     171                        addVSQTrack(new VSQTrack(getMixerSetting(i), decode(t.get(i).getMidiData(0L)))); 
     172                } 
     173        } 
     174 
     175        public ArrayList<MidiTrack> getVSQSequence() throws InvalidBaseObjectException{ 
     176                ArrayList<MidiTrack> t = new ArrayList<MidiTrack>(); 
    89177 
    90178                List<List<String>> tsections = getVSQText(); 
    91                 for(int i = 0; i < getTrackSize(); i++){ 
    92                         VSQTrack vt = getTrack(i); 
    93                         Track t = sq.createTrack(); 
    94                         t.add(vt.getTrackNameME()); 
    95                         List<MidiEvent> me = encode(tsections.get(i)); 
    96                         for(int j = 0; j < me.size(); j++){ 
    97                                 t.add(me.get(j)); 
    98                         } 
    99                 } 
    100  
    101                 return sq; 
    102         } 
    103  
    104         public List<List<String>> getVSQText() throws Exception{ 
    105                 if(!isReadied()){ 
    106                         throw new Exception(); 
    107                 } 
     179                for(int i = 0; i < getVSQTrackSize(); i++){ 
     180                        MidiTrack mt = new MidiTrack(); 
     181                        mt.setMidiData(0L, encode(tsections.get(i))); 
     182                        t.add(mt); 
     183                } 
     184 
     185                return t; 
     186        } 
     187 
     188        public List<List<String>> getVSQText() throws InvalidBaseObjectException{ 
     189                validate(); 
    108190 
    109191                List<List<String>> tcommons = new ArrayList<List<String>>(); 
    110192                List<List<String>> ttimelines = new ArrayList<List<String>>(); 
    111                 for(int i = 0; i < getTrackSize(); i++){ 
    112                         VSQTrack vt = getTrack(i); 
     193                for(int i = 0; i < getVSQTrackSize(); i++){ 
     194                        VSQTrack vt = getVSQTrack(i); 
    113195                        tcommons.add(vt.getCommon().getSection()); 
    114196                        ttimelines.add(vt.getTimeLine().getSectionFast()); 
     
    128210                vsqtext.add(sections); 
    129211 
    130                 for(int i = 1; i < getTrackSize(); i++){ 
     212                for(int i = 1; i < getVSQTrackSize(); i++){ 
    131213                        sections = new ArrayList<String>(); 
    132214                        sections.add(setSectionBracket(COMMON)); 
     
    164246        } 
    165247 
    166         public int getTrackSize(){ 
     248        public int getVSQTrackSize(){ 
    167249                return tracks.size(); 
    168250        } 
    169251 
    170         public void addTrack(VSQTrack vt){ 
     252        public void addVSQTrack(VSQTrack vt){ 
    171253                if(vt == null || vt.isDeleted()){ 
    172254                        return; 
     
    175257        } 
    176258 
    177         public void addTrack(int index, VSQTrack vt){ 
     259        public void addVSQTrack(int index, VSQTrack vt){ 
    178260                if(vt == null || vt.isDeleted()){ 
    179261                        return; 
    180262                } 
    181                 if(index < getTrackSize()){ 
     263                if(index < getVSQTrackSize()){ 
    182264                        tracks.add(index, vt); 
    183265                } 
    184266                else{ 
    185                         addTrack(vt); 
    186                 } 
    187         } 
    188  
    189         public void setTrack(int index, VSQTrack vt){ 
     267                        addVSQTrack(vt); 
     268                } 
     269        } 
     270 
     271        public void setVSQTrack(int index, VSQTrack vt){ 
    190272                if(vt == null || vt.isDeleted()){ 
    191                         removeTrack(index); 
    192                         return; 
    193                 } 
    194                 if(index < getTrackSize()){ 
     273                        removeVSQTrack(index); 
     274                        return; 
     275                } 
     276                if(index < getVSQTrackSize()){ 
    195277                        tracks.set(index, vt); 
    196278                } 
    197279                else{ 
    198                         addTrack(vt); 
    199                 } 
    200         } 
    201  
    202         public VSQTrack getTrack(int index){ 
    203                 if(index < getTrackSize()){ 
     280                        addVSQTrack(vt); 
     281                } 
     282        } 
     283 
     284        public VSQTrack getVSQTrack(int index){ 
     285                if(index < getVSQTrackSize()){ 
    204286                        return tracks.get(index); 
    205287                } 
     
    209291        } 
    210292 
    211         public VSQTrack removeTrack(int index){ 
    212                 if(index < getTrackSize()){ 
     293        public VSQTrack removeVSQTrack(int index){ 
     294                if(index < getVSQTrackSize()){ 
    213295                        return tracks.remove(index); 
    214296                } 
     
    223305                        sl.add("VsqFile=" + getVsqFileS()); 
    224306                } 
    225                 if(hasFileType()){ 
    226                         sl.add("FileType=" + getFileType()); 
    227                 } 
    228                 if(hasDivisionType()){ 
    229                         sl.add("DivisionType=" + getDivisionType()); 
    230                 } 
    231                 if(hasResolution()){ 
    232                         sl.add("Resolution=" + getResolution()); 
    233                 } 
    234                 if(hasConductor()){ 
    235                         sl.add("Conductor={" + getConductor().toString() + "}"); 
    236                 } 
    237307                if(hasMaster()){ 
    238308                        sl.add("Master={" + getMaster().toString() + "}"); 
     
    241311                        sl.add("Mixer={" + getMixer().toString() + "}"); 
    242312                } 
    243                 if(hasTracks()){ 
    244                         StringBuffer sb = new StringBuffer(); 
    245                         sb.append(getTrack(0).toString()); 
    246                         for(int i = 1; i < getTrackSize(); i++){ 
    247                                 sb.append("," + getTrack(i).toString()); 
     313                if(hasVSQTracks()){ 
     314                        StringBuilder sb = new StringBuilder(); 
     315                        sb.append(getVSQTrack(0).toString()); 
     316                        for(int i = 1; i < getVSQTrackSize(); i++){ 
     317                                sb.append("," + getVSQTrack(i).toString()); 
    248318                        } 
    249319                        sl.add("Tracks=[" + sb.toString() + "]"); 
    250320                } 
    251321 
    252                 StringBuffer sb = new StringBuffer(); 
     322                StringBuilder sb = new StringBuilder(); 
     323                sb.append(super.toString()); 
     324 
    253325                sb.append("VSQFile={"); 
    254326                if(!sl.isEmpty()){ 
     
    262334        } 
    263335 
    264         public boolean isReadied(){ 
    265                 boolean ready = true; 
    266                 ready &= hasFileType(); 
    267                 ready &= hasDivisionType(); 
    268                 ready &= hasResolution(); 
    269                 ready &= hasConductor() && getConductor().isReadied(); 
    270                 ready &= hasMaster() && getMaster().isReadied(); 
    271                 ready &= hasMixer() && getMixer().isReadied(); 
    272                 for(int i = 0; i < getTrackSize(); i++){ 
    273                         ready &= getTrack(i).isReadied(); 
     336        public boolean validate() throws InvalidBaseObjectException{ 
     337                boolean ready = super.validate(); 
     338                ready &= hasMaster() && getMaster().validate(); 
     339                ready &= hasMixer() && getMixer().validate(); 
     340                for(int i = 0; i < getVSQTrackSize(); i++){ 
     341                        ready &= getVSQTrack(i).validate(); 
     342                } 
     343                if(!ready){ 
     344                        throw new InvalidBaseObjectException(this); 
    274345                } 
    275346                return ready; 
    276347        } 
    277348 
    278         public int compareTo(ImmutableObject obj){ 
    279                 VSQFile vsqFile = (VSQFile)obj; 
    280                 return compare(getVsqFile().getPath(), vsqFile.getVsqFile().getPath()); 
    281         } 
    282  
    283         public VSQFile over(Object obj, boolean fill, boolean has){ 
     349        public VSQFile over(BaseObject obj, boolean fill, boolean has){ 
     350                super.over(obj, fill, has); 
    284351                VSQFile vsqFile = ((VSQFile)obj).clone(); 
    285                 if(vsqFile.hasFileType() && (fill || has == hasFileType())){ 
    286                         setFileType(vsqFile.getFileType()); 
    287                 } 
    288                 if(vsqFile.hasDivisionType() && (fill || has == hasDivisionType())){ 
    289                         setDivisionType(vsqFile.getDivisionType()); 
    290                 } 
    291                 if(vsqFile.hasResolution() && (fill || has == hasResolution())){ 
    292                         setResolution(vsqFile.getResolution()); 
    293                 } 
    294                 if(vsqFile.hasConductor()){ 
    295                         MidiTrack conductor = hasConductor() ? getConductor() : new MidiTrack(); 
    296                         setConductor(conductor.over(vsqFile.getConductor(), fill, has)); 
    297                 } 
    298352                if(vsqFile.hasMaster()){ 
    299353                        MasterSection master = hasMaster() ? getMaster() : new MasterSection(); 
     
    304358                        setMixer(mixer.over(vsqFile.getMixer(), fill, has)); 
    305359                } 
    306                 for(int i = 0; i < vsqFile.getTracks().size(); i++){ 
    307                         VSQTrack vt = getTrack(i); 
    308                         setTrack(i, vt.over(vsqFile.getTrack(i), fill, has)); 
    309                 } 
    310                 if(vsqFile.hasVsqFile() && (fill || has == hasVsqFile())){ 
    311                         setVsqFile(vsqFile.getVsqFile()); 
     360                for(int i = 0; i < vsqFile.getVSQTracks().size(); i++){ 
     361                        VSQTrack vt = getVSQTrack(i); 
     362                        setVSQTrack(i, vt.over(vsqFile.getVSQTrack(i), fill, has)); 
    312363                } 
    313364                return this; 
     
    315366 
    316367        public VSQFile setDefault(){ 
    317                 setFileType(1); 
    318                 setDivisionType(0.0f); 
    319                 setResolution(480); 
    320                 setConductor(new MidiTrack()); 
     368                super.setDefault(); 
    321369                setMaster(MasterSection.getDefault()); 
    322370                setMixer(MixerSection.getDefault()); 
    323                 deleteTracks(); 
    324                 addTrack(VSQTrack.getDefault()); 
    325                 deleteVsqFile(); 
     371                deleteVSQTracks(); 
     372                addVSQTrack(VSQTrack.getDefault()); 
    326373                return this; 
    327374        } 
     
    334381 
    335382        public VSQFile delete(){ 
    336                 deleteFileType(); 
    337                 deleteDivisionType(); 
    338                 deleteResolution(); 
    339                 deleteConductor(); 
     383                super.delete(); 
    340384                deleteMaster(); 
    341385                deleteMixer(); 
    342                 deleteTracks(); 
    343                 deleteVsqFile(); 
     386                deleteVSQTracks(); 
    344387                return this; 
    345388        } 
    346389 
    347390        public boolean isDeleted(){ 
    348                 boolean has = false; 
    349                 has |= hasFileType(); 
    350                 has |= hasDivisionType(); 
    351                 has |= hasResolution(); 
    352                 has |= hasConductor(); 
     391                boolean has = super.isDeleted(); 
    353392                has |= hasMaster(); 
    354393                has |= hasMixer(); 
    355                 has |= hasTracks(); 
    356                 has |= hasVsqFile(); 
     394                has |= hasVSQTracks(); 
    357395                return !has; 
    358396        } 
    359397 
    360398        public VSQFile(){ 
     399                super(); 
    361400                delete(); 
    362401        } 
    363402 
    364403        public File getVsqFile(){ 
    365                 return vsqFile; 
     404                return getMidiFile(); 
    366405        } 
    367406 
     
    371410 
    372411        public void setVsqFile(File vsqFile){ 
    373                 this.vsqFile = vsqFile; 
     412                setMidiFile(vsqFile); 
    374413        } 
    375414 
     
    379418 
    380419        public void deleteVsqFile(){ 
    381                 vsqFile = null; 
     420                deleteMidiFile(); 
    382421        } 
    383422 
    384423        public boolean hasVsqFile(){ 
    385                 return vsqFile != null; 
    386         } 
    387  
    388         public Integer getFileType(){ 
    389                 return fileType; 
    390         } 
    391  
    392         public void setFileType(Integer fileType){ 
    393                 this.fileType = fileType; 
    394         } 
    395  
    396         public void deleteFileType(){ 
    397                 fileType = null; 
    398         } 
    399  
    400         public boolean hasFileType(){ 
    401                 return fileType != null; 
    402         } 
    403  
    404         public Float getDivisionType(){ 
    405                 return divisionType; 
    406         } 
    407  
    408         public void setDivisionType(Float divisionType){ 
    409                 this.divisionType = divisionType; 
    410         } 
    411  
    412         public void deleteDivisionType(){ 
    413                 divisionType = null; 
    414         } 
    415  
    416         public boolean hasDivisionType(){ 
    417                 return divisionType != null; 
    418         } 
    419  
    420         public Integer getResolution(){ 
    421                 return resolution; 
    422         } 
    423  
    424         public void setResolution(Integer resolution){ 
    425                 this.resolution = resolution; 
    426         } 
    427  
    428         public void deleteResolution(){ 
    429                 resolution = null; 
    430         } 
    431  
    432         public boolean hasResolution(){ 
    433                 return resolution != null; 
    434         } 
    435  
    436         public MidiTrack getConductor(){ 
    437                 return conductor; 
    438         } 
    439  
    440         public void getConductor(Track t) throws Exception{ 
    441                 conductor.getTrack(t); 
    442         } 
    443  
    444         public void setConductor(MidiTrack conductor){ 
    445                 if(conductor == null || conductor.isDeleted()){ 
    446                         deleteConductor(); 
    447                         return; 
    448                 } 
    449                 this.conductor = conductor; 
    450         } 
    451  
    452         public void setConductor(Track t){ 
    453                 this.conductor = new MidiTrack(t); 
    454         } 
    455  
    456         public void deleteConductor(){ 
    457                 conductor = null; 
    458         } 
    459  
    460         public boolean hasConductor(){ 
    461                 return conductor != null; 
     424                return hasMidiFile(); 
    462425        } 
    463426 
     
    502465        } 
    503466 
    504         public ArrayList<VSQTrack> getTracks(){ 
     467        public ArrayList<VSQTrack> getVSQTracks(){ 
    505468                return tracks; 
    506469        } 
    507470 
    508         public void setTracks(ArrayList<VSQTrack> tracks){ 
     471        public void setVSQTracks(ArrayList<VSQTrack> tracks){ 
    509472                if(tracks == null){ 
    510                         deleteTracks(); 
     473                        deleteVSQTracks(); 
    511474                        return; 
    512475                } 
     
    514477        } 
    515478 
    516         public void deleteTracks(){ 
    517                 setTracks(new ArrayList<VSQTrack>()); 
    518         } 
    519  
    520         public boolean hasTracks(){ 
     479        public void deleteVSQTracks(){ 
     480                setVSQTracks(new ArrayList<VSQTrack>()); 
     481        } 
     482 
     483        public boolean hasVSQTracks(){ 
    521484                return !tracks.isEmpty(); 
    522485        } 
     
    526489        } 
    527490 
    528         public static VSQFile load(String file) throws Exception{ 
    529                 return (VSQFile)ImmutableObject.load(file); 
    530         } 
    531  
    532         public static VSQFile load(File file) throws Exception{ 
    533                 return (VSQFile)ImmutableObject.load(file); 
    534         } 
    535  
    536         public void store(String file) throws Exception{ 
     491        public static VSQFile load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     492                return (VSQFile)BaseObject.load(file); 
     493        } 
     494 
     495        public static VSQFile load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     496                return (VSQFile)BaseObject.load(file); 
     497        } 
     498 
     499        public void store(String file) throws FileNotFoundException, IOException{ 
    537500                super.store(file); 
    538501        } 
    539502 
    540         public void store(File file) throws Exception{ 
     503        public void store(File file) throws FileNotFoundException, IOException{ 
    541504                super.store(file); 
    542505        } 
    543506 
    544         public static VSQFile unzip(String file) throws Exception{ 
    545                 return (VSQFile)ImmutableObject.unzip(file); 
    546         } 
    547  
    548         public static VSQFile unzip(File file) throws Exception{ 
    549                 return (VSQFile)ImmutableObject.unzip(file); 
    550         } 
    551  
    552         public void zip(String file) throws Exception{ 
     507        public static VSQFile unzip(String file) throws IOException, ClassNotFoundException{ 
     508                return (VSQFile)BaseObject.unzip(file); 
     509        } 
     510 
     511        public static VSQFile unzip(File file) throws IOException, ClassNotFoundException{ 
     512                return (VSQFile)BaseObject.unzip(file); 
     513        } 
     514 
     515        public void zip(String file) throws IOException{ 
    553516                super.zip(file); 
    554517        } 
    555518 
    556         public void zip(File file) throws Exception{ 
     519        public void zip(File file) throws IOException{ 
    557520                super.zip(file); 
    558521        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/VSQTrack.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.WIN31J; 
    4 import static org.rayflood.mikuvat.io.VSQFile.COMMON; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.io.vsq.VSQFile.COMMON; 
    54 
    65import java.io.File; 
     6import java.io.FileNotFoundException; 
     7import java.io.IOException; 
    78import java.util.ArrayList; 
    89import java.util.List; 
    910import java.util.Map; 
    1011 
    11 import javax.sound.midi.MetaMessage; 
    12 import javax.sound.midi.MidiEvent; 
    13  
    14 public class VSQTrack extends ImmutableObject{ 
     12import org.rayflood.mikuvat.io.BaseObject; 
     13import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     14 
     15public class VSQTrack extends BaseObject{ 
    1516        private static final long serialVersionUID = 6296614810415852578L; 
    16         private String trackName; 
    1717        private CommonSection common; 
    1818        private MixerSetting mixer; 
    1919        private TimeLine timeLine; 
    2020 
    21         public VSQTrack(MidiEvent trackName, MixerSetting mixer, Map<String, List<String>> sections){ 
     21        public VSQTrack(MixerSetting mixer, Map<String, List<String>> sections){ 
    2222                this(); 
    23                 setTrack(trackName, mixer, sections); 
    24         } 
    25  
    26         public VSQTrack(String trackName, MixerSetting mixer, Map<String, List<String>> sections){ 
    27                 this(); 
    28                 setTrack(trackName, mixer, sections); 
     23                setTrack(mixer, sections); 
    2924        } 
    3025 
     
    3429        } 
    3530 
    36         public void setTrack(MidiEvent trackName, MixerSetting mixer, Map<String, List<String>> sections){ 
     31        public void setTrack(MixerSetting mixer, Map<String, List<String>> sections){ 
    3732                setMixer(mixer); 
    3833                setTrack(sections); 
    39                 setTrackName(trackName); 
    40         } 
    41  
    42         public void setTrack(String trackName, MixerSetting mixer, Map<String, List<String>> sections){ 
    43                 setMixer(mixer); 
    44                 setTrack(sections); 
    45                 setTrackName(trackName); 
    4634        } 
    4735 
     
    5341        public String toString(){ 
    5442                List<String> sl = new ArrayList<String>(); 
    55                 if(hasTrackName()){ 
    56                         sl.add("TrackName=" + getTrackName()); 
    57                 } 
    5843                if(hasCommon()){ 
    5944                        sl.add("Common={" + getCommon().toString() + "}"); 
     
    6651                } 
    6752 
    68                 StringBuffer sb = new StringBuffer(); 
     53                StringBuilder sb = new StringBuilder(); 
    6954                sb.append("VSQTrack={"); 
    7055                if(!sl.isEmpty()){ 
     
    7863        } 
    7964 
    80         public boolean isReadied(){ 
     65        public boolean validate() throws InvalidBaseObjectException{ 
    8166                boolean ready = true; 
    82                 ready &= hasTrackName(); 
    83                 ready &= hasCommon() && getCommon().isReadied(); 
    84                 ready &= hasMixer() && getMixer().isReadied(); 
    85                 ready &= hasTimeLine() && getTimeLine().isReadied(); 
     67                ready &= hasCommon() && getCommon().validate(); 
     68                ready &= hasMixer() && getMixer().validate(); 
     69                ready &= hasTimeLine() && getTimeLine().validate(); 
     70                if(!ready){ 
     71                        throw new InvalidBaseObjectException(this); 
     72                } 
    8673                return ready; 
    8774        } 
    8875 
    89         public int compareTo(ImmutableObject obj){ 
     76        public int compareTo(BaseObject obj){ 
    9077                VSQTrack vsqTrack = (VSQTrack)obj; 
    91                 return compare(this.getTrackName(), vsqTrack.getTrackName()); 
    92         } 
    93  
    94         public VSQTrack over(Object obj, boolean fill, boolean has){ 
     78                return compare(getCommon().getName(), vsqTrack.getCommon().getName()); 
     79        } 
     80 
     81        public VSQTrack over(BaseObject obj, boolean fill, boolean has){ 
    9582                VSQTrack vsqTrack = ((VSQTrack)obj).clone(); 
    9683                if(vsqTrack.hasCommon()){ 
     
    10592                        TimeLine timeLine = hasTimeLine() ? getTimeLine() : new TimeLine(); 
    10693                        setTimeLine(timeLine.over(vsqTrack.getTimeLine(), fill, has)); 
    107                 } 
    108                 if(vsqTrack.hasTrackName() && (fill || has == hasTrackName())){ 
    109                         setTrackName(vsqTrack.getTrackName()); 
    11094                } 
    11195                return this; 
     
    126110 
    127111        public VSQTrack delete(){ 
    128                 deleteTrackName(); 
    129112                deleteCommon(); 
    130113                deleteMixer(); 
     
    135118        public boolean isDeleted(){ 
    136119                boolean has = false; 
    137                 has |= hasTrackName(); 
    138120                has |= hasCommon(); 
    139121                has |= hasMixer(); 
     
    146128        } 
    147129 
    148         public String getTrackName(){ 
    149                 return trackName; 
    150         } 
    151  
    152         public MidiEvent getTrackNameME() throws Exception{ 
    153                 byte mb[] = getTrackName().getBytes(WIN31J); 
    154                 MetaMessage mm = new MetaMessage(); 
    155                 mm.setMessage(1, mb, mb.length); 
    156                 return new MidiEvent(mm, 0); 
    157         } 
    158  
    159         public void setTrackName(String trackName){ 
    160                 this.trackName = trackName; 
    161         } 
    162  
    163         public void setTrackName(MidiEvent trackName){ 
    164                 MetaMessage mm = (MetaMessage)trackName.getMessage(); 
    165                 setTrackName(new String(mm.getData(), WIN31J)); 
    166         } 
    167  
    168         public void deleteTrackName(){ 
    169                 trackName = null; 
    170         } 
    171  
    172         public boolean hasTrackName(){ 
    173                 return trackName != null; 
    174         } 
    175  
    176130        public CommonSection getCommon(){ 
    177131                return common; 
     
    184138                } 
    185139                this.common = common; 
    186                 setTrackName(common.getName()); 
    187140        } 
    188141 
     
    239192        } 
    240193 
    241         public static VSQTrack load(String file) throws Exception{ 
    242                 return (VSQTrack)ImmutableObject.load(file); 
    243         } 
    244  
    245         public static VSQTrack load(File file) throws Exception{ 
    246                 return (VSQTrack)ImmutableObject.load(file); 
    247         } 
    248  
    249         public void store(String file) throws Exception{ 
     194        public static VSQTrack load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     195                return (VSQTrack)BaseObject.load(file); 
     196        } 
     197 
     198        public static VSQTrack load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     199                return (VSQTrack)BaseObject.load(file); 
     200        } 
     201 
     202        public void store(String file) throws FileNotFoundException, IOException{ 
    250203                super.store(file); 
    251204        } 
    252205 
    253         public void store(File file) throws Exception{ 
     206        public void store(File file) throws FileNotFoundException, IOException{ 
    254207                super.store(file); 
    255208        } 
    256209 
    257         public static VSQTrack unzip(String file) throws Exception{ 
    258                 return (VSQTrack)ImmutableObject.unzip(file); 
    259         } 
    260  
    261         public static VSQTrack unzip(File file) throws Exception{ 
    262                 return (VSQTrack)ImmutableObject.unzip(file); 
    263         } 
    264  
    265         public void zip(String file) throws Exception{ 
     210        public static VSQTrack unzip(String file) throws IOException, ClassNotFoundException{ 
     211                return (VSQTrack)BaseObject.unzip(file); 
     212        } 
     213 
     214        public static VSQTrack unzip(File file) throws IOException, ClassNotFoundException{ 
     215                return (VSQTrack)BaseObject.unzip(file); 
     216        } 
     217 
     218        public void zip(String file) throws IOException{ 
    266219                super.zip(file); 
    267220        } 
    268221 
    269         public void zip(File file) throws Exception{ 
     222        public void zip(File file) throws IOException{ 
    270223                super.zip(file); 
    271224        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/VibratoBP.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
     1package org.rayflood.mikuvat.io.vsq; 
    22 
    3 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.getBigDecimalString; 
     3import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
     4import static org.rayflood.mikuvat.Utilities.getBigDecimalString; 
    55 
    66import java.io.File; 
     7import java.io.FileNotFoundException; 
     8import java.io.IOException; 
    79import java.math.BigDecimal; 
    810 
    9 public class VibratoBP extends ImmutableObject{ 
     11import org.rayflood.mikuvat.io.BaseObject; 
     12 
     13public class VibratoBP extends BaseObject{ 
    1014        private static final long serialVersionUID = -1542047841867886356L; 
    1115        public static final BigDecimal X_MAX = new BigDecimal("1.0"); 
     
    3337        } 
    3438 
    35         public boolean isReadied(){ 
     39        public boolean validate(){ 
    3640                return true; 
    3741        } 
    3842 
    39         public int compareTo(ImmutableObject obj){ 
     43        public int compareTo(BaseObject obj){ 
    4044                VibratoBP bp = (VibratoBP)obj; 
    4145                int c = compare(getX(), bp.getX()); 
     
    4650        } 
    4751 
    48         public VibratoBP over(Object obj, boolean fill, boolean has){ 
     52        public VibratoBP over(BaseObject obj, boolean fill, boolean has){ 
    4953                VibratoBP vibratoBP = ((VibratoBP)obj).clone(); 
    5054                setX(vibratoBP.getX()); 
     
    112116        } 
    113117 
    114         public static VibratoBP load(String file) throws Exception{ 
    115                 return (VibratoBP)ImmutableObject.load(file); 
     118        public static VibratoBP load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     119                return (VibratoBP)BaseObject.load(file); 
    116120        } 
    117121 
    118         public static VibratoBP load(File file) throws Exception{ 
    119                 return (VibratoBP)ImmutableObject.load(file); 
     122        public static VibratoBP load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     123                return (VibratoBP)BaseObject.load(file); 
    120124        } 
    121125 
    122         public void store(String file) throws Exception{ 
     126        public void store(String file) throws FileNotFoundException, IOException{ 
    123127                super.store(file); 
    124128        } 
    125129 
    126         public void store(File file) throws Exception{ 
     130        public void store(File file) throws FileNotFoundException, IOException{ 
    127131                super.store(file); 
    128132        } 
    129133 
    130         public static VibratoBP unzip(String file) throws Exception{ 
    131                 return (VibratoBP)ImmutableObject.unzip(file); 
     134        public static VibratoBP unzip(String file) throws IOException, ClassNotFoundException{ 
     135                return (VibratoBP)BaseObject.unzip(file); 
    132136        } 
    133137 
    134         public static VibratoBP unzip(File file) throws Exception{ 
    135                 return (VibratoBP)ImmutableObject.unzip(file); 
     138        public static VibratoBP unzip(File file) throws IOException, ClassNotFoundException{ 
     139                return (VibratoBP)BaseObject.unzip(file); 
    136140        } 
    137141 
    138         public void zip(String file) throws Exception{ 
     142        public void zip(String file) throws IOException{ 
    139143                super.zip(file); 
    140144        } 
    141145 
    142         public void zip(File file) throws Exception{ 
     146        public void zip(File file) throws IOException{ 
    143147                super.zip(file); 
    144148        } 
  • trunk/src/org/rayflood/mikuvat/io/vsq/VibratoHandle.java

    r2 r4  
    1 package org.rayflood.mikuvat.io; 
    2  
    3 import static org.rayflood.mikuvat.io.VSQDecoder.SPLITCOMMA; 
    4 import static org.rayflood.mikuvat.io.VSQDecoder.adjustMaxMin; 
    5 import static org.rayflood.mikuvat.io.VSQDecoder.getBigDecimalString; 
    6 import static org.rayflood.mikuvat.io.VSQDecoder.getVibratoBPList; 
    7 import static org.rayflood.mikuvat.io.VSQDecoder.getVibratoBPMap; 
    8 import static org.rayflood.mikuvat.io.VSQDecoder.splitEqual; 
     1package org.rayflood.mikuvat.io.vsq; 
     2 
     3import static org.rayflood.mikuvat.Utilities.SPLITCOMMA; 
     4import static org.rayflood.mikuvat.Utilities.adjustMaxMin; 
     5import static org.rayflood.mikuvat.Utilities.getBigDecimalString; 
     6import static org.rayflood.mikuvat.Utilities.getVibratoBPList; 
     7import static org.rayflood.mikuvat.Utilities.getVibratoBPMap; 
     8import static org.rayflood.mikuvat.Utilities.splitEqual; 
    99 
    1010import java.io.File; 
     11import java.io.FileNotFoundException; 
     12import java.io.IOException; 
    1113import java.math.BigDecimal; 
    1214import java.util.ArrayList; 
     
    1416import java.util.TreeMap; 
    1517 
    16 public class VibratoHandle extends ImmutableObject{ 
     18import org.rayflood.mikuvat.io.BaseObject; 
     19import org.rayflood.mikuvat.io.InvalidBaseObjectException; 
     20 
     21public class VibratoHandle extends BaseObject{ 
    1722        private static final long serialVersionUID = 7575294004927556748L; 
    1823        public static final String ICONID = "IconID"; 
     
    208213                        TreeMap<BigDecimal, Integer> bps = getDepthBP(); 
    209214                        BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 
    210                         StringBuffer xsb = new StringBuffer(); 
    211                         StringBuffer ysb = new StringBuffer(); 
     215                        StringBuilder xsb = new StringBuilder(); 
     216                        StringBuilder ysb = new StringBuilder(); 
    212217                        xsb.append(getBigDecimalString(xs[0])); 
    213218                        ysb.append(bps.get(xs[0])); 
     
    224229                        TreeMap<BigDecimal, Integer> bps = getRateBP(); 
    225230                        BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 
    226                         StringBuffer xsb = new StringBuffer(); 
    227                         StringBuffer ysb = new StringBuffer(); 
     231                        StringBuilder xsb = new StringBuilder(); 
     232                        StringBuilder ysb = new StringBuilder(); 
    228233                        xsb.append(getBigDecimalString(xs[0])); 
    229234                        ysb.append(bps.get(xs[0])); 
     
    284289                        TreeMap<BigDecimal, Integer> bps = getDepthBP(); 
    285290                        BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 
    286                         StringBuffer xsb = new StringBuffer(); 
    287                         StringBuffer ysb = new StringBuffer(); 
     291                        StringBuilder xsb = new StringBuilder(); 
     292                        StringBuilder ysb = new StringBuilder(); 
    288293                        xsb.append(getBigDecimalString(xs[0])); 
    289294                        ysb.append(bps.get(xs[0])); 
     
    304309                        TreeMap<BigDecimal, Integer> bps = getRateBP(); 
    305310                        BigDecimal xs[] = bps.keySet().toArray(new BigDecimal[0]); 
    306                         StringBuffer xsb = new StringBuffer(); 
    307                         StringBuffer ysb = new StringBuffer(); 
     311                        StringBuilder xsb = new StringBuilder(); 
     312                        StringBuilder ysb = new StringBuilder(); 
    308313                        xsb.append(getBigDecimalString(xs[0])); 
    309314                        ysb.append(bps.get(xs[0])); 
     
    316321                } 
    317322 
    318                 StringBuffer sb = new StringBuffer(); 
     323                StringBuilder sb = new StringBuilder(); 
    319324                sb.append("VibratoHandle={"); 
    320325                if(!sl.isEmpty()){ 
     
    328333        } 
    329334 
    330         public boolean isReadied(){ 
     335        public boolean validate() throws InvalidBaseObjectException{ 
    331336                boolean ready = true; 
    332337                ready &= hasIconID(); 
     
    342347                ready &= hasRateBPNum(); 
    343348                ready &= (getRateBPNum() == getRateBP().size()); 
     349                if(!ready){ 
     350                        throw new InvalidBaseObjectException(this); 
     351                } 
    344352                return ready; 
    345353        } 
    346354 
    347         public int compareTo(ImmutableObject obj){ 
     355        public int compareTo(BaseObject obj){ 
    348356                VibratoHandle vibratoHandle = (VibratoHandle)obj; 
    349357                int c = compare(getIconID(), vibratoHandle.getIconID()); 
     
    354362        } 
    355363 
    356         public VibratoHandle over(Object obj, boolean fill, boolean has){ 
     364        public VibratoHandle over(BaseObject obj, boolean fill, boolean has){ 
    357365                VibratoHandle vibratoHandle = ((VibratoHandle)obj).clone(); 
    358366                if(vibratoHandle.hasIconID() && (fill || has == hasIconID())){ 
     
    717725        } 
    718726 
    719         public static VibratoHandle load(String file) throws Exception{ 
    720                 return (VibratoHandle)ImmutableObject.load(file); 
    721         } 
    722  
    723         public static VibratoHandle load(File file) throws Exception{ 
    724                 return (VibratoHandle)ImmutableObject.load(file); 
    725         } 
    726  
    727         public void store(String file) throws Exception{ 
     727        public static VibratoHandle load(String file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     728                return (VibratoHandle)BaseObject.load(file); 
     729        } 
     730 
     731        public static VibratoHandle load(File file) throws FileNotFoundException, IOException, ClassNotFoundException{ 
     732                return (VibratoHandle)BaseObject.load(file); 
     733        } 
     734 
     735        public void store(String file) throws FileNotFoundException, IOException{ 
    728736                super.store(file); 
    729737        } 
    730738 
    731         public void store(File file) throws Exception{ 
     739        public void store(File file) throws FileNotFoundException, IOException{ 
    732740                super.store(file); 
    733741        } 
    734742 
    735         public static VibratoHandle unzip(String file) throws Exception{ 
    736                 return (VibratoHandle)ImmutableObject.unzip(file); 
    737         } 
    738  
    739         public static VibratoHandle unzip(File file) throws Exception{ 
    740                 return (VibratoHandle)ImmutableObject.unzip(file); 
    741         } 
    742  
    743         public void zip(String file) throws Exception{ 
     743        public static VibratoHandle unzip(String file) throws IOException, ClassNotFoundException{ 
     744                return (VibratoHandle)BaseObject.unzip(file); 
     745        } 
     746 
     747        public static VibratoHandle unzip(File file) throws IOException, ClassNotFoundException{ 
     748                return (VibratoHandle)BaseObject.unzip(file); 
     749        } 
     750 
     751        public void zip(String file) throws IOException{ 
    744752                super.zip(file); 
    745753        } 
    746754 
    747         public void zip(File file) throws Exception{ 
     755        public void zip(File file) throws IOException{ 
    748756                super.zip(file); 
    749757        } 
  • trunk/src/org/rayflood/mikuvat/plugin/PluginLoader.java

    r2 r4  
    3131                                String plugin = man.getMainAttributes().getValue("Mikuvat-Plugin"); 
    3232                                float version = new Float(MIKUVAT_VERSION); 
    33                                 float reqver = new Float(man.getMainAttributes().getValue("Mikuvat-Require-Version")); 
    34                                 if(plugin != null && !plugin.isEmpty() && version >= reqver){ 
     33                                String mins = man.getMainAttributes().getValue("Mikuvat-Min-Version"); 
     34                                float min = (mins == null) ? Float.MIN_VALUE: new Float(mins); 
     35                                String maxs = man.getMainAttributes().getValue("Mikuvat-Max-Version"); 
     36                                float max = (maxs == null) ? Float.MAX_VALUE: new Float(maxs); 
     37                                if(plugin != null && !plugin.isEmpty() && version >= min && version <= max){ 
    3538                                        pluginclasses.add(plugin); 
    3639                                        urls.add(pluginfiles[i].toURI().toURL()); 
     
    3841                        } 
    3942                        catch(Exception e){ 
     43                                System.out.println("プラグイン読み込み失敗! 無視します。" + pluginfiles[i].getPath()); 
    4044                                e.printStackTrace(); 
    4145                        } 
     
    5660                        } 
    5761                        catch(Exception e){ 
     62                                System.out.println("ライブラリ読み込み失敗! 無視します。" + libfiles[i].getPath()); 
    5863                                e.printStackTrace(); 
    5964                        }