OSDN Git Service

Java5で動作するように修正。(1.6で導入されたメソッドを削除)
authoryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Mon, 24 May 2010 05:17:32 +0000 (05:17 +0000)
committeryuki <yuki@bdf3b611-c98c-6041-8292-703d9c9adbe7>
Mon, 24 May 2010 05:17:32 +0000 (05:17 +0000)
git-svn-id: http://192.168.11.7/svn/repository/NicoBrowser/trunk@320 bdf3b611-c98c-6041-8292-703d9c9adbe7

nbproject/build-impl.xml
nbproject/genfiles.properties
nbproject/groovy-build.xml
nbproject/project.properties
nbproject/project.xml
src/nicobrowser/Config.java
src/nicobrowser/NicoHttpClient.java
src/nicobrowser/update/DBUpdater.java

index 4ebb80e..0569b54 100644 (file)
@@ -56,6 +56,43 @@ is divided into following sections:
         <property file="nbproject/project.properties"/>\r
     </target>\r
     <target depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property" name="-do-init">\r
+        <j2seproject1:property name="platform.home" value="platforms.${platform.active}.home"/>\r
+        <j2seproject1:property name="platform.bootcp" value="platforms.${platform.active}.bootclasspath"/>\r
+        <j2seproject1:property name="platform.compiler" value="platforms.${platform.active}.compile"/>\r
+        <j2seproject1:property name="platform.javac.tmp" value="platforms.${platform.active}.javac"/>\r
+        <condition property="platform.javac" value="${platform.home}/bin/javac">\r
+            <equals arg1="${platform.javac.tmp}" arg2="$${platforms.${platform.active}.javac}"/>\r
+        </condition>\r
+        <property name="platform.javac" value="${platform.javac.tmp}"/>\r
+        <j2seproject1:property name="platform.java.tmp" value="platforms.${platform.active}.java"/>\r
+        <condition property="platform.java" value="${platform.home}/bin/java">\r
+            <equals arg1="${platform.java.tmp}" arg2="$${platforms.${platform.active}.java}"/>\r
+        </condition>\r
+        <property name="platform.java" value="${platform.java.tmp}"/>\r
+        <j2seproject1:property name="platform.javadoc.tmp" value="platforms.${platform.active}.javadoc"/>\r
+        <condition property="platform.javadoc" value="${platform.home}/bin/javadoc">\r
+            <equals arg1="${platform.javadoc.tmp}" arg2="$${platforms.${platform.active}.javadoc}"/>\r
+        </condition>\r
+        <property name="platform.javadoc" value="${platform.javadoc.tmp}"/>\r
+        <condition property="platform.invalid" value="true">\r
+            <or>\r
+                <contains string="${platform.javac}" substring="$${platforms."/>\r
+                <contains string="${platform.java}" substring="$${platforms."/>\r
+                <contains string="${platform.javadoc}" substring="$${platforms."/>\r
+            </or>\r
+        </condition>\r
+        <fail unless="platform.home">Must set platform.home</fail>\r
+        <fail unless="platform.bootcp">Must set platform.bootcp</fail>\r
+        <fail unless="platform.java">Must set platform.java</fail>\r
+        <fail unless="platform.javac">Must set platform.javac</fail>\r
+        <fail if="platform.invalid">\r
+ The J2SE Platform is not correctly set up.\r
+ Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. \r
+ Either open the project in the IDE and setup the Platform with the same name or add it manually.\r
+ For example like this:\r
+     ant -Duser.properties.file=&lt;path_to_property_file&gt; jar (where you put the property "platforms.${platform.active}.home" in a .properties file)\r
+  or ant -Dplatforms.${platform.active}.home=&lt;path_to_JDK_home&gt; jar (where no properties file is used) \r
+  </fail>\r
         <available file="${manifest.file}" property="manifest.available"/>\r
         <condition property="main.class.available">\r
             <and>\r
@@ -157,7 +194,6 @@ is divided into following sections:
         <condition else="" property="endorsed.classpath.cmd.line.arg" value="-Xbootclasspath/p:'${toString:endorsed.classpath.path}'">\r
             <length length="0" string="${endorsed.classpath}" when="greater"/>\r
         </condition>\r
-        <property name="javac.fork" value="false"/>\r
     </target>\r
     <target name="-post-init">\r
         <!-- Empty placeholder for easier customization. -->\r
@@ -198,7 +234,7 @@ is divided into following sections:
             <sequential>\r
                 <property location="${build.dir}/empty" name="empty.dir"/>\r
                 <mkdir dir="${empty.dir}"/>\r
-                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" fork="${javac.fork}" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
+                <javac debug="@{debug}" deprecation="${javac.deprecation}" destdir="@{destdir}" encoding="${source.encoding}" excludes="@{excludes}" executable="${platform.javac}" fork="yes" includeantruntime="false" includes="@{includes}" source="${javac.source}" sourcepath="@{sourcepath}" srcdir="@{srcdir}" target="${javac.target}" tempdir="${java.io.tmpdir}">\r
                     <src>\r
                         <dirset dir="@{gensrcdir}" erroronmissingdir="false">\r
                             <include name="*"/>\r
@@ -247,7 +283,7 @@ is divided into following sections:
             <attribute default="${excludes}" name="excludes"/>\r
             <attribute default="**" name="testincludes"/>\r
             <sequential>\r
-                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" showoutput="true" tempdir="${build.dir}">\r
+                <junit dir="${work.dir}" errorproperty="tests.failed" failureproperty="tests.failed" fork="true" jvm="${platform.java}" showoutput="true" tempdir="${build.dir}">\r
                     <batchtest todir="${build.test.results.dir}">\r
                         <fileset dir="${test.src.dir}" excludes="@{excludes},${excludes}" includes="@{includes}">\r
                             <filename name="@{testincludes}"/>\r
@@ -278,6 +314,9 @@ is divided into following sections:
                     <classpath>\r
                         <path path="@{classpath}"/>\r
                     </classpath>\r
+                    <bootclasspath>\r
+                        <path path="${platform.bootcp}"/>\r
+                    </bootclasspath>\r
                 </nbjpdastart>\r
             </sequential>\r
         </macrodef>\r
@@ -293,7 +332,9 @@ is divided into following sections:
         </macrodef>\r
     </target>\r
     <target name="-init-debug-args">\r
-        <property name="version-output" value="java version &quot;${ant.java.version}"/>\r
+        <exec executable="${platform.java}" outputproperty="version-output">\r
+            <arg value="-version"/>\r
+        </exec>\r
         <condition property="have-jdk-older-than-1.4">\r
             <or>\r
                 <contains string="${version-output}" substring="java version &quot;1.0"/>\r
@@ -318,7 +359,7 @@ is divided into following sections:
             <attribute default="${debug.classpath}" name="classpath"/>\r
             <element name="customize" optional="true"/>\r
             <sequential>\r
-                <java classname="@{classname}" dir="${work.dir}" fork="true">\r
+                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">\r
                     <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
                     <jvmarg line="${debug-args-line}"/>\r
                     <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>\r
@@ -343,7 +384,7 @@ is divided into following sections:
             <attribute default="${run.classpath}" name="classpath"/>\r
             <element name="customize" optional="true"/>\r
             <sequential>\r
-                <java classname="@{classname}" dir="${work.dir}" fork="true">\r
+                <java classname="@{classname}" dir="${work.dir}" fork="true" jvm="${platform.java}">\r
                     <jvmarg line="${endorsed.classpath.cmd.line.arg}"/>\r
                     <jvmarg value="-Dfile.encoding=${runtime.encoding}"/>\r
                     <redirector errorencoding="${runtime.encoding}" inputencoding="${runtime.encoding}" outputencoding="${runtime.encoding}"/>\r
@@ -468,7 +509,7 @@ is divided into following sections:
             <path path="${run.classpath}"/>\r
             <map from="${build.classes.dir.resolved}" to="${dist.jar.resolved}"/>\r
         </pathconvert>\r
-        <echo>java -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>\r
+        <echo>${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class}</echo>\r
     </target>\r
     <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class+mkdist.available" name="-do-jar-with-libraries">\r
         <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>\r
@@ -493,7 +534,7 @@ is divided into following sections:
         </copylibs>\r
         <echo>To run this application from the command line without Ant, try:</echo>\r
         <property location="${dist.jar}" name="dist.jar.resolved"/>\r
-        <echo>java -jar "${dist.jar.resolved}"</echo>\r
+        <echo>${platform.java} -jar "${dist.jar.resolved}"</echo>\r
     </target>\r
     <target depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+mkdist.available" name="-do-jar-with-libraries-without-mainclass" unless="main.class.available">\r
         <property location="${build.classes.dir}" name="build.classes.dir.resolved"/>\r
@@ -613,7 +654,7 @@ is divided into following sections:
             -->\r
     <target depends="init" name="-javadoc-build">\r
         <mkdir dir="${dist.javadoc.dir}"/>\r
-        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">\r
+        <javadoc additionalparam="${javadoc.additionalparam}" author="${javadoc.author}" charset="UTF-8" destdir="${dist.javadoc.dir}" docencoding="UTF-8" encoding="${javadoc.encoding.used}" executable="${platform.javadoc}" failonerror="true" noindex="${javadoc.noindex}" nonavbar="${javadoc.nonavbar}" notree="${javadoc.notree}" private="${javadoc.private}" source="${javac.source}" splitindex="${javadoc.splitindex}" use="${javadoc.use}" useexternalfile="true" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}">\r
             <classpath>\r
                 <path path="${javac.classpath}"/>\r
             </classpath>\r
index 02a1c70..b46c7a1 100644 (file)
@@ -1,11 +1,11 @@
-build.xml.data.CRC32=d1b53a37\r
+build.xml.data.CRC32=4e83c611\r
 build.xml.script.CRC32=02aac843\r
-build.xml.stylesheet.CRC32=958a1d3e@1.26.2.45\r
+build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45\r
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.\r
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.\r
-nbproject/build-impl.xml.data.CRC32=d1b53a37\r
-nbproject/build-impl.xml.script.CRC32=5e9e1e09\r
+nbproject/build-impl.xml.data.CRC32=4e83c611\r
+nbproject/build-impl.xml.script.CRC32=555d6525\r
 nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45\r
-nbproject/groovy-build.xml.data.CRC32=d1b53a37\r
-nbproject/groovy-build.xml.script.CRC32=542f299d\r
-nbproject/groovy-build.xml.stylesheet.CRC32=4de8406b@1.9.1\r
+nbproject/groovy-build.xml.data.CRC32=4e83c611\r
+nbproject/groovy-build.xml.script.CRC32=e12d80ae\r
+nbproject/groovy-build.xml.stylesheet.CRC32=4de8406b@1.11.1\r
index ae01434..4ce48b9 100644 (file)
@@ -29,7 +29,7 @@
                     <classpath>\r
                         <path path="@{classpath}"/>\r
                     </classpath>\r
-                    <javac debug="@{debug}" deprecation="${javac.deprecation}" encoding="${source.encoding}" source="${javac.source}" target="${javac.target}">\r
+                    <javac debug="@{debug}" deprecation="${javac.deprecation}" encoding="${source.encoding}" source="${javac.source}" target="${javac.target}" fork="yes" executable="${platform.javac}" tempdir="${java.io.tmpdir}">\r
                         <compilerarg line="${javac.compilerargs} ${javac.compilerargs.jaxws}"/>\r
                         <customize/>\r
                     </javac>\r
index 072ac2d..9ece101 100644 (file)
@@ -82,7 +82,7 @@ libs.Rome.classpath=../../../java/commons/rome-0.9/rome-0.9.jar;../../../java/co
 main.class=nicobrowser.main.Main\r
 manifest.file=manifest.mf\r
 meta.inf.dir=${src.dir}/META-INF\r
-platform.active=default_platform\r
+platform.active=JDK_1.5\r
 run.classpath=\\r
     ${javac.classpath}:\\r
     ${build.classes.dir}\r
index 7fcdea1..1171b01 100644 (file)
@@ -13,6 +13,7 @@
         <data xmlns="http://www.netbeans.org/ns/j2se-project/3">\r
             <name>NicoBrowser</name>\r
             <minimum-ant-version>1.6.5</minimum-ant-version>\r
+            <explicit-platform explicit-source-supported="true"/>\r
             <source-roots>\r
                 <root id="src.dir"/>\r
             </source-roots>\r
index ff2a954..2e0b89e 100644 (file)
@@ -13,6 +13,7 @@ import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -104,7 +105,7 @@ public final class Config {
      * @param p 新規プロパティ.
      * @throws IOException
      */
-    public void updateConfigFile(Configuration p) throws IOException {
+    public void updateConfigFile(Configuration p) throws ConfigurationException {
         updatePropertyValue(p, P_NICOVIDEO_MAIL);
         updatePropertyValue(p, P_NICOVIDEO_PASSWORD);
         updatePropertyValue(p, P_FILE_ENCODING);
@@ -121,11 +122,7 @@ public final class Config {
 
         updatePropertyValueArray(p, P_DOWNLOAD_MYLIST);
 
-        try {
-            properties.save();
-        } catch (ConfigurationException ex) {
-            throw new IOException(ex);
-        }
+        properties.save();
     }
 
     /**
@@ -243,11 +240,11 @@ public final class Config {
         return properties.getString(P_SAVEFILE_PATTERN, "{title}");
     }
 
-    public String getFileNameReplaceFrom(){
+    public String getFileNameReplaceFrom() {
         return properties.getString(P_SAVEFILE_REPLACE_FROM, "/\\:*?\"<>|.");
     }
 
-    public String getFileNameReplaceTo(){
+    public String getFileNameReplaceTo() {
         return properties.getString(P_SAVEFILE_REPLACE_TO, "_");
     }
 
@@ -292,7 +289,7 @@ public final class Config {
             List lines = FileUtils.readLines(FEEDURL_FILE, getEncoding());
             for (Object line : lines) {
                 final String str = line.toString();
-                if (str.isEmpty() || str.startsWith("#")) {
+                if (StringUtils.isEmpty(str) || str.startsWith("#")) {
                     // 空行, コメント行はスキップ.
                     continue;
                 }
index 557f605..7c1ba30 100644 (file)
@@ -678,15 +678,15 @@ public class NicoHttpClient {
         return getFlvFile(vi, vi.getRealVideoId(), Status.GET_INFO, true, ProgressListener.EMPTY_LISTENER);
     }
 
-    public File getCommentFile(VideoInfo vi, String fileName) throws IOException {
+    public File getCommentFile(VideoInfo vi, String fileName) throws Exception {
         return downloadComment(vi, fileName, false);
     }
 
-    public File getTCommentFile(VideoInfo vi, String fileName) throws IOException {
+    public File getTCommentFile(VideoInfo vi, String fileName) throws Exception {
         return downloadComment(vi, fileName, true);
     }
 
-    private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm) throws IOException {
+    private File downloadComment(VideoInfo vi, String fileName, boolean isTcomm) throws Exception {
         HttpResponse response = null;
         BufferedOutputStream bos = null;
 
@@ -710,7 +710,7 @@ public class NicoHttpClient {
 
             return new File(outputFileName);
         } catch (Exception e) {
-            throw new IOException("コメントダウンロードに失敗しました。", e);
+            throw new Exception("コメントダウンロードに失敗しました。", e);
         } finally {
             if (response != null) {
                 response.getEntity().consumeContent();
index 407eaec..ce6199c 100644 (file)
@@ -29,7 +29,7 @@ public class DBUpdater {
      * これの回避策としてファイル名を固定した.
      * 既存のカラム値をこの固定名にアップデートする.
      */
-    public void sync_for_4() throws IOException {
+    public void sync_for_4() throws Exception {
         try {
             Class.forName("org.h2.Driver");
             Connection con = DriverManager.getConnection("jdbc:h2:" + Config.getInstance().getDbFile(), "sa", "");
@@ -43,11 +43,11 @@ public class DBUpdater {
             log.info("DBのアップデートが終了しました.");
         } catch (Exception ex) {
             log.fatal("DBのアップデートに失敗しました.", ex);
-            throw new IOException(ex);
+            throw ex;
         }
     }
 
-    public void sync() throws IOException {
+    public void sync() throws Exception {
         sync_for_4();
 
         File updateFile = new File(Config.getAppHome(), UPDATE_FILE);
@@ -67,11 +67,11 @@ public class DBUpdater {
             log.info("DBのアップデートが終了しました.");
         } catch (CommandLineParsingException ex) {
             log.fatal("DBのアップデートに失敗しました.", ex);
-            throw new IOException(ex);
+            throw ex;
         }
     }
 
-    public void update() throws IOException {
+    public void update() throws Exception {
         File updateFile = new File(Config.getAppHome(), UPDATE_FILE);
         InputStream resource = ClassLoader.getSystemResourceAsStream("resources/" + UPDATE_FILE);
 
@@ -89,7 +89,7 @@ public class DBUpdater {
             log.info("DBのアップデートが終了しました.");
         } catch (CommandLineParsingException ex) {
             log.fatal("DBのアップデートに失敗しました.", ex);
-            throw new IOException(ex);
+            throw ex;
         }
     }