OSDN Git Service

1st commit
authorOlyutorskii <olyutorskii@users.osdn.me>
Fri, 8 Oct 2010 14:08:20 +0000 (23:08 +0900)
committerOlyutorskii <olyutorskii@users.osdn.me>
Fri, 8 Oct 2010 14:08:20 +0000 (23:08 +0900)
13 files changed:
.hgignore [new file with mode: 0644]
CHANGELOG.txt [new file with mode: 0644]
LICENSE.txt [new file with mode: 0644]
README.txt [new file with mode: 0644]
build.xml [new file with mode: 0644]
pom.xml [new file with mode: 0644]
src/main/assembly/descriptor.xml [new file with mode: 0644]
src/main/config/checks.xml [new file with mode: 0644]
src/main/config/pmdrules.xml [new file with mode: 0644]
src/main/java/jp/sourceforge/mikutoga/pmd2xml/Pmd2Xml.java [new file with mode: 0644]
src/main/java/jp/sourceforge/mikutoga/pmd2xml/XmlHandler.java [new file with mode: 0644]
src/main/java/jp/sourceforge/mikutoga/pmd2xml/package-info.java [new file with mode: 0644]
src/main/resources/jp/sourceforge/mikutoga/pmd2xml/resources/version.properties [new file with mode: 0644]

diff --git a/.hgignore b/.hgignore
new file mode 100644 (file)
index 0000000..14f3cd2
--- /dev/null
+++ b/.hgignore
@@ -0,0 +1,3 @@
+^nb-configuration\.xml$\r
+^nbactions\.xml$\r
+^target$\r
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
new file mode 100644 (file)
index 0000000..4aef713
--- /dev/null
@@ -0,0 +1,11 @@
+[UTF-8 Japanese]\r
+\r
+\r
+Pmd2XML 変更履歴\r
+\r
+\r
+1.101-SNAPSHOT (2010-10-07)\r
+    ・初回リリース。\r
+\r
+\r
+--- EOF ---\r
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644 (file)
index 0000000..5280b80
--- /dev/null
@@ -0,0 +1,34 @@
+[UTF-8 English & Japanese]\r
+\r
+The MIT License\r
+\r
+\r
+Copyright(c) 2010 olyutorskii\r
+\r
+\r
+Permission is hereby granted, free of charge, to any person obtaining a copy\r
+of this software and associated documentation files (the "Software"), to deal\r
+in the Software without restriction, including without limitation the rights\r
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
+copies of the Software, and to permit persons to whom the Software is\r
+furnished to do so, subject to the following conditions:\r
+\r
+The above copyright notice and this permission notice shall be included in\r
+all copies or substantial portions of the Software.\r
+\r
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r
+THE SOFTWARE.\r
+\r
+\r
+Pmd2XMLオリジナル制作者自身からのコメント:\r
+\r
+  ※ 少なくともこのソフトウェアの実行、複製、配布、改造は自由です。\r
+  ※ 少なくともこのソフトウェアは無保証です。\r
+\r
+\r
+--- EOF ---\r
diff --git a/README.txt b/README.txt
new file mode 100644 (file)
index 0000000..8d9f439
--- /dev/null
@@ -0,0 +1,80 @@
+[UTF-8 Japanese]\r
+\r
+                               P m d 2 X M L\r
+                                  Readme\r
+\r
+                                              Copyright(c) 2010 olyutorskii\r
+\r
+\r
+=== Pmd2XMLとは ===\r
+\r
+Pmd2XMLは、3D動画制作ツール、MikuMikuDance(MMD)で用いられる\r
+モデルデータファイル(*.pmd)の内容を、XML形式のデータファイルと交換するための\r
+アプリケーションです。\r
+Pmd2XMLは、MikuTogaプロジェクトの派生物として誕生しました。\r
+\r
+MikuTogaプロジェクトは、MMDによる3Dアニメーション制作を支援するプログラムの\r
+整備のために発足した、オープンソースプロジェクトです。\r
+\r
+Pmd2XMLは、同じMikuTogaプロジェクト内のTogaGemライブラリを用いて\r
+開発が進められています。\r
+\r
+※ MMD開発者の樋口M氏は、MikuTogaの開発活動に一切関与していません。\r
+  Pmd2XMLに関する問い合わせをを樋口M氏へ投げかけないように!約束だよ!\r
+\r
+\r
+=== 実行環境 ===\r
+\r
+ - Pmd2XMLはJava言語(JLS3)で記述されたプログラムです。\r
+ - Pmd2XMLはJRE1.6に準拠したJava実行環境で利用できるように作られています。\r
+   原則として、JRE1.6に準拠した実行系であれば、プラットフォームを選びません。\r
+\r
+\r
+=== アーカイブ管理体制 ===\r
+\r
+  このアーカイブは、UTF-8による開発環境を前提として構成されています。\r
+  このアーカイブの原本となる開発資産は、\r
+      http://hg.sourceforge.jp/view/mikutoga/Pmd2XML\r
+  を上位に持つMercurialリポジトリで管理されています。\r
+  アーカイブの代わりにMercurialを通じての開発資産へのアクセスが可能です。\r
+  # hg clone http://hg.sourceforge.jp/view/mikutoga/Pmd2XML\r
+\r
+\r
+=== 開発プロジェクト運営元 ===\r
+\r
+  http://sourceforge.jp/projects/mikutoga/ まで。\r
+\r
+\r
+=== ディレクトリ内訳構成 ===\r
+\r
+基本的にはMaven2のmaven-archetype-quickstart構成に準じます。\r
+\r
+./README.txt\r
+    あなたが今見てるこれ。\r
+\r
+./CHANGELOG.txt\r
+    変更履歴。\r
+\r
+./LICENSE.txt\r
+    ライセンスに関して。\r
+\r
+./pom.xml\r
+    Maven2用プロジェクト構成定義ファイル。\r
+\r
+./src/main/java/\r
+    Javaのソースコード。\r
+\r
+./src/test/java/\r
+    JUnit 4.* 用のユニットテストコード。\r
+\r
+./src/main/config/\r
+    各種ビルド・構成管理に必要なファイル群。\r
+\r
+./src/main/config/checks.xml\r
+    Checkstyle用configファイル。\r
+\r
+./src/main/config/pmdrules.xml\r
+    PMD用ルール定義ファイル。\r
+\r
+\r
+--- EOF ---\r
diff --git a/build.xml b/build.xml
new file mode 100644 (file)
index 0000000..15e4563
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!-- ====================================================================== -->
+<!-- Ant build file (http://ant.apache.org/) for Ant 1.6.2 or above.        -->
+<!-- ====================================================================== -->
+
+<project name="pmd2xml" default="package" basedir=".">
+
+<!-- ====================================================================== -->
+<!-- Import maven-build.xml into the current project                        -->
+<!-- Maven2 command "mvn ant:ant" will put maven-build.xml                  -->
+<!-- ====================================================================== -->
+
+    <import optional="true" file="maven-build.xml"/>
+
+<!-- ====================================================================== -->
+<!-- Help target                                                            -->
+<!-- ====================================================================== -->
+
+    <target name="help">
+        <echo message="Please run: $ant -projecthelp"/>
+    </target>
+
+<!-- ====================================================================== -->
+<!-- sanitize files for native environment                                  -->
+<!-- ====================================================================== -->
+
+    <target description="sanitize files" name="sanitize" >
+        <echo message="sanitize files..." />
+
+        <fixcrlf
+            srcDir="./src/" includes="**/*.java"
+            encoding="UTF-8" outputencoding="UTF-8"
+            tablength="4" tab="remove" javafiles="true"
+            eof="remove"
+        />
+
+        <fixcrlf
+            srcDir="./src/" includes="**/*.xml,**/*.xsd"
+            encoding="UTF-8" outputencoding="UTF-8"
+            tablength="8" tab="remove"
+            eol="lf"
+            eof="remove"
+        />
+
+        <fixcrlf
+            srcDir="./src/" includes="**/*.properties"
+            encoding="ISO-8859-1" outputencoding="ISO-8859-1"
+            eol="lf"
+            eof="remove"
+        />
+
+        <fixcrlf
+            srcDir="." includes="*.txt"
+            encoding="UTF-8" outputencoding="UTF-8"
+            tablength="8" tab="remove"
+            eof="remove"
+        />
+
+        <chmod type="file" perm="a-x">
+            <fileset dir="." includes="**/*" excludes="**/*.sh" />
+        </chmod>
+
+    </target>
+
+</project>
+
+<!-- EOF -->
diff --git a/pom.xml b/pom.xml
new file mode 100644 (file)
index 0000000..957c183
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,328 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    Pmd2XML
+    Maven2用プロジェクト構成定義ファイル
+-->
+
+<project
+  xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+  http://maven.apache.org/maven-v4_0_0.xsd"
+>
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>jp.sourceforge.mikutoga</groupId>
+    <artifactId>pmd2xml</artifactId>
+
+    <version>1.101-SNAPSHOT</version>
+
+    <packaging>jar</packaging>
+    <name>Pmd2XML</name>
+
+    <description><!--
+-->Pmd2XML<!--
+ -->
+    </description>
+
+    <url>http://sourceforge.jp/projects/mikutoga/</url>
+    <inceptionYear>2010</inceptionYear>
+
+    <organization>
+        <name>MikuToga Partners</name>
+        <url>http://sourceforge.jp/projects/mikutoga/</url>
+    </organization>
+
+    <licenses>
+        <license>
+            <name>The MIT License</name>
+            <url>http://www.opensource.org/licenses/mit-license.php</url>
+            <distribution>manual</distribution>
+        </license>
+    </licenses>
+
+    <developers>
+        <developer>
+            <id>olyutorskii</id>
+            <url>http://sites.google.com/site/olyutorskiipit/</url>
+            <organization>MikuToga Partners</organization>
+            <organizationUrl>http://sourceforge.jp/projects/mikutoga/devel/</organizationUrl>
+            <roles>
+                <role>Project Founder</role>
+                <role>Java Developer</role>
+            </roles>
+        </developer>
+    </developers>
+
+    <contributors/>
+    <mailingLists/>
+
+    <prerequisites>
+        <maven>2.1</maven>
+    </prerequisites>
+
+    <modules/>
+
+    <scm>
+        <connection>scm:hg:http://hg.sourceforge.jp/view/mikutoga/Pmd2XML</connection>
+        <developerConnection>scm:hg:ssh://hg.sourceforge.jp//hgroot/mikutoga/Pmd2XML</developerConnection>
+        <url>http://hg.sourceforge.jp/view/mikutoga/Pmd2XML</url>
+    </scm>
+
+    <issueManagement>
+        <system>SourceForge.JP</system>
+        <url>http://sourceforge.jp/projects/mikutoga/ticket/</url>
+    </issueManagement>
+
+    <ciManagement/>
+    <distributionManagement/>
+
+    <properties>
+        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
+
+        <maven.compiler.source>1.6</maven.compiler.source>
+        <maven.compiler.target>1.6</maven.compiler.target>
+
+        <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
+        <maven.compiler.showWarnings>true</maven.compiler.showWarnings>
+
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
+        <project.myrepoconf>${project.basedir}/src/main/config</project.myrepoconf>
+        <project.transformer>
+            org.apache.maven.plugins.shade.resource.ManifestResourceTransformer
+        </project.transformer>
+        <project.mainentry>jp.sourceforge.mikutoga.pmd2xml.Pmd2Xml</project.mainentry>
+    </properties>
+
+    <dependencyManagement/>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>[4,)</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>jp.sourceforge.mikutoga</groupId>
+            <artifactId>togagem</artifactId>
+            <version>1.104.2</version>
+            <scope>compile</scope>
+        </dependency>
+
+    </dependencies>
+
+    <repositories/>
+    <pluginRepositories/>
+
+    <build>
+        <pluginManagement/>
+
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.6</source>  <!-- for NetBeans IDE -->
+                    <target>1.6</target>
+                    <showDeprecation>true</showDeprecation>
+                    <showWarnings>true</showWarnings>
+                    <compilerArguments>
+                        <Xlint/>
+                    </compilerArguments>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-clean-plugin</artifactId>
+                <configuration>
+                    <filesets>
+                        <fileset>
+                            <directory>${project.basedir}</directory>
+                            <includes>
+                                <include>**/.DS_Store</include>
+                                <include>**/Thumbs.db</include>
+                                <include>**/core</include>
+                            </includes>
+                        </fileset>
+                    </filesets>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifestEntries>
+                            <Main-Class>${project.mainentry}</Main-Class>
+                            <Built-By>${project.organization.name}</Built-By>
+                        </manifestEntries>
+                    </archive>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <descriptors>
+                        <descriptor>src/main/assembly/descriptor.xml</descriptor>
+                    </descriptors>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                          <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <artifactSet>
+                                <includes>
+                                    <include>jp.sourceforge.mikutoga:togagem</include>
+                                </includes>
+                                <excludes>
+                                    <exclude>junit:junit</exclude>
+                                </excludes>
+                            </artifactSet>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-enforcer-plugin</artifactId>
+                <configuration>
+                    <rules>
+                        <requireMavenVersion>
+                            <version>[2.1,3)</version>
+                        </requireMavenVersion>
+                        <requireJavaVersion>
+                            <version>[1.6,)</version>
+                        </requireJavaVersion>
+                    </rules>
+                </configuration>
+            </plugin>
+
+        </plugins>
+
+        <resources>
+
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/version.properties</include>
+                </includes>
+            </resource>
+
+            <resource>
+                <directory>src/main/resources</directory>
+                <includes>
+                    <include>**/*.properties</include>
+                    <include>**/*.xsd</include>
+                    <include>**/*.dtd</include>
+                </includes>
+                <excludes>
+                    <exclude>**/version.properties</exclude>
+                </excludes>
+            </resource>
+
+        </resources>
+
+    </build>
+
+    <reporting>
+        <plugins>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.7</version>
+                <configuration>
+                    <show>protected</show>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <artifactId>maven-site-plugin</artifactId>
+                <version>2.1.1</version>
+                <configuration>
+                    <locales>ja</locales>
+                    <inputEncoding>${project.build.sourceEncoding}</inputEncoding>
+                    <outputEncoding>${project.reporting.outputEncoding}</outputEncoding>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-checkstyle-plugin</artifactId>
+                <version>2.5</version>
+                <configuration>
+                    <configLocation>${project.myrepoconf}/checks.xml</configLocation>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-pmd-plugin</artifactId>
+                <version>2.5</version>
+                <configuration>
+                    <sourceEncoding>UTF-8</sourceEncoding>
+                    <targetJdk>1.6</targetJdk>
+                    <rulesets>
+                        <ruleset>${project.myrepoconf}/pmdrules.xml</ruleset>
+                    </rulesets>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <version>2.3.1</version>
+                <configuration>
+                    <effort>Max</effort>
+                    <threshold>Low</threshold>
+                    <inputEncoding>${project.build.sourceEncoding}</inputEncoding>
+                    <outputEncoding>${project.reporting.outputEncoding}</outputEncoding>
+                    <!--excludeFilterFile/-->
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>cobertura-maven-plugin</artifactId>
+                <version>2.4</version>
+            </plugin>
+
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>javancss-maven-plugin</artifactId>
+                <version>2.0</version>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jxr-plugin</artifactId>
+                <version>2.2</version>
+            </plugin>
+
+        </plugins>
+    </reporting>
+
+</project>
+
+<!-- EOF -->
diff --git a/src/main/assembly/descriptor.xml b/src/main/assembly/descriptor.xml
new file mode 100644 (file)
index 0000000..b744cbd
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<assembly
+  xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
+  http://maven.apache.org/xsd/assembly-1.1.0.xsd"
+>
+
+<!--
+    SourceForge.JP用リリースファイル構成定義ファイル
+    Maven2 assembly用
+-->
+
+    <id>src</id>
+
+    <formats>
+        <format>zip</format>
+    </formats>
+
+    <fileSets>
+        <fileSet>
+            <includes>
+                <include>*.txt</include>
+                <include>pom.xml</include>
+                <include>build.xml</include>
+            </includes>
+            <useDefaultExcludes>true</useDefaultExcludes>
+        </fileSet>
+        <fileSet>
+            <directory>src/</directory>
+            <useDefaultExcludes>true</useDefaultExcludes>
+        </fileSet>
+    </fileSets>
+
+</assembly>
+
+<!-- EOF -->
diff --git a/src/main/config/checks.xml b/src/main/config/checks.xml
new file mode 100644 (file)
index 0000000..67da074
--- /dev/null
@@ -0,0 +1,367 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE module PUBLIC
+    "-//Puppy Crawl//DTD Check Configuration 1.2//EN"
+    "http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
+
+<!--
+    Checkstyle用チェック項目定義。
+
+    Checkstyle5.1以降向けに記述。
+
+    [ http://checkstyle.sourceforge.net/ ]
+
+    Copyright(c) 2010 olyutorskii
+-->
+
+
+<module name="Checker">
+
+    <property name="charset" value="UTF-8" />
+    <property name="severity" value="error" />
+
+
+    <!-- Duplicate Code -->
+    <module name="StrictDuplicateCode">
+        <property name="min" value="20" />
+    </module>
+
+
+    <!-- Headers -->
+    <module name="RegexpHeader">
+        <property name="header" value="^/\*$\n^ \*( .*)?$\n^ \*/$\n" />
+        <property name="multiLines" value="2" />
+    </module>
+
+
+    <!-- Javadoc Comments -->
+    <module name="JavadocPackage" />
+
+
+    <!-- Miscellaneous -->
+    <module name="NewlineAtEndOfFile" />
+    <module name="Translation" />
+
+
+    <!-- Regexp -->
+    <module name="RegexpSingleline">
+        <property name="format" value="\s+$" />
+        <property name="minimum" value="0" />
+        <property name="maximum" value="0" />
+    </module>
+
+
+    <!-- Size Violations -->
+    <module name="FileLength" />
+
+
+    <!-- Whitespace -->
+    <module name="FileTabCharacter" />
+
+
+<!-- Filters
+    <module name="SeverityMatchFilter" />
+    <module name="SuppressionFilter" />
+    <module name="SuppressionCommentFilter" />
+    <module name="SuppressWithNearbyCommentFilter" />
+-->
+
+
+    <module name="TreeWalker">
+
+        <property name="tabWidth" value="4" />
+
+
+    <!-- Annotations -->
+
+        <module name="AnnotationUseStyle" />
+        <module name="MissingDeprecated" />
+        <module name="MissingOverride" />
+        <module name="PackageAnnotation" />
+        <module name="SuppressWarnings" />
+
+
+    <!-- Block Checks -->
+
+        <module name="EmptyBlock" />
+        <module name="LeftCurly" />
+        <module name="NeedBraces">
+            <property name="tokens" value="LITERAL_DO" />
+        </module>
+        <module name="RightCurly" />
+        <module name="AvoidNestedBlocks" />
+
+
+    <!-- Class Design -->
+
+        <module name="VisibilityModifier" />
+        <module name="FinalClass" />
+        <module name="InterfaceIsType" />
+        <module name="HideUtilityClassConstructor" />
+<!--    <module name="DesignForExtension" />  -->
+        <module name="MutableException" />
+        <module name="ThrowsCount">
+            <property name="max" value="4" />
+        </module>
+
+
+    <!-- Coding -->
+
+        <module name="ArrayTrailingComma" />
+        <module name="AvoidInlineConditionals" />
+        <module name="CovariantEquals" />
+        <module name="DoubleCheckedLocking" />
+        <module name="EmptyStatement" />
+        <module name="EqualsAvoidNull" />
+        <module name="EqualsHashCode" />
+<!--    <module name="FinalLocalVariable" />  -->
+        <module name="HiddenField">
+            <property name="ignoreConstructorParameter" value="true" />
+            <property name="ignoreSetter" value="true" />
+            <property name="ignoreAbstractMethods" value="true" />
+        </module>
+        <module name="IllegalInstantiation">
+            <property
+                name="classes"
+                value="java.lang.Boolean, java.lang.Integer" />
+        </module>
+        <module name="IllegalToken">
+            <property name="tokens" value="LITERAL_NATIVE, STATIC_IMPORT" />
+        </module>
+        <module name="IllegalTokenText">
+            <property name="tokens" value="NUM_INT, NUM_LONG" />
+            <property name="format" value="^0[^lx]" />
+            <property name="ignoreCase" value="true" />
+        </module>
+        <module name="InnerAssignment" />
+        <module name="MagicNumber" />
+        <module name="MissingSwitchDefault" />
+        <module name="ModifiedControlVariable" />
+        <module name="RedundantThrows">
+            <property name="allowUnchecked" value="true" />
+            <property name="allowSubclasses" value="true" />
+        </module>
+        <module name="SimplifyBooleanExpression" />
+        <module name="SimplifyBooleanReturn" />
+        <module name="StringLiteralEquality" />
+        <module name="NestedIfDepth" />
+        <module name="NestedTryDepth" />
+        <module name="NoClone" />
+        <module name="NoFinalizer" />
+        <module name="SuperClone" />
+        <module name="SuperFinalize" />
+        <module name="IllegalCatch" />
+        <module name="IllegalThrows" />
+        <module name="PackageDeclaration" />
+        <module name="JUnitTestCase" />
+        <module name="ReturnCount">
+            <property name="max" value="3" />
+        </module>
+        <module name="IllegalType" />
+        <module name="DeclarationOrder" />
+        <module name="ParameterAssignment" />
+<!--    <module name="ExplicitInitialization" />  -->
+        <module name="DefaultComesLast" />
+        <module name="MissingCtor" />
+        <module name="FallThrough" />
+        <module name="MultipleStringLiterals" />
+        <module name="MultipleVariableDeclarations" />
+        <module name="UnnecessaryParentheses" />
+
+
+    <!-- Imports -->
+
+        <module name="AvoidStarImport" />
+        <module name="AvoidStaticImport" />
+        <module name="IllegalImport" />
+        <module name="RedundantImport" />
+        <module name="UnusedImports" />
+        <module name="ImportOrder" />
+<!--    <module name="ImportControl" />  -->
+
+
+    <!-- Javadoc Comments -->
+
+        <module name="JavadocType" />
+        <module name="JavadocMethod" />
+        <module name="JavadocVariable">
+            <property name="scope" value="protected" />
+        </module>
+        <module name="JavadocStyle">
+            <property
+                name="endOfSentenceFormat"
+                value="([。.?!][ \t\n\r\f&lt;])|([。.?!]$)" />
+            <property name="checkEmptyJavadoc" value="true" />
+            <property name="checkHtml" value="true" />
+        </module>
+<!--    <module name="WriteTag" />  -->
+
+
+    <!-- Metrics -->
+
+        <module name="BooleanExpressionComplexity" />
+        <module name="ClassDataAbstractionCoupling" />
+        <module name="ClassFanOutComplexity" />
+        <module name="CyclomaticComplexity" />
+        <module name="NPathComplexity" />
+        <module name="JavaNCSS" />
+
+
+    <!-- Miscellaneous -->
+
+        <module name="TodoComment">
+            <property name="format" value="TODO" />
+        </module>
+        <module name="UncommentedMain" />
+        <module name="UpperEll" />
+        <module name="ArrayTypeStyle" />
+<!--    <module name="FinalParameters" />  -->
+        <module name="DescendantToken" />
+<!--
+        <module name="Indentation">
+            <property name="basicOffset" value="4" />
+            <property name="caseIndent" value="0" />
+        </module>
+-->
+<!--    <module name="TrailingComment" />  -->
+        <module name="Regexp">
+            <property name="format" value="@author" />
+            <property name="illegalPattern" value="true" />
+        </module>
+        <module name="Regexp">
+            <property name="format" value="^ \* Copyright\(c\)" />
+        </module>
+        <module name="Regexp">
+            <property name="format" value="^ \* License : The MIT License" />
+            <property name="duplicateLimit" value="1" />
+        </module>
+
+    <!-- Modifiers -->
+
+        <module name="ModifierOrder" />
+        <module name="RedundantModifier" />
+
+
+    <!-- Naming Conventions -->
+
+        <module name="AbstractClassName" />
+        <module name="ClassTypeParameterName" />
+        <module name="ConstantName" />
+        <module name="LocalFinalVariableName">
+            <property name="format" value="^[a-z][_a-zA-Z0-9]*$" />
+        </module>
+        <module name="LocalVariableName">
+            <property name="format" value="^[a-z][_a-zA-Z0-9]*$" />
+        </module>
+        <module name="MemberName">
+            <property name="format" value="^[a-z][_a-zA-Z0-9]*$" />
+        </module>
+        <module name="MethodName" />
+        <module name="MethodTypeParameterName" />
+        <module name="PackageName" />
+        <module name="ParameterName">
+            <property name="format" value="^[a-z][_a-zA-Z0-9]*$" />
+        </module>
+        <module name="StaticVariableName">
+            <property name="format" value="^[a-z][_a-zA-Z0-9]*$" />
+        </module>
+        <module name="TypeName" />
+
+
+    <!-- Size Violations -->
+
+        <module name="ExecutableStatementCount" />
+        <module name="LineLength">
+            <property name="max" value="78" />
+        </module>
+        <module name="MethodLength" />
+        <module name="AnonInnerLength" />
+        <module name="ParameterNumber" />
+        <module name="OuterTypeNumber" />
+
+
+    <!-- Whitespace -->
+
+        <module name="GenericWhitespace" />
+        <module name="EmptyForInitializerPad" />
+        <module name="EmptyForIteratorPad" />
+        <module name="MethodParamPad">
+            <property name="tokens" value="CTOR_DEF, LITERAL_NEW, METHOD_DEF, SUPER_CTOR_CALL" />
+        </module>
+        <module name="NoWhitespaceAfter">
+            <property name="allowLineBreaks" value="false" />
+            <property name="tokens" value="DEC, DOT, INC" />
+        </module>
+        <module name="NoWhitespaceBefore">
+            <property name="allowLineBreaks" value="false" />
+            <property name="tokens" value="POST_DEC, POST_INC" />
+        </module>
+        <module name="NoWhitespaceBefore">
+            <property name="allowLineBreaks" value="true" />
+            <property name="tokens" value="SEMI" />
+        </module>
+        <module name="OperatorWrap">
+            <property name="option" value="eol" />
+            <property
+                name="tokens"
+                value="ASSIGN,
+                       BAND_ASSIGN, BOR_ASSIGN, BXOR_ASSIGN,
+                       PLUS_ASSIGN, MINUS_ASSIGN,
+                       STAR_ASSIGN, DIV_ASSIGN, MOD_ASSIGN,
+                       SL_ASSIGN, SR_ASSIGN"
+            />
+        </module>
+        <module name="OperatorWrap">
+            <property name="option" value="nl" />
+            <property
+                name="tokens"
+                value="BAND, BOR, BXOR,
+                       MINUS, STAR, DIV, MOD,
+                       LAND, LOR,
+                       EQUAL"
+            />
+        </module>
+        <module name="ParenPad">
+            <property name="option" value="nospace" />
+            <property name="tokens" value="CTOR_CALL, METHOD_CALL, SUPER_CTOR_CALL" />
+        </module>
+        <module name="TypecastParenPad" />
+        <module name="WhitespaceAfter">
+            <property name="tokens" value="COMMA, SEMI" />
+        </module>
+        <module name="WhitespaceAround">
+            <property
+                name="tokens"
+                value="ASSIGN,
+                       LAND, LOR,
+                       BAND, BOR, BXOR, BSR,
+                       BAND_ASSIGN, BOR_ASSIGN, BXOR_ASSIGN, BSR_ASSIGN,
+                       SL, SR,
+                       SL_ASSIGN, SR_ASSIGN,
+                       MINUS, STAR, DIV, MOD,
+                       PLUS_ASSIGN, MINUS_ASSIGN, STAR_ASSIGN, DIV_ASSIGN, MOD_ASSIGN,
+                       EQUAL, NOT_EQUAL, GT, GE, LT, LE,
+                       "
+            />
+        </module>
+
+
+<!-- 代用品で解決
+        <module name="Header" />
+        <module name="RegexpSingleline" />
+        <module name="RegexpMultiline" />
+        <module name="RegexpSinglelineJava" />
+-->
+
+<!-- バグ?
+        <module name="RequireThis" />
+-->
+
+<!-- Obsolated
+        <module name="TabCharacter" />
+-->
+
+    </module>
+</module>
+
+<!-- EOF -->
diff --git a/src/main/config/pmdrules.xml b/src/main/config/pmdrules.xml
new file mode 100644 (file)
index 0000000..1b5fcf2
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+    PMD用ルールセット定義
+
+    PMD [ http://pmd.sourceforge.net/ ] 4.2.5 以降用に記述されています。
+
+    Copyright(c) 2010 olyutorskii
+-->
+
+<ruleset
+  name="Custom ruleset"
+  xmlns="http://pmd.sf.net/ruleset/1.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
+  http://pmd.sf.net/ruleset_xml_schema.xsd"
+  xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
+>
+
+    <rule ref="rulesets/basic.xml">
+        <exclude name="UnnecessaryReturn" />
+    </rule>
+
+    <rule ref="rulesets/braces.xml">
+        <exclude name="IfElseStmtsMustUseBraces" />
+        <exclude name="IfStmtsMustUseBraces" />
+    </rule>
+
+    <rule ref="rulesets/codesize.xml">
+        <exclude name="TooManyMethods" />
+    </rule>
+
+    <rule ref="rulesets/clone.xml" />
+
+    <rule ref="rulesets/controversial.xml">
+        <exclude name="DataflowAnomalyAnalysis" />
+        <exclude name="OnlyOneReturn" />
+        <exclude name="DefaultPackage" />
+    </rule>
+
+    <rule ref="rulesets/coupling.xml" />
+
+    <rule ref="rulesets/design.xml">
+        <exclude name="UnnecessaryLocalBeforeReturn" />
+    </rule>
+
+    <rule ref="rulesets/finalizers.xml" />
+
+    <rule ref="rulesets/imports.xml" />
+
+    <rule ref="rulesets/logging-java.xml" />
+
+    <rule ref="rulesets/migrating.xml" />
+    <rule ref="rulesets/migrating_to_15.xml" />
+
+    <rule ref="rulesets/naming.xml">
+        <exclude name="LongVariable" />
+        <exclude name="ShortVariable" />
+    </rule>
+
+    <rule ref="rulesets/optimizations.xml">
+        <exclude name="LocalVariableCouldBeFinal" />
+        <exclude name="MethodArgumentCouldBeFinal" />
+    </rule>
+
+    <rule ref="rulesets/strictexception.xml">
+        <exclude name="AvoidThrowingNullPointerException" />
+    </rule>
+
+    <rule ref="rulesets/strings.xml" />
+
+    <rule ref="rulesets/sunsecure.xml" />
+
+    <rule ref="rulesets/typeresolution.xml" />
+
+    <rule ref="rulesets/unusedcode.xml" />
+
+</ruleset>
+
+<!-- EOF -->
diff --git a/src/main/java/jp/sourceforge/mikutoga/pmd2xml/Pmd2Xml.java b/src/main/java/jp/sourceforge/mikutoga/pmd2xml/Pmd2Xml.java
new file mode 100644 (file)
index 0000000..e52c922
--- /dev/null
@@ -0,0 +1,417 @@
+/*\r
+ * pmd 2 xml converter main entry\r
+ *\r
+ * License : The MIT License\r
+ * Copyright(c) 2010 MikuToga Partners\r
+ */\r
+\r
+package jp.sourceforge.mikutoga.pmd2xml;\r
+\r
+import java.io.BufferedInputStream;\r
+import java.io.BufferedOutputStream;\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+import java.io.InputStream;\r
+import java.io.OutputStream;\r
+import java.nio.channels.FileChannel;\r
+import java.util.Properties;\r
+import javax.xml.parsers.DocumentBuilder;\r
+import javax.xml.parsers.ParserConfigurationException;\r
+import jp.sourceforge.mikutoga.parser.MmdFormatException;\r
+import jp.sourceforge.mikutoga.parser.MmdSource;\r
+import jp.sourceforge.mikutoga.pmd.PmdModel;\r
+import jp.sourceforge.mikutoga.pmd.pmdexporter.IllegalPmdException;\r
+import jp.sourceforge.mikutoga.pmd.pmdexporter.PmdExporter;\r
+import jp.sourceforge.mikutoga.pmd.pmdloader.PmdLoader;\r
+import jp.sourceforge.mikutoga.pmd.xml.PmdXmlExporter;\r
+import jp.sourceforge.mikutoga.pmd.xml.PmdXmlResources;\r
+import jp.sourceforge.mikutoga.pmd.xml.Xml2PmdLoader;\r
+import jp.sourceforge.mikutoga.xml.TogaXmlException;\r
+import org.xml.sax.InputSource;\r
+import org.xml.sax.SAXException;\r
+\r
+/**\r
+ * PMDモデルファイルとXMLとの間で変換を行うアプリケーション。\r
+ */\r
+public final class Pmd2Xml {\r
+\r
+    private static final Class THISCLASS;\r
+    private static final String APPNAME;\r
+    private static final String APPVER;\r
+    private static final String APPLICENSE;\r
+\r
+    static{\r
+        THISCLASS = Pmd2Xml.class;\r
+        InputStream ver =\r
+                THISCLASS.getResourceAsStream("resources/version.properties");\r
+        Properties verProps = new Properties();\r
+        try{\r
+            verProps.load(ver);\r
+        }catch(IOException e){\r
+            throw new ExceptionInInitializerError(e);\r
+        }\r
+\r
+        APPNAME    = verProps.getProperty("app.name");\r
+        APPVER     = verProps.getProperty("app.version");\r
+        APPLICENSE = verProps.getProperty("app.license");\r
+\r
+        Object dummy = new Pmd2Xml();\r
+    }\r
+\r
+    /**\r
+     * 隠しコンストラクタ。\r
+     */\r
+    private Pmd2Xml(){\r
+        super();\r
+        assert this.getClass().equals(THISCLASS);\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * Mainエントリ。\r
+     * @param args コマンドパラメータ\r
+     */\r
+    public static void main(String[] args){\r
+        checkJRE();\r
+\r
+        String inputFile = null;\r
+        String outputFile = null;\r
+        boolean pmd2xml = false;\r
+        boolean xml2pmd = false;\r
+        boolean force = false;\r
+        int argsLen = args.length;\r
+        for(int argIdx = 0; argIdx < argsLen; argIdx++){\r
+            String arg = args[argIdx];\r
+\r
+            if(arg.equals("-h")){\r
+                putHelp();\r
+            }else if(arg.equals("-pmd2xml")){\r
+                pmd2xml = true;\r
+                xml2pmd = false;\r
+            }else if(arg.equals("-xml2pmd")){\r
+                pmd2xml = false;\r
+                xml2pmd = true;\r
+            }else if(arg.equals("-i")){\r
+                if(++argIdx >= argsLen){\r
+                    System.err.println("ERROR:");\r
+                    System.err.println("You need -i argument.");\r
+                    System.err.println("(-h for help)");\r
+                    System.exit(1);\r
+                }\r
+                inputFile = args[argIdx];\r
+            }else if(arg.equals("-o")){\r
+                if(++argIdx >= argsLen){\r
+                    System.err.println("ERROR:");\r
+                    System.err.println("You need -o argument.");\r
+                    System.err.println("(-h for help)");\r
+                    System.exit(1);\r
+                }\r
+                outputFile = args[argIdx];\r
+            }else if(arg.equals("-f")){\r
+                force = true;\r
+            }\r
+        }\r
+\r
+        if( ( ! pmd2xml) && ( ! xml2pmd) ){\r
+            System.err.println("ERROR:");\r
+            System.err.println("You must specify -pmd2xml or -xml2pmd.");\r
+            System.err.println("(-h for help)");\r
+            System.exit(1);\r
+        }\r
+\r
+        if(inputFile == null){\r
+            System.err.println("ERROR:");\r
+            System.err.println("You must specify input file with -i.");\r
+            System.err.println("(-h for help)");\r
+            System.exit(1);\r
+        }\r
+\r
+        if(outputFile == null){\r
+            System.err.println("ERROR:");\r
+            System.err.println("You must specify output file with -o.");\r
+            System.err.println("(-h for help)");\r
+            System.exit(1);\r
+        }\r
+\r
+        File iFile = new File(inputFile);\r
+        if( (! iFile.exists()) || (! iFile.isFile()) ){\r
+            System.err.println("ERROR:");\r
+            System.err.println("Can't find input file:"\r
+                    + iFile.getAbsolutePath());\r
+            System.err.println("(-h for help)");\r
+            System.exit(1);\r
+        }\r
+\r
+        if( ! force ){\r
+            File oFile = new File(outputFile);\r
+            if(oFile.exists()){\r
+                System.err.println("ERROR:");\r
+                System.err.println(oFile.getAbsolutePath()\r
+                        + " already exists.");\r
+                System.err.println("If you want to overwrite, use -f.");\r
+                System.err.println("(-h for help)");\r
+                System.exit(1);\r
+            }\r
+        }else{\r
+            File oFile = new File(outputFile);\r
+            if(oFile.exists()){\r
+                if( ! oFile.isFile()){\r
+                    System.err.println("ERROR:");\r
+                    System.err.println(oFile.getAbsolutePath()\r
+                            + " is not file.");\r
+                    System.err.println("(-h for help)");\r
+                    System.exit(1);\r
+                }\r
+            }\r
+        }\r
+\r
+        try{\r
+            if(pmd2xml) pmd2xml(inputFile, outputFile);\r
+            else        xml2pmd(inputFile, outputFile);\r
+        }catch(IOException e){\r
+            ioError(e);\r
+        }catch(ParserConfigurationException e){\r
+            internalError(e);\r
+        }catch(IllegalPmdException e){\r
+            internalError(e);\r
+        }catch(MmdFormatException e){\r
+            pmdError(e);\r
+        }catch(TogaXmlException e){\r
+            xmlError(e);\r
+        }catch(SAXException e){\r
+            xmlError(e);\r
+        }\r
+\r
+        System.exit(0);\r
+\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * 入出力エラー処理。\r
+     * 例外を出力してVM終了する。\r
+     * @param ex 例外\r
+     */\r
+    private static void ioError(Throwable ex){\r
+        System.err.println(ex);\r
+        System.exit(1);\r
+    }\r
+\r
+    /**\r
+     * XML構文エラー処理。\r
+     * 例外を出力してVM終了する。\r
+     * @param ex 例外\r
+     */\r
+    private static void xmlError(Throwable ex){\r
+        System.err.println(ex);\r
+        System.exit(2);\r
+    }\r
+\r
+    /**\r
+     * PMDファイルフォーマットエラー処理。\r
+     * 例外を出力してVM終了する。\r
+     * @param ex 例外\r
+     */\r
+    private static void pmdError(Throwable ex){\r
+        System.err.println(ex);\r
+        ex.printStackTrace(System.err);\r
+        System.exit(3);\r
+    }\r
+\r
+    /**\r
+     * 内部エラー処理。\r
+     * 例外を出力してVM終了する。\r
+     * @param ex 例外\r
+     */\r
+    private static void internalError(Throwable ex){\r
+        System.err.println(ex);\r
+        ex.printStackTrace(System.err);\r
+        System.exit(4);\r
+    }\r
+\r
+    /**\r
+     * JREのバージョン判定を行う。\r
+     * 不適切ならVMごと終了。\r
+     */\r
+    private static void checkJRE(){\r
+        Package jrePackage = java.lang.Object.class.getPackage();\r
+        if( ! jrePackage.isCompatibleWith("1.6")){\r
+            System.err.println("You need JRE 1.6 or later.");\r
+            System.exit(1);\r
+        }\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * ヘルプメッセージを出力してVMを終了させる。\r
+     */\r
+    private static void putHelp(){\r
+        System.err.println(APPNAME + ' ' + APPVER );\r
+        System.err.println("  License : " + APPLICENSE);\r
+        System.err.println("  http://mikutoga.sourceforge.jp/");\r
+        System.err.println();\r
+        System.err.println("-h       : put help massage");\r
+        System.err.println("-pmd2xml : convert *.pmd to *.xml");\r
+        System.err.println("-xml2pmd : convert *.xml to *.pmd");\r
+        System.err.println("-i file  : specify input file");\r
+        System.err.println("-o file  : specify output file");\r
+        System.err.println("-f       : force overwriting");\r
+        System.exit(0);\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * PMD->XML変換を行う。\r
+     * @param inputFile 入力ファイル名\r
+     * @param outputFile 出力ファイル名\r
+     * @throws IOException 入出力エラー\r
+     * @throws MmdFormatException 不正なPMDファイル\r
+     * @throws IllegalPmdException 不正なモデルデータ\r
+     */\r
+    private static void pmd2xml(String inputFile, String outputFile)\r
+            throws IOException, MmdFormatException, IllegalPmdException{\r
+        File iFile = new File(inputFile);\r
+        InputStream is = new FileInputStream(iFile);\r
+        is = new BufferedInputStream(is);\r
+        PmdModel model = pmdRead(is);\r
+        is.close();\r
+\r
+        File oFile = new File(outputFile);\r
+        trunc(oFile);\r
+        OutputStream ostream;\r
+        ostream = new FileOutputStream(oFile, false);\r
+        ostream = new BufferedOutputStream(ostream);\r
+        xmlOut(model, ostream);\r
+        ostream.close();\r
+\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * XML->PMD変換を行う。\r
+     * @param inputFile 入力ファイル名\r
+     * @param outputFile 出力ファイル名\r
+     * @throws IOException 入出力エラー\r
+     * @throws ParserConfigurationException XML構成のエラー\r
+     * @throws SAXException 不正なXMLファイル\r
+     * @throws TogaXmlException 不正なXMLファイル\r
+     * @throws IllegalPmdException 不正なPMDモデルデータ\r
+     */\r
+    private static void xml2pmd(String inputFile, String outputFile)\r
+            throws IOException,\r
+                   ParserConfigurationException,\r
+                   SAXException,\r
+                   TogaXmlException,\r
+                   IllegalPmdException {\r
+        File iFile = new File(inputFile);\r
+        InputStream is = new FileInputStream(iFile);\r
+        is = new BufferedInputStream(is);\r
+        InputSource source = new InputSource(is);\r
+        PmdModel model = xmlRead(source);\r
+        is.close();\r
+\r
+        File oFile = new File(outputFile);\r
+        trunc(oFile);\r
+        OutputStream ostream;\r
+        ostream = new FileOutputStream(oFile, false);\r
+        ostream = new BufferedOutputStream(ostream);\r
+        pmdOut(model, ostream);\r
+        ostream.close();\r
+\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * ファイルサイズを0に切り詰める。\r
+     * @param file ファイル\r
+     * @throws IOException 入出力エラー\r
+     */\r
+    private static void trunc(File file) throws IOException{\r
+        if( ! file.exists() ) return;\r
+        if( ! file.isFile() ) return;\r
+\r
+        FileOutputStream foStream = new FileOutputStream(file);\r
+        FileChannel channnel = foStream.getChannel();\r
+        channnel.truncate(0);\r
+\r
+        channnel.close();\r
+        foStream.close();\r
+\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * PMDファイルからモデルデータを読み込む。\r
+     * @param is 入力ストリーム\r
+     * @return モデルデータ\r
+     * @throws IOException 入力エラー\r
+     * @throws MmdFormatException 不正なPMDファイルフォーマット\r
+     */\r
+    private static PmdModel pmdRead(InputStream is)\r
+            throws IOException, MmdFormatException{\r
+        MmdSource source = new MmdSource(is);\r
+        PmdLoader loader = new PmdLoader(source);\r
+\r
+        PmdModel model = loader.load();\r
+\r
+        return model;\r
+    }\r
+\r
+    /**\r
+     * XMLファイルからモデルデータを読み込む。\r
+     * @param source 入力ソース\r
+     * @return モデルデータ\r
+     * @throws IOException 入力エラー\r
+     * @throws ParserConfigurationException XML構成エラー\r
+     * @throws SAXException XML構文エラー\r
+     * @throws TogaXmlException 不正なXMLデータ\r
+     */\r
+    private static PmdModel xmlRead(InputSource source)\r
+            throws IOException,\r
+                   ParserConfigurationException,\r
+                   SAXException,\r
+                   TogaXmlException {\r
+        DocumentBuilder builder =\r
+                PmdXmlResources.newBuilder(XmlHandler.HANDLER);\r
+        Xml2PmdLoader loader = new Xml2PmdLoader(builder);\r
+\r
+        PmdModel model = loader.parse(source);\r
+\r
+        return model;\r
+    }\r
+\r
+    /**\r
+     * モデルデータをPMDファイルに出力する。\r
+     * @param model モデルデータ\r
+     * @param ostream 出力ストリーム\r
+     * @throws IOException 出力エラー\r
+     * @throws IllegalPmdException 不正なモデルデータ\r
+     */\r
+    private static void pmdOut(PmdModel model, OutputStream ostream)\r
+            throws IOException, IllegalPmdException{\r
+        PmdExporter exporter = new PmdExporter(ostream);\r
+        exporter.dumpPmdModel(model);\r
+        ostream.close();\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * モデルデータをXMLファイルに出力する。\r
+     * @param model モデルデータ\r
+     * @param ostream 出力ストリーム\r
+     * @throws IOException 出力エラー\r
+     * @throws IllegalPmdException 不正なモデルデータ\r
+     */\r
+    private static void xmlOut(PmdModel model, OutputStream ostream)\r
+            throws IOException, IllegalPmdException{\r
+        PmdXmlExporter exporter = new PmdXmlExporter(ostream);\r
+        exporter.setNewLine("\r\n");\r
+        exporter.setGenerator(APPNAME + ' ' + APPVER);\r
+        exporter.putPmdModel(model);\r
+        exporter.close();\r
+        return;\r
+    }\r
+\r
+}\r
diff --git a/src/main/java/jp/sourceforge/mikutoga/pmd2xml/XmlHandler.java b/src/main/java/jp/sourceforge/mikutoga/pmd2xml/XmlHandler.java
new file mode 100644 (file)
index 0000000..62efd7a
--- /dev/null
@@ -0,0 +1,63 @@
+/*\r
+ * XML custom error-handler\r
+ *\r
+ * License : The MIT License\r
+ * Copyright(c) 2010 MikuToga Partners\r
+ */\r
+\r
+package jp.sourceforge.mikutoga.pmd2xml;\r
+\r
+import org.xml.sax.ErrorHandler;\r
+import org.xml.sax.SAXException;\r
+import org.xml.sax.SAXParseException;\r
+\r
+/**\r
+ * 自製エラーハンドラ。\r
+ * 例外を渡されれば即投げる。\r
+ */\r
+final class XmlHandler implements ErrorHandler{\r
+\r
+    /**\r
+     * 唯一のシングルトン。\r
+     */\r
+    static final ErrorHandler HANDLER = new XmlHandler();\r
+\r
+    /**\r
+     * 隠しコンストラクタ。\r
+     */\r
+    private XmlHandler(){\r
+        super();\r
+        return;\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     * @param exception {@inheritDoc}\r
+     * @throws SAXException {@inheritDoc}\r
+     */\r
+    @Override\r
+    public void error(SAXParseException exception) throws SAXException{\r
+        throw exception;\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     * @param exception {@inheritDoc}\r
+     * @throws SAXException {@inheritDoc}\r
+     */\r
+    @Override\r
+    public void fatalError(SAXParseException exception) throws SAXException{\r
+        throw exception;\r
+    }\r
+\r
+    /**\r
+     * {@inheritDoc}\r
+     * @param exception {@inheritDoc}\r
+     * @throws SAXException {@inheritDoc}\r
+     */\r
+    @Override\r
+    public void warning(SAXParseException exception) throws SAXException{\r
+        throw exception;\r
+    }\r
+\r
+}\r
diff --git a/src/main/java/jp/sourceforge/mikutoga/pmd2xml/package-info.java b/src/main/java/jp/sourceforge/mikutoga/pmd2xml/package-info.java
new file mode 100644 (file)
index 0000000..f4eddd3
--- /dev/null
@@ -0,0 +1,15 @@
+/*\r
+ * package information for Javadoc\r
+ *\r
+ * License : The MIT License\r
+ * Copyright(c) 2010 MikuToga Partners\r
+ */\r
+\r
+/**\r
+ * PMDモデルデータとXML間でのデータ交換を行うアプリケーション。\r
+ * Mainエントリは、クラスPmd2Xml。\r
+ */\r
+\r
+package jp.sourceforge.mikutoga.pmd2xml;\r
+\r
+/* EOF */\r
diff --git a/src/main/resources/jp/sourceforge/mikutoga/pmd2xml/resources/version.properties b/src/main/resources/jp/sourceforge/mikutoga/pmd2xml/resources/version.properties
new file mode 100644 (file)
index 0000000..76d9b53
--- /dev/null
@@ -0,0 +1,8 @@
+# Version definition
+#   [ with Maven resource filtering ]
+
+app.name = ${pom.name}
+app.version = ${pom.version}
+app.license = The MIT License
+
+# EOF #