Пример #1
0
  public boolean _GetRdReserve() {

    setErrmsg(MSGID + "予約一覧取得は無効です。");

    final String sysDir = getUser();
    final String iniFile = sysDir + File.separator + "TVTest.ini";

    File d = new File(sysDir);
    if (!d.exists() || !d.isDirectory()) {
      String msg = ERRID + "指定のディレクトリがみつからないか、あるいはディレクトリではありません:" + sysDir;
      setErrmsg(msg);
      // System.out.println(msg);
      return (false);
    }

    String DriverDirectory = null;
    ArrayList<String> Drivers = new ArrayList<String>();
    String buf = CommonUtils.read4file(iniFile, false, "Unicode");
    if (buf == null) {
      String msg = ERRID + "設定ファイルが取得できませんでした:" + iniFile;
      setErrmsg(msg);
      // System.out.println(msg);
      return false;
    }

    String[] sa = buf.split("[\r\n]+");
    for (String str : sa) {
      Matcher ma = Pattern.compile("^DriverDirectory=(.+?)\\s*$", Pattern.DOTALL).matcher(str);
      if (ma.find()) {
        DriverDirectory = ma.group(1);
        if (getDebug()) System.out.println(DBGID + "ドライバーディレクトリの取得: " + ma.group(1));
        continue;
      }
      ma = Pattern.compile("^Driver=(.+?)\\.dll").matcher(str);
      if (ma.find()) {
        Drivers.add(ma.group(1));
        if (getDebug()) System.out.println(DBGID + "ドライバーの追加: " + ma.group(1));
        continue;
      }
      ma = Pattern.compile("^Driver\\d+_FileName=(.+?)\\.dll").matcher(str);
      if (ma.find()) {
        Drivers.add(ma.group(1));
        if (getDebug()) System.out.println(DBGID + "ドライバーの追加: " + ma.group(1));
        continue;
      }
    }

    for (String Driver : Drivers) {
      String ch2File = null;
      if (Driver.contains(File.separator)) {
        ch2File = Driver + ".ch2";
      } else {
        ch2File = DriverDirectory + File.separator + Driver + ".ch2";
      }
      File f = new File(ch2File);
      if (!f.exists() || !f.isFile()) {
        String msg = ERRID + "チャンネル設定ファイルがみつかりません:" + ch2File;
        setErrmsg(msg);
        // System.out.println(msg);
        continue;
      }

      buf = CommonUtils.read4file(ch2File, false, thisEncoding);
      if (buf == null) {
        String msg = ERRID + "チャンネル設定ファイルが取得できませんでした:" + ch2File;
        setErrmsg(msg);
        // System.out.println(msg);
        return false;
      }

      sa = buf.split("[\r\n]+");
      for (String str : sa) {
        if (str.startsWith(";")) {
          continue;
        }

        String[] da = str.split(",");
        if (da.length < 4) {
          continue;
        }

        if (da[7].equals("17168") || da[7].equals("17169")) {
          da[0] = "臨)" + da[0];
        }

        String val = text2value(chvalue, da[0]);
        if (val == null || val.length() == 0) {
          TextValueSet tn;

          String chid;
          try {
            chid =
                ContentIdEDCB.getChId(
                    Integer.valueOf(da[6]), Integer.valueOf(da[7]), Integer.valueOf(da[5]));
          } catch (NumberFormatException e) {
            String msg = ERRID + "iniファイルの内容が不正です:" + ch2File;
            setErrmsg(msg);
            // System.out.println(msg);
            return false;
          }
          tn = new TextValueSet();
          tn.setText(da[0]);
          tn.setValue(String.valueOf(Long.decode("0x" + chid)));
          chvalue.add(tn);

          tn = new TextValueSet();
          tn.setText(da[0]);
          tn.setValue(Driver + ".dll," + da[6] + ":" + da[7] + ":" + da[5]);
          chtype.add(tn);

          if (getDebug())
            System.out.println(DBGID + "設定の追加: " + tn.getText() + "=" + tn.getValue());
        }
      }
    }

    return (true);
  }