Pmd2XMLは、3D動画制作ツール、MikuMikuDance(MMD)で用いられるモデルデータファイル(*.pmd)の内容を、XML形式のデータファイルと交換するためのアプリケーションです。
| Revision | f5ccf9a8f0902b0b8d4fc4f00d8059357e2880c6 (tree) |
|---|---|
| Time | 2019-07-04 16:26:03 |
| Author | |
| Commiter | Olyutorskii |
Merge release/v1.203.2
| @@ -4,6 +4,9 @@ | ||
| 4 | 4 | Pmd2XML 変更履歴 |
| 5 | 5 | |
| 6 | 6 | |
| 7 | +1.203.2 (2019-07-04) | |
| 8 | + * Prevent XXE vulnerabilities from external resources. | |
| 9 | + | |
| 7 | 10 | 1.202.2 (2019-06-06) |
| 8 | 11 | ・必須環境をJavaSE8に引き上げ。 |
| 9 | 12 | ・デフォルトロケールによる出力揺らぎを解消。 |
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | |
| 7 | 7 | <!-- |
| 8 | 8 | Checkstyle suppressions |
| 9 | - for Checkstyle 8.20 or later | |
| 9 | + for Checkstyle 8.22 or later | |
| 10 | 10 | |
| 11 | 11 | [ https://checkstyle.org/ ] |
| 12 | 12 |
| @@ -31,18 +31,19 @@ | ||
| 31 | 31 | <suppress files="" checks="ImportControl" /> |
| 32 | 32 | |
| 33 | 33 | <!-- Javadoc Comments --> |
| 34 | - <suppress files="" checks="JavadocParagraph" /> | |
| 35 | - <suppress files="" checks="JavadocTagContinuationIndentation" /> | |
| 36 | 34 | <suppress files="" checks="SummaryJavadocCheck" /> |
| 37 | 35 | |
| 38 | 36 | <!-- Miscellaneous --> |
| 39 | 37 | <suppress files="" checks="FinalParameters" /> |
| 38 | + <suppress files="" checks="OrderedProperties" /> | |
| 40 | 39 | <suppress files="" checks="TrailingComment" /> |
| 41 | 40 | |
| 42 | 41 | <!-- Modifier --> |
| 43 | - <suppress files="" checks="InterfaceMemberImpliedModifier" /> | |
| 42 | + <suppress files="" checks="RedundantModifier" /> | |
| 44 | 43 | |
| 45 | 44 | <!-- Whitespace --> |
| 45 | + <suppress files="" checks="MethodParam" /> | |
| 46 | + <suppress files="" checks="ParenPad" /> | |
| 46 | 47 | <suppress files="" checks="SingleSpaceSeparator" /> |
| 47 | 48 | |
| 48 | 49 | </suppressions> |
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | |
| 7 | 7 | <!-- |
| 8 | 8 | Checkstyle modules |
| 9 | - for Checkstyle 8.21 or later | |
| 9 | + for Checkstyle 8.22 or later | |
| 10 | 10 | |
| 11 | 11 | [ https://checkstyle.org/ ] |
| 12 | 12 |
| @@ -39,6 +39,7 @@ | ||
| 39 | 39 | <property name="fileExtensions" value="xml" /> |
| 40 | 40 | </module> |
| 41 | 41 | <module name="RegexpHeader"> |
| 42 | + <!-- /* ... */ --> | |
| 42 | 43 | <property name="header" value="^/\*$\n^ \*( .*)?$\n^ \*/$\n" /> |
| 43 | 44 | <property name="multiLines" value="2" /> |
| 44 | 45 | <property name="fileExtensions" value="java" /> |
| @@ -55,6 +56,7 @@ | ||
| 55 | 56 | <module name="NewlineAtEndOfFile"> |
| 56 | 57 | <property name="fileExtensions" value="java, properties, xml, xsd, md, txt" /> |
| 57 | 58 | </module> |
| 59 | + <module name="OrderedProperties" /> | |
| 58 | 60 | <module name="Translation" /> |
| 59 | 61 | <module name="UniqueProperties" /> |
| 60 | 62 |
| @@ -188,13 +190,18 @@ | ||
| 188 | 190 | <module name="RequireThis"> |
| 189 | 191 | <property name="checkMethods" value="false" /> |
| 190 | 192 | </module> |
| 191 | - <module name="ReturnCount" /> | |
| 193 | + <module name="ReturnCount"> | |
| 194 | + <property name="max" value="5" /> | |
| 195 | + <property name="maxForVoid" value="5" /> | |
| 196 | + </module> | |
| 192 | 197 | <module name="SimplifyBooleanExpression" /> |
| 193 | 198 | <module name="SimplifyBooleanReturn" /> |
| 194 | 199 | <module name="StringLiteralEquality" /> |
| 195 | 200 | <module name="SuperClone" /> |
| 196 | 201 | <module name="SuperFinalize" /> |
| 197 | 202 | <module name="UnnecessaryParentheses" /> |
| 203 | + <module name="UnnecessarySemicolonInEnumeration" /> | |
| 204 | + <module name="UnnecessarySemicolonInTryWithResources" /> | |
| 198 | 205 | <module name="VariableDeclarationUsageDistance"> |
| 199 | 206 | <property name="allowedDistance" value="5"/> |
| 200 | 207 | </module> |
| @@ -230,6 +237,7 @@ | ||
| 230 | 237 | <property name="scope" value="protected" /> |
| 231 | 238 | </module> |
| 232 | 239 | <module name="MissingJavadocMethod" /> |
| 240 | + <module name="MissingJavadocPackage" /> | |
| 233 | 241 | <module name="MissingJavadocType" /> |
| 234 | 242 | <module name="NonEmptyAtclauseDescription" /> |
| 235 | 243 | <module name="SingleLineJavadoc" /> |
| @@ -352,16 +360,17 @@ | ||
| 352 | 360 | <module name="GenericWhitespace" /> |
| 353 | 361 | <module name="MethodParamPad" /> |
| 354 | 362 | <module name="NoLineWrap" /> |
| 355 | - <module name="NoWhitespaceAfter" /> | |
| 356 | - <module name="NoWhitespaceBefore" /> | |
| 357 | - <module name="OperatorWrap" /> | |
| 358 | - <module name="ParenPad"> | |
| 359 | - <property name="option" value="nospace" /> | |
| 363 | + <module name="NoWhitespaceAfter"> | |
| 360 | 364 | <property |
| 361 | 365 | name="tokens" |
| 362 | - value="CTOR_CALL, METHOD_CALL, SUPER_CTOR_CALL" | |
| 366 | + value="AT, INC, DEC, UNARY_MINUS, UNARY_PLUS, DOT" | |
| 363 | 367 | /> |
| 364 | 368 | </module> |
| 369 | + <module name="NoWhitespaceBefore"> | |
| 370 | + <property name="allowLineBreaks" value="true" /> | |
| 371 | + </module> | |
| 372 | + <module name="OperatorWrap" /> | |
| 373 | + <module name="ParenPad" /> | |
| 365 | 374 | <module name="SeparatorWrap"> |
| 366 | 375 | <property name="tokens" value="DOT"/> |
| 367 | 376 | <property name="option" value="nl"/> |
| @@ -392,6 +401,6 @@ | ||
| 392 | 401 | </module> |
| 393 | 402 | |
| 394 | 403 | |
| 395 | - </module> | |
| 404 | +</module> | |
| 396 | 405 | |
| 397 | 406 | <!-- EOF --> |
| @@ -37,6 +37,11 @@ | ||
| 37 | 37 | <property name="checkSingleIfStmt" value="false"/> |
| 38 | 38 | </properties> |
| 39 | 39 | </rule> |
| 40 | + <rule ref="category/java/codestyle.xml/LongVariable" > | |
| 41 | + <properties> | |
| 42 | + <property name="minimum" value="25"/> | |
| 43 | + </properties> | |
| 44 | + </rule> | |
| 40 | 45 | |
| 41 | 46 | <rule ref="category/java/design.xml" > |
| 42 | 47 | <exclude name="LawOfDemeter" /> |
| @@ -16,7 +16,7 @@ | ||
| 16 | 16 | <groupId>jp.sourceforge.mikutoga</groupId> |
| 17 | 17 | <artifactId>pmd2xml</artifactId> |
| 18 | 18 | |
| 19 | - <version>1.202.2</version> | |
| 19 | + <version>1.203.2</version> | |
| 20 | 20 | |
| 21 | 21 | <packaging>jar</packaging> |
| 22 | 22 | <name>Pmd2XML</name> |
| @@ -86,26 +86,23 @@ | ||
| 86 | 86 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> |
| 87 | 87 | <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> |
| 88 | 88 | |
| 89 | - <locale>en</locale> | |
| 90 | - <site.locales>${locale}</site.locales> | |
| 91 | - <javadoc.locale>${locale}</javadoc.locale> | |
| 92 | - <spotbugs.jvmArgs>-Duser.language=${locale}</spotbugs.jvmArgs> | |
| 93 | - | |
| 94 | - <!-- Walk around: JDK 11 javadoc + Maven --> | |
| 95 | - <detectJavaApiLink>false</detectJavaApiLink> | |
| 89 | + <!-- DO NOT USE ${locale} with site-plugin --> | |
| 90 | + <site.locales>en</site.locales> | |
| 91 | + <javadoc.locale>en</javadoc.locale> | |
| 92 | + <spotbugs.jvmArgs>-Duser.language=en</spotbugs.jvmArgs> | |
| 96 | 93 | |
| 97 | 94 | <surefire-plugin.version>3.0.0-M3</surefire-plugin.version> |
| 98 | 95 | <jacoco-plugin.version>0.8.4</jacoco-plugin.version> |
| 99 | 96 | |
| 100 | 97 | <checkstyle-plugin.version>3.1.0</checkstyle-plugin.version> |
| 101 | - <checkstyleruntime.version>8.21</checkstyleruntime.version> | |
| 102 | - <checkstyle.config.location>${project.basedir}/config/checkstyle/checkstyle.xml</checkstyle.config.location> | |
| 103 | - <checkstyle.suppressions.location>${project.basedir}/config/checkstyle/checkstyle-suppressions.xml</checkstyle.suppressions.location> | |
| 98 | + <checkstyleruntime.version>8.22</checkstyleruntime.version> | |
| 99 | + <checkstyle.config.location>config/checkstyle/checkstyle.xml</checkstyle.config.location> | |
| 100 | + <checkstyle.suppressions.location>config/checkstyle/checkstyle-suppressions.xml</checkstyle.suppressions.location> | |
| 104 | 101 | <checkstyle.enable.rss>false</checkstyle.enable.rss> |
| 105 | 102 | |
| 106 | 103 | <pmd-plugin.version>3.12.0</pmd-plugin.version> |
| 107 | 104 | |
| 108 | - <spotbugs-plugin.version>3.1.11</spotbugs-plugin.version> | |
| 105 | + <spotbugs-plugin.version>3.1.12</spotbugs-plugin.version> | |
| 109 | 106 | <spotbugs.effort>Max</spotbugs.effort> |
| 110 | 107 | <spotbugs.threshold>Low</spotbugs.threshold> |
| 111 | 108 | <!-- for Jenkins --> |
| @@ -129,7 +126,7 @@ | ||
| 129 | 126 | <dependency> |
| 130 | 127 | <groupId>jp.sourceforge.mikutoga</groupId> |
| 131 | 128 | <artifactId>togagem</artifactId> |
| 132 | - <version>3.121.2</version> | |
| 129 | + <version>3.122.2</version> | |
| 133 | 130 | <scope>compile</scope> |
| 134 | 131 | </dependency> |
| 135 | 132 |
| @@ -315,7 +312,7 @@ | ||
| 315 | 312 | <execution> |
| 316 | 313 | <phase>package</phase> |
| 317 | 314 | <goals> |
| 318 | - <goal>shade</goal> | |
| 315 | + <goal>shade</goal> | |
| 319 | 316 | </goals> |
| 320 | 317 | <configuration> |
| 321 | 318 | <createDependencyReducedPom>false</createDependencyReducedPom> |
| @@ -349,7 +346,7 @@ | ||
| 349 | 346 | <id>attach-sources</id> |
| 350 | 347 | <phase>verify</phase> |
| 351 | 348 | <goals> |
| 352 | - <goal>jar-no-fork</goal> | |
| 349 | + <goal>jar-no-fork</goal> | |
| 353 | 350 | </goals> |
| 354 | 351 | </execution> |
| 355 | 352 | </executions> |
| @@ -508,13 +505,14 @@ | ||
| 508 | 505 | <artifactId>maven-javadoc-plugin</artifactId> |
| 509 | 506 | <version>3.1.0</version> |
| 510 | 507 | <configuration> |
| 508 | + <locale>${javadoc.locale}</locale> | |
| 509 | + <source>${maven.compiler.source}</source> | |
| 511 | 510 | <author>false</author> |
| 512 | 511 | <notimestamp>true</notimestamp> |
| 513 | 512 | <quiet>true</quiet> |
| 514 | 513 | <show>protected</show> |
| 515 | 514 | <header>${project.name} ${project.version} API</header> |
| 516 | 515 | <version>true</version> |
| 517 | - <locale>${javadoc.locale}</locale> | |
| 518 | 516 | <!-- for JDK11 javadoc --> |
| 519 | 517 | <additionalJOption>-J-Duser.language=${javadoc.locale}</additionalJOption> |
| 520 | 518 | </configuration> |
| @@ -571,7 +569,7 @@ | ||
| 571 | 569 | <version>${pmd-plugin.version}</version> |
| 572 | 570 | <configuration> |
| 573 | 571 | <rulesets> |
| 574 | - <ruleset>${project.basedir}/config/pmd/pmdrules.xml</ruleset> | |
| 572 | + <ruleset>config/pmd/pmdrules.xml</ruleset> | |
| 575 | 573 | </rulesets> |
| 576 | 574 | </configuration> |
| 577 | 575 | <reportSets> |
| @@ -18,11 +18,11 @@ import jp.sfjp.mikutoga.corelib.I18nText; | ||
| 18 | 18 | * 通し番号0のボーングループは、 |
| 19 | 19 | * 暗黙に用意される「デフォルトボーングループ」とする。 |
| 20 | 20 | */ |
| 21 | -public class BoneGroup implements SerialNumbered , Iterable<BoneInfo> { | |
| 21 | +public class BoneGroup implements SerialNumbered, Iterable<BoneInfo> { | |
| 22 | 22 | |
| 23 | 23 | private final I18nText groupName = new I18nText(); |
| 24 | 24 | |
| 25 | - private final List<BoneInfo> boneList = new ArrayList<BoneInfo>(); | |
| 25 | + private final List<BoneInfo> boneList = new ArrayList<>(); | |
| 26 | 26 | |
| 27 | 27 | private int serialNo = -1; |
| 28 | 28 |
| @@ -21,7 +21,7 @@ public class IKChain implements Iterable<BoneInfo> { | ||
| 21 | 21 | private int ikDepth; |
| 22 | 22 | private float ikWeight; |
| 23 | 23 | |
| 24 | - private final List<BoneInfo> chainList = new ArrayList<BoneInfo>(); | |
| 24 | + private final List<BoneInfo> chainList = new ArrayList<>(); | |
| 25 | 25 | |
| 26 | 26 | |
| 27 | 27 | /** |
| @@ -39,7 +39,7 @@ public class Material implements Iterable<Surface> { | ||
| 39 | 39 | |
| 40 | 40 | private boolean edgeAppearance = true; |
| 41 | 41 | |
| 42 | - private final List<Surface> surfaceList = new ArrayList<Surface>(); | |
| 42 | + private final List<Surface> surfaceList = new ArrayList<>(); | |
| 43 | 43 | |
| 44 | 44 | |
| 45 | 45 | /** |
| @@ -23,7 +23,7 @@ public class MorphPart implements SerialNumbered, Iterable<MorphVertex> { | ||
| 23 | 23 | private MorphType type; |
| 24 | 24 | |
| 25 | 25 | private final List<MorphVertex> morphVertexList = |
| 26 | - new ArrayList<MorphVertex>(); | |
| 26 | + new ArrayList<>(); | |
| 27 | 27 | |
| 28 | 28 | private int morphSerialNo = -1; |
| 29 | 29 |
| @@ -29,23 +29,23 @@ public class PmdModel { | ||
| 29 | 29 | private final I18nText modelName = new I18nText(); |
| 30 | 30 | private final I18nText description = new I18nText(); |
| 31 | 31 | |
| 32 | - private final List<Vertex> vertexList = new ArrayList<Vertex>(); | |
| 33 | - private final List<Surface> surfaceList = new ArrayList<Surface>(); | |
| 34 | - private final List<Material> materialList = new LinkedList<Material>(); | |
| 32 | + private final List<Vertex> vertexList = new ArrayList<>(); | |
| 33 | + private final List<Surface> surfaceList = new ArrayList<>(); | |
| 34 | + private final List<Material> materialList = new LinkedList<>(); | |
| 35 | 35 | |
| 36 | - private final List<BoneInfo> boneList = new ArrayList<BoneInfo>(); | |
| 37 | - private final List<BoneGroup> boneGroupList = new ArrayList<BoneGroup>(); | |
| 36 | + private final List<BoneInfo> boneList = new ArrayList<>(); | |
| 37 | + private final List<BoneGroup> boneGroupList = new ArrayList<>(); | |
| 38 | 38 | |
| 39 | - private final List<IKChain> ikChainList = new ArrayList<IKChain>(); | |
| 39 | + private final List<IKChain> ikChainList = new ArrayList<>(); | |
| 40 | 40 | |
| 41 | 41 | private final Map<MorphType, List<MorphPart>> morphMap = |
| 42 | - new EnumMap<MorphType, List<MorphPart>>(MorphType.class); | |
| 42 | + new EnumMap<>(MorphType.class); | |
| 43 | 43 | |
| 44 | - private final List<RigidInfo> rigidList = new ArrayList<RigidInfo>(); | |
| 44 | + private final List<RigidInfo> rigidList = new ArrayList<>(); | |
| 45 | 45 | private final List<RigidGroup> rigidGroupList = |
| 46 | - new ArrayList<RigidGroup>(); | |
| 46 | + new ArrayList<>(); | |
| 47 | 47 | |
| 48 | - private final List<JointInfo> jointList = new ArrayList<JointInfo>(); | |
| 48 | + private final List<JointInfo> jointList = new ArrayList<>(); | |
| 49 | 49 | |
| 50 | 50 | private ToonMap toonMap = new ToonMap(); |
| 51 | 51 |
| @@ -59,10 +59,10 @@ public class PmdModel { | ||
| 59 | 59 | assert this.vertexList instanceof RandomAccess; |
| 60 | 60 | assert this.surfaceList instanceof RandomAccess; |
| 61 | 61 | |
| 62 | - this.morphMap.put(MorphType.EYEBROW, new ArrayList<MorphPart>()); | |
| 63 | - this.morphMap.put(MorphType.EYE, new ArrayList<MorphPart>()); | |
| 64 | - this.morphMap.put(MorphType.LIP, new ArrayList<MorphPart>()); | |
| 65 | - this.morphMap.put(MorphType.EXTRA, new ArrayList<MorphPart>()); | |
| 62 | + this.morphMap.put(MorphType.EYEBROW, new ArrayList<>()); | |
| 63 | + this.morphMap.put(MorphType.EYE, new ArrayList<>()); | |
| 64 | + this.morphMap.put(MorphType.LIP, new ArrayList<>()); | |
| 65 | + this.morphMap.put(MorphType.EXTRA, new ArrayList<>()); | |
| 66 | 66 | |
| 67 | 67 | return; |
| 68 | 68 | } |
| @@ -70,6 +70,7 @@ public class PmdModel { | ||
| 70 | 70 | |
| 71 | 71 | /** |
| 72 | 72 | * モデル名を返す。 |
| 73 | + * | |
| 73 | 74 | * @return モデル名 |
| 74 | 75 | */ |
| 75 | 76 | public I18nText getModelName(){ |
| @@ -79,6 +80,7 @@ public class PmdModel { | ||
| 79 | 80 | /** |
| 80 | 81 | * モデル説明文を返す。 |
| 81 | 82 | * 改行表現には{@literal \n}が用いられる |
| 83 | + * | |
| 82 | 84 | * @return モデル説明文 |
| 83 | 85 | */ |
| 84 | 86 | public I18nText getDescription(){ |
| @@ -87,6 +89,7 @@ public class PmdModel { | ||
| 87 | 89 | |
| 88 | 90 | /** |
| 89 | 91 | * 頂点リストを返す。 |
| 92 | + * | |
| 90 | 93 | * @return 頂点リスト。 |
| 91 | 94 | */ |
| 92 | 95 | public List<Vertex> getVertexList(){ |
| @@ -95,6 +98,7 @@ public class PmdModel { | ||
| 95 | 98 | |
| 96 | 99 | /** |
| 97 | 100 | * 面リストを返す。 |
| 101 | + * | |
| 98 | 102 | * @return 面リスト |
| 99 | 103 | */ |
| 100 | 104 | public List<Surface> getSurfaceList(){ |
| @@ -103,6 +107,7 @@ public class PmdModel { | ||
| 103 | 107 | |
| 104 | 108 | /** |
| 105 | 109 | * 素材リストを返す。 |
| 110 | + * | |
| 106 | 111 | * @return 素材リスト |
| 107 | 112 | */ |
| 108 | 113 | public List<Material> getMaterialList(){ |
| @@ -111,6 +116,7 @@ public class PmdModel { | ||
| 111 | 116 | |
| 112 | 117 | /** |
| 113 | 118 | * ボーンリストを返す。 |
| 119 | + * | |
| 114 | 120 | * @return ボーンリスト |
| 115 | 121 | */ |
| 116 | 122 | public List<BoneInfo> getBoneList(){ |
| @@ -119,6 +125,7 @@ public class PmdModel { | ||
| 119 | 125 | |
| 120 | 126 | /** |
| 121 | 127 | * ボーングループリストを返す。 |
| 128 | + * | |
| 122 | 129 | * @return ボーングループリスト |
| 123 | 130 | */ |
| 124 | 131 | public List<BoneGroup> getBoneGroupList(){ |
| @@ -127,6 +134,7 @@ public class PmdModel { | ||
| 127 | 134 | |
| 128 | 135 | /** |
| 129 | 136 | * IKチェーンリストを返す。 |
| 137 | + * | |
| 130 | 138 | * @return IKチェーンリスト |
| 131 | 139 | */ |
| 132 | 140 | public List<IKChain> getIKChainList(){ |
| @@ -135,6 +143,7 @@ public class PmdModel { | ||
| 135 | 143 | |
| 136 | 144 | /** |
| 137 | 145 | * 種類別モーフリストのマップを返す。 |
| 146 | + * | |
| 138 | 147 | * @return 種類別モーフリストのマップ |
| 139 | 148 | */ |
| 140 | 149 | public Map<MorphType, List<MorphPart>> getMorphMap(){ |
| @@ -143,6 +152,7 @@ public class PmdModel { | ||
| 143 | 152 | |
| 144 | 153 | /** |
| 145 | 154 | * 剛体リストを返す。 |
| 155 | + * | |
| 146 | 156 | * @return 剛体リスト |
| 147 | 157 | */ |
| 148 | 158 | public List<RigidInfo> getRigidList(){ |
| @@ -151,6 +161,7 @@ public class PmdModel { | ||
| 151 | 161 | |
| 152 | 162 | /** |
| 153 | 163 | * 剛体グループリストを返す。 |
| 164 | + * | |
| 154 | 165 | * @return 剛体グループリスト。 |
| 155 | 166 | */ |
| 156 | 167 | public List<RigidGroup> getRigidGroupList(){ |
| @@ -159,6 +170,7 @@ public class PmdModel { | ||
| 159 | 170 | |
| 160 | 171 | /** |
| 161 | 172 | * 剛体間ジョイントリストを返す。 |
| 173 | + * | |
| 162 | 174 | * @return 剛体間ジョイントリスト |
| 163 | 175 | */ |
| 164 | 176 | public List<JointInfo> getJointList(){ |
| @@ -167,6 +179,7 @@ public class PmdModel { | ||
| 167 | 179 | |
| 168 | 180 | /** |
| 169 | 181 | * トゥーンファイルマップを返す。 |
| 182 | + * | |
| 170 | 183 | * @return トゥーンファイルマップ |
| 171 | 184 | */ |
| 172 | 185 | public ToonMap getToonMap(){ |
| @@ -176,6 +189,7 @@ public class PmdModel { | ||
| 176 | 189 | /** |
| 177 | 190 | * トゥーンファイルマップを設定する。 |
| 178 | 191 | * 各素材のシェーディングで参照するトゥーンファイルマップも更新される。 |
| 192 | + * | |
| 179 | 193 | * @param map トゥーンファイルマップ |
| 180 | 194 | */ |
| 181 | 195 | public void setToonMap(ToonMap map){ |
| @@ -190,6 +204,7 @@ public class PmdModel { | ||
| 190 | 204 | /** |
| 191 | 205 | * このモデルがグローバル名を含むか判定する。 |
| 192 | 206 | * ボーン名、ボーングループ名、モーフ名、モデル説明文が判定対象。 |
| 207 | + * | |
| 193 | 208 | * @return グローバル名を持つならtrue |
| 194 | 209 | */ |
| 195 | 210 | public boolean hasGlobalText(){ |
| @@ -216,10 +231,11 @@ public class PmdModel { | ||
| 216 | 231 | /** |
| 217 | 232 | * 全モーフが使う全モーフ頂点の出現順リストを返す。 |
| 218 | 233 | * モーフ種別毎に固まっている事が保証される。 |
| 234 | + * | |
| 219 | 235 | * @return モーフ頂点リスト |
| 220 | 236 | */ |
| 221 | 237 | private List<MorphVertex> getAllMorphVertexList(){ |
| 222 | - List<MorphVertex> allList = new ArrayList<MorphVertex>(); | |
| 238 | + List<MorphVertex> allList = new ArrayList<>(); | |
| 223 | 239 | |
| 224 | 240 | for(MorphType type : this.morphMap.keySet()){ |
| 225 | 241 | if(type.isBase()) continue; |
| @@ -239,14 +255,15 @@ public class PmdModel { | ||
| 239 | 255 | |
| 240 | 256 | /** |
| 241 | 257 | * 重複する頂点参照を除いたモーフ頂点リストを返す。 |
| 258 | + * | |
| 242 | 259 | * @param allList モーフ頂点リスト |
| 243 | 260 | * @return 重複が除かれたモーフ頂点リスト |
| 244 | 261 | */ |
| 245 | 262 | private List<MorphVertex> getUniqueMorphVertexList( |
| 246 | 263 | List<MorphVertex> allList ){ |
| 247 | - List<MorphVertex> result = new ArrayList<MorphVertex>(); | |
| 264 | + List<MorphVertex> result = new ArrayList<>(); | |
| 248 | 265 | |
| 249 | - Set<Vertex> mergedVertexSet = new HashSet<Vertex>(); | |
| 266 | + Set<Vertex> mergedVertexSet = new HashSet<>(); | |
| 250 | 267 | |
| 251 | 268 | for(MorphVertex morphVertex : allList){ |
| 252 | 269 | Vertex vertex = morphVertex.getBaseVertex(); |
| @@ -264,9 +281,10 @@ public class PmdModel { | ||
| 264 | 281 | * モーフで使われる全てのモーフ頂点のリストを返す。 |
| 265 | 282 | * モーフ間で重複する頂点はマージされる。 |
| 266 | 283 | * 頂点IDでソートされる。 |
| 267 | - * <p> | |
| 268 | - * 0から始まる通し番号がリナンバリングされる。 | |
| 284 | + * | |
| 285 | + * <p>0から始まる通し番号がリナンバリングされる。 | |
| 269 | 286 | * 通し番号は返されるモーフ頂点リストの添え字番号と一致する。 |
| 287 | + * | |
| 270 | 288 | * @return モーフに使われるモーフ頂点のリスト |
| 271 | 289 | */ |
| 272 | 290 | public List<MorphVertex> mergeMorphVertex(){ |
| @@ -279,7 +297,7 @@ public class PmdModel { | ||
| 279 | 297 | ListUtil.assignIndexedSerial(result); |
| 280 | 298 | |
| 281 | 299 | Map<Vertex, MorphVertex> numberedMap = |
| 282 | - new HashMap<Vertex, MorphVertex>(); | |
| 300 | + new HashMap<>(); | |
| 283 | 301 | for(MorphVertex morphVertex : result){ |
| 284 | 302 | Vertex vertex = morphVertex.getBaseVertex(); |
| 285 | 303 | numberedMap.put(vertex, morphVertex); |
| @@ -319,10 +337,11 @@ public class PmdModel { | ||
| 319 | 337 | * 所属マテリアル順に再配置し、通し番号を割り振り直す。 |
| 320 | 338 | * 所属マテリアルの無い面はリストの末端に配置される。 |
| 321 | 339 | * 面リスト中のnullは削除され詰められる。 |
| 340 | + * | |
| 322 | 341 | * @return トリミングされた面リスト |
| 323 | 342 | */ |
| 324 | 343 | private List<Surface> trimmingSurfaceList(){ |
| 325 | - Set<Surface> materialedSurfaceSet = new HashSet<Surface>(); | |
| 344 | + Set<Surface> materialedSurfaceSet = new HashSet<>(); | |
| 326 | 345 | for(Material material : this.materialList){ |
| 327 | 346 | if(material == null) continue; |
| 328 | 347 | for(Surface surface : material){ |
| @@ -333,7 +352,7 @@ public class PmdModel { | ||
| 333 | 352 | |
| 334 | 353 | materialedSurfaceSet.removeAll(this.surfaceList); |
| 335 | 354 | |
| 336 | - List<Surface> result = new ArrayList<Surface>(); | |
| 355 | + List<Surface> result = new ArrayList<>(); | |
| 337 | 356 | for(Surface surface : this.surfaceList){ |
| 338 | 357 | if(surface == null) continue; |
| 339 | 358 | result.add(surface); |
| @@ -355,10 +374,11 @@ public class PmdModel { | ||
| 355 | 374 | * 通し番号を振り直す。 |
| 356 | 375 | * 所属面の無い頂点はリストの末端に配置される。 |
| 357 | 376 | * 頂点リスト中のnullは削除され詰められる。 |
| 377 | + * | |
| 358 | 378 | * @return トリミングされた頂点リスト |
| 359 | 379 | */ |
| 360 | 380 | private List<Vertex> trimmingVertexList(){ |
| 361 | - Set<Vertex> surfacedVertexSet = new HashSet<Vertex>(); | |
| 381 | + Set<Vertex> surfacedVertexSet = new HashSet<>(); | |
| 362 | 382 | for(Surface surface : this.surfaceList){ |
| 363 | 383 | if(surface == null) continue; |
| 364 | 384 | for(Vertex vertex : surface){ |
| @@ -368,7 +388,7 @@ public class PmdModel { | ||
| 368 | 388 | |
| 369 | 389 | surfacedVertexSet.removeAll(this.vertexList); |
| 370 | 390 | |
| 371 | - List<Vertex> result = new ArrayList<Vertex>(); | |
| 391 | + List<Vertex> result = new ArrayList<>(); | |
| 372 | 392 | for(Vertex vertex : this.vertexList){ |
| 373 | 393 | if(vertex == null) continue; |
| 374 | 394 | result.add(vertex); |
| @@ -21,7 +21,7 @@ public class RigidGroup implements SerialNumbered, Iterable<RigidInfo> { | ||
| 21 | 21 | public static final int MAX_RIGID_GROUP = 16; |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - private final List<RigidInfo> rigidList = new ArrayList<RigidInfo>(); | |
| 24 | + private final List<RigidInfo> rigidList = new ArrayList<>(); | |
| 25 | 25 | |
| 26 | 26 | private int rigidGroupSerialNo = -1; |
| 27 | 27 |
| @@ -32,7 +32,7 @@ public class RigidInfo implements SerialNumbered { | ||
| 32 | 32 | private final DynamicsInfo dynamicsInfo = new DynamicsInfo(); |
| 33 | 33 | |
| 34 | 34 | private final Collection<RigidGroup> throughGroupColl = |
| 35 | - new ArrayList<RigidGroup>(); | |
| 35 | + new ArrayList<>(); | |
| 36 | 36 | |
| 37 | 37 | private RigidGroup rigidGroup; |
| 38 | 38 |
| @@ -15,20 +15,23 @@ import java.util.Comparator; | ||
| 15 | 15 | public interface SerialNumbered { |
| 16 | 16 | |
| 17 | 17 | /** 昇順での比較子。 */ |
| 18 | - Comparator<SerialNumbered> COMPARATOR = new SerialComparator(); | |
| 18 | + public static final Comparator<SerialNumbered> COMPARATOR = | |
| 19 | + new SerialComparator(); | |
| 19 | 20 | |
| 20 | 21 | |
| 21 | 22 | /** |
| 22 | 23 | * 通し番号を設定する。 |
| 24 | + * | |
| 23 | 25 | * @param num 通し番号 |
| 24 | 26 | */ |
| 25 | - void setSerialNumber(int num); | |
| 27 | + public abstract void setSerialNumber(int num); | |
| 26 | 28 | |
| 27 | 29 | /** |
| 28 | 30 | * 通し番号を返す。 |
| 31 | + * | |
| 29 | 32 | * @return 通し番号 |
| 30 | 33 | */ |
| 31 | - int getSerialNumber(); | |
| 34 | + public abstract int getSerialNumber(); | |
| 32 | 35 | |
| 33 | 36 | |
| 34 | 37 | /** |
| @@ -36,7 +39,7 @@ public interface SerialNumbered { | ||
| 36 | 39 | * 通し番号の昇順を定義づける。 |
| 37 | 40 | */ |
| 38 | 41 | @SuppressWarnings("serial") |
| 39 | - class SerialComparator | |
| 42 | + public static class SerialComparator | |
| 40 | 43 | implements Comparator<SerialNumbered> { |
| 41 | 44 | |
| 42 | 45 | /** |
| @@ -50,6 +53,7 @@ public interface SerialNumbered { | ||
| 50 | 53 | |
| 51 | 54 | /** |
| 52 | 55 | * {@inheritDoc} |
| 56 | + * | |
| 53 | 57 | * @param o1 {@inheritDoc} |
| 54 | 58 | * @param o2 {@inheritDoc} |
| 55 | 59 | * @return {@inheritDoc} |
| @@ -38,6 +38,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * 3頂点を設定する。 |
| 41 | + * | |
| 41 | 42 | * @param vtx1 頂点1 |
| 42 | 43 | * @param vtx2 頂点2 |
| 43 | 44 | * @param vtx3 頂点3 |
| @@ -61,10 +62,11 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 61 | 62 | |
| 62 | 63 | /** |
| 63 | 64 | * 3頂点を返す。 |
| 65 | + * | |
| 64 | 66 | * @param store 頂点格納用配列。nullもしくは3要素に満たない場合は無視され、 |
| 65 | - * 新規に格納用配列が生成される。 | |
| 67 | + * 新規に格納用配列が生成される。 | |
| 66 | 68 | * @return 先頭3要素に3頂点が収められた配列。未設定要素にはnullが入る。 |
| 67 | - * 引数が長さ3以上の配列であれば引数と同じ配列が返る。 | |
| 69 | + * 引数が長さ3以上の配列であれば引数と同じ配列が返る。 | |
| 68 | 70 | */ |
| 69 | 71 | public Vertex[] getTriangle(Vertex[] store){ |
| 70 | 72 | Vertex[] result; |
| @@ -83,6 +85,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 83 | 85 | |
| 84 | 86 | /** |
| 85 | 87 | * 頂点その1を返す。 |
| 88 | + * | |
| 86 | 89 | * @return 頂点その1 |
| 87 | 90 | */ |
| 88 | 91 | public Vertex getVertex1(){ |
| @@ -91,6 +94,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 91 | 94 | |
| 92 | 95 | /** |
| 93 | 96 | * 頂点その2を返す。 |
| 97 | + * | |
| 94 | 98 | * @return 頂点その2 |
| 95 | 99 | */ |
| 96 | 100 | public Vertex getVertex2(){ |
| @@ -99,6 +103,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 99 | 103 | |
| 100 | 104 | /** |
| 101 | 105 | * 頂点その3を返す。 |
| 106 | + * | |
| 102 | 107 | * @return 頂点その3 |
| 103 | 108 | */ |
| 104 | 109 | public Vertex getVertex3(){ |
| @@ -109,11 +114,12 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 109 | 114 | * {@inheritDoc} |
| 110 | 115 | * 頂点を返す反復子を生成する。 |
| 111 | 116 | * 反復子がnullを返す可能性もありうる。 |
| 117 | + * | |
| 112 | 118 | * @return {@inheritDoc} |
| 113 | 119 | */ |
| 114 | 120 | @Override |
| 115 | 121 | public Iterator<Vertex> iterator(){ |
| 116 | - List<Vertex> list = new ArrayList<Vertex>(TRIANGLE); | |
| 122 | + List<Vertex> list = new ArrayList<>(TRIANGLE); | |
| 117 | 123 | |
| 118 | 124 | list.add(this.vertex1); |
| 119 | 125 | list.add(this.vertex2); |
| @@ -124,6 +130,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 124 | 130 | |
| 125 | 131 | /** |
| 126 | 132 | * 3頂点全てが設定されているか判定する。 |
| 133 | + * | |
| 127 | 134 | * @return 3頂点とも非nullが設定されていればtrue |
| 128 | 135 | */ |
| 129 | 136 | public boolean isCompleted(){ |
| @@ -136,6 +143,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 136 | 143 | |
| 137 | 144 | /** |
| 138 | 145 | * {@inheritDoc} |
| 146 | + * | |
| 139 | 147 | * @param num {@inheritDoc} |
| 140 | 148 | */ |
| 141 | 149 | @Override |
| @@ -146,6 +154,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 146 | 154 | |
| 147 | 155 | /** |
| 148 | 156 | * {@inheritDoc} |
| 157 | + * | |
| 149 | 158 | * @return {@inheritDoc} |
| 150 | 159 | */ |
| 151 | 160 | @Override |
| @@ -155,6 +164,7 @@ public class Surface implements SerialNumbered, Iterable<Vertex> { | ||
| 155 | 164 | |
| 156 | 165 | /** |
| 157 | 166 | * {@inheritDoc} |
| 167 | + * | |
| 158 | 168 | * @return {@inheritDoc} |
| 159 | 169 | */ |
| 160 | 170 | @Override |
| @@ -33,7 +33,7 @@ public class ToonMap { | ||
| 33 | 33 | private static final int IDX_SP = 0xff; // 特殊トゥーンのインデックス |
| 34 | 34 | |
| 35 | 35 | static{ |
| 36 | - Map<Integer, String> map = new TreeMap<Integer, String>(); | |
| 36 | + Map<Integer, String> map = new TreeMap<>(); | |
| 37 | 37 | |
| 38 | 38 | int idx = 0x00; |
| 39 | 39 | map.put(idx++, "toon01.bmp"); |
| @@ -57,7 +57,7 @@ public class ToonMap { | ||
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | private final Map<Integer, String> toonDefMap = |
| 60 | - new TreeMap<Integer, String>(DEF_TOONMAP); | |
| 60 | + new TreeMap<>(DEF_TOONMAP); | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | 63 | /** |
| @@ -47,6 +47,7 @@ public class Vertex implements SerialNumbered { | ||
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * 頂点位置座標を返す。 |
| 50 | + * | |
| 50 | 51 | * @return 頂点の位置座標 |
| 51 | 52 | */ |
| 52 | 53 | public MkPos3D getPosition(){ |
| @@ -55,6 +56,7 @@ public class Vertex implements SerialNumbered { | ||
| 55 | 56 | |
| 56 | 57 | /** |
| 57 | 58 | * 法線ベクトルを返す。 |
| 59 | + * | |
| 58 | 60 | * @return 法線ベクトル |
| 59 | 61 | */ |
| 60 | 62 | public MkVec3D getNormal(){ |
| @@ -63,6 +65,7 @@ public class Vertex implements SerialNumbered { | ||
| 63 | 65 | |
| 64 | 66 | /** |
| 65 | 67 | * UVマップ座標を返す。 |
| 68 | + * | |
| 66 | 69 | * @return UVマップ情報 |
| 67 | 70 | */ |
| 68 | 71 | public MkPos2D getUVPosition(){ |
| @@ -71,6 +74,7 @@ public class Vertex implements SerialNumbered { | ||
| 71 | 74 | |
| 72 | 75 | /** |
| 73 | 76 | * 頂点の属するボーンを設定する。 |
| 77 | + * | |
| 74 | 78 | * @param boneAArg ボーンA |
| 75 | 79 | * @param boneBArg ボーンB |
| 76 | 80 | * @throws NullPointerException 引数がnull |
| @@ -88,6 +92,7 @@ public class Vertex implements SerialNumbered { | ||
| 88 | 92 | |
| 89 | 93 | /** |
| 90 | 94 | * ボーンAを返す。 |
| 95 | + * | |
| 91 | 96 | * @return ボーンA |
| 92 | 97 | */ |
| 93 | 98 | public BoneInfo getBoneA(){ |
| @@ -96,6 +101,7 @@ public class Vertex implements SerialNumbered { | ||
| 96 | 101 | |
| 97 | 102 | /** |
| 98 | 103 | * ボーンBを返す。 |
| 104 | + * | |
| 99 | 105 | * @return ボーンB |
| 100 | 106 | */ |
| 101 | 107 | public BoneInfo getBoneB(){ |
| @@ -104,12 +110,13 @@ public class Vertex implements SerialNumbered { | ||
| 104 | 110 | |
| 105 | 111 | /** |
| 106 | 112 | * ボーンAのウェイト値を設定する。 |
| 113 | + * | |
| 107 | 114 | * @param weight ウェイト値。0(影響小)-100(影響大) |
| 108 | 115 | * @throws IllegalArgumentException ウェイト値が範囲外 |
| 109 | 116 | */ |
| 110 | 117 | public void setWeightA(int weight) throws IllegalArgumentException{ |
| 111 | - if( weight < MIN_WEIGHT | |
| 112 | - || MAX_WEIGHT < weight ){ | |
| 118 | + if( weight < MIN_WEIGHT | |
| 119 | + || MAX_WEIGHT < weight ){ | |
| 113 | 120 | throw new IllegalArgumentException(); |
| 114 | 121 | } |
| 115 | 122 | this.boneWeight = weight; |
| @@ -118,6 +125,7 @@ public class Vertex implements SerialNumbered { | ||
| 118 | 125 | |
| 119 | 126 | /** |
| 120 | 127 | * ボーンBのウェイト値を設定する。 |
| 128 | + * | |
| 121 | 129 | * @param weight ウェイト値。0(影響小)-100(影響大) |
| 122 | 130 | * @throws IllegalArgumentException ウェイト値が範囲外 |
| 123 | 131 | */ |
| @@ -128,6 +136,7 @@ public class Vertex implements SerialNumbered { | ||
| 128 | 136 | |
| 129 | 137 | /** |
| 130 | 138 | * ボーンAのウェイト値を返す。 |
| 139 | + * | |
| 131 | 140 | * @return ウェイト値 |
| 132 | 141 | */ |
| 133 | 142 | public int getWeightA(){ |
| @@ -136,6 +145,7 @@ public class Vertex implements SerialNumbered { | ||
| 136 | 145 | |
| 137 | 146 | /** |
| 138 | 147 | * ボーンBのウェイト値を返す。 |
| 148 | + * | |
| 139 | 149 | * @return ウェイト値 |
| 140 | 150 | */ |
| 141 | 151 | public int getWeightB(){ |
| @@ -145,6 +155,7 @@ public class Vertex implements SerialNumbered { | ||
| 145 | 155 | |
| 146 | 156 | /** |
| 147 | 157 | * ボーンAのウェイト率を返す。 |
| 158 | + * | |
| 148 | 159 | * @return ウェイト率。0.0(影響小)-1.0(影響大) |
| 149 | 160 | */ |
| 150 | 161 | public float getWeightRatioA(){ |
| @@ -153,6 +164,7 @@ public class Vertex implements SerialNumbered { | ||
| 153 | 164 | |
| 154 | 165 | /** |
| 155 | 166 | * ボーンBのウェイト率を返す。 |
| 167 | + * | |
| 156 | 168 | * @return ウェイト率。0.0(影響小)-1.0(影響大) |
| 157 | 169 | */ |
| 158 | 170 | public float getWeightRatioB(){ |
| @@ -163,6 +175,7 @@ public class Vertex implements SerialNumbered { | ||
| 163 | 175 | /** |
| 164 | 176 | * エッジを表示するか設定する。 |
| 165 | 177 | * マテリアル材質単位の設定より優先度は高い。 |
| 178 | + * | |
| 166 | 179 | * @param show 表示するならtrue |
| 167 | 180 | */ |
| 168 | 181 | public void setEdgeAppearance(boolean show){ |
| @@ -173,6 +186,7 @@ public class Vertex implements SerialNumbered { | ||
| 173 | 186 | /** |
| 174 | 187 | * エッジを表示するか判定する。 |
| 175 | 188 | * マテリアル材質単位の設定より優先度は高い。 |
| 189 | + * | |
| 176 | 190 | * @return 表示するならtrue |
| 177 | 191 | */ |
| 178 | 192 | public boolean getEdgeAppearance(){ |
| @@ -181,6 +195,7 @@ public class Vertex implements SerialNumbered { | ||
| 181 | 195 | |
| 182 | 196 | /** |
| 183 | 197 | * {@inheritDoc} |
| 198 | + * | |
| 184 | 199 | * @param num {@inheritDoc} |
| 185 | 200 | */ |
| 186 | 201 | @Override |
| @@ -191,6 +206,7 @@ public class Vertex implements SerialNumbered { | ||
| 191 | 206 | |
| 192 | 207 | /** |
| 193 | 208 | * {@inheritDoc} |
| 209 | + * | |
| 194 | 210 | * @return {@inheritDoc} |
| 195 | 211 | */ |
| 196 | 212 | @Override |
| @@ -200,6 +216,7 @@ public class Vertex implements SerialNumbered { | ||
| 200 | 216 | |
| 201 | 217 | /** |
| 202 | 218 | * {@inheritDoc} |
| 219 | + * | |
| 203 | 220 | * @return {@inheritDoc} |
| 204 | 221 | */ |
| 205 | 222 | @Override |
| @@ -158,7 +158,7 @@ class BoneBuilder implements PmdBoneHandler { | ||
| 158 | 158 | * 所属グループの無いボーンをデフォルトボーングループへ登録する。 |
| 159 | 159 | */ |
| 160 | 160 | private void pickOrphanBone(){ |
| 161 | - List<BoneInfo> orpahnList = new LinkedList<BoneInfo>(); | |
| 161 | + List<BoneInfo> orpahnList = new LinkedList<>(); | |
| 162 | 162 | orpahnList.addAll(this.boneList); |
| 163 | 163 | for(BoneGroup group : this.boneGroupList){ |
| 164 | 164 | orpahnList.removeAll(group.getBoneList()); |
| @@ -34,7 +34,7 @@ class MorphBuilder implements PmdMorphHandler { | ||
| 34 | 34 | private MorphPart currentMorphPart; |
| 35 | 35 | private final List<Vertex> vertexList; |
| 36 | 36 | |
| 37 | - private final List<Vertex> morphVertexList = new ArrayList<Vertex>(); | |
| 37 | + private final List<Vertex> morphVertexList = new ArrayList<>(); | |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * コンストラクタ。 |
| @@ -183,7 +183,7 @@ class MorphBuilder implements PmdMorphHandler { | ||
| 183 | 183 | |
| 184 | 184 | List<MorphPart> partList = this.morphMap.get(type); |
| 185 | 185 | if(partList == null){ |
| 186 | - partList = new LinkedList<MorphPart>(); | |
| 186 | + partList = new LinkedList<>(); | |
| 187 | 187 | this.morphMap.put(type, partList); |
| 188 | 188 | } |
| 189 | 189 | partList.add(part); |
| @@ -38,8 +38,8 @@ import jp.sfjp.mikutoga.pmd.model.Vertex; | ||
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * PMDファイルのエクスポーター(拡張無し基本フォーマット)。 |
| 41 | - * <p> | |
| 42 | - * 英名対応以降のPMDファイルフォーマットを | |
| 41 | + * | |
| 42 | + * <p>英名対応以降のPMDファイルフォーマットを | |
| 43 | 43 | * 使いたくない場合はこのエクスポーターを用いて出力せよ。 |
| 44 | 44 | */ |
| 45 | 45 | public class PmdExporterBase extends BinaryExporter{ |
| @@ -88,6 +88,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | 90 | * コンストラクタ。 |
| 91 | + * | |
| 91 | 92 | * @param stream 出力ストリーム |
| 92 | 93 | * @throws NullPointerException 引数がnull |
| 93 | 94 | */ |
| @@ -100,6 +101,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 100 | 101 | /** |
| 101 | 102 | * 改行文字の正規化を行う。 |
| 102 | 103 | * CR(0x0d)およびCRLF(0x0d0a)がLF(0x0a)へと正規化される。 |
| 104 | + * | |
| 103 | 105 | * @param text 文字列 |
| 104 | 106 | * @return 正規化の行われた文字列。 |
| 105 | 107 | */ |
| @@ -117,11 +119,12 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 117 | 119 | * 文字列の改行記号はLF(0x0a)に正規化される。 |
| 118 | 120 | * エンコード結果がバイト長に満たない場合は |
| 119 | 121 | * 1つの0x00及びそれに続く複数の0xfdがパディングされる。 |
| 122 | + * | |
| 120 | 123 | * @param text 文字列 |
| 121 | 124 | * @param maxByteLength バイト長指定 |
| 122 | 125 | * @throws IOException 出力エラー |
| 123 | 126 | * @throws IllegalTextExportException エンコード結果が |
| 124 | - * 指定バイト長をはみ出した。 | |
| 127 | + * 指定バイト長をはみ出した。 | |
| 125 | 128 | */ |
| 126 | 129 | protected void dumpText(String text, int maxByteLength) |
| 127 | 130 | throws IOException, IllegalTextExportException{ |
| @@ -131,6 +134,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 131 | 134 | |
| 132 | 135 | /** |
| 133 | 136 | * モデルデータをPMDファイル形式で出力する。 |
| 137 | + * | |
| 134 | 138 | * @param model モデルデータ |
| 135 | 139 | * @throws IOException 出力エラー |
| 136 | 140 | * @throws IllegalPmdDataException モデルデータに不備が発見された |
| @@ -156,6 +160,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 156 | 160 | |
| 157 | 161 | /** |
| 158 | 162 | * モデル基本情報を出力する。 |
| 163 | + * | |
| 159 | 164 | * @param model モデルデータ |
| 160 | 165 | * @throws IOException 出力エラー |
| 161 | 166 | * @throws IllegalTextExportException モデル名もしくは説明が長すぎる |
| @@ -179,6 +184,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 179 | 184 | |
| 180 | 185 | /** |
| 181 | 186 | * 頂点リストを出力する。 |
| 187 | + * | |
| 182 | 188 | * @param model モデルデータ |
| 183 | 189 | * @throws IOException 出力エラー |
| 184 | 190 | */ |
| @@ -200,6 +206,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 200 | 206 | |
| 201 | 207 | /** |
| 202 | 208 | * 個別の頂点データを出力する。 |
| 209 | + * | |
| 203 | 210 | * @param vertex 頂点 |
| 204 | 211 | * @throws IOException 出力エラー |
| 205 | 212 | */ |
| @@ -233,6 +240,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 233 | 240 | |
| 234 | 241 | /** |
| 235 | 242 | * 面リストを出力する。 |
| 243 | + * | |
| 236 | 244 | * @param model モデルデータ |
| 237 | 245 | * @throws IOException 出力エラー |
| 238 | 246 | */ |
| @@ -262,6 +270,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 262 | 270 | |
| 263 | 271 | /** |
| 264 | 272 | * マテリアル素材リストを出力する。 |
| 273 | + * | |
| 265 | 274 | * @param model モデルデータ |
| 266 | 275 | * @throws IOException 出力エラー |
| 267 | 276 | * @throws IllegalTextExportException シェーディングファイル情報が長すぎる |
| @@ -285,6 +294,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 285 | 294 | |
| 286 | 295 | /** |
| 287 | 296 | * フォンシェーディングの色情報を出力する。 |
| 297 | + * | |
| 288 | 298 | * @param material マテリアル情報 |
| 289 | 299 | * @throws IOException 出力エラー |
| 290 | 300 | */ |
| @@ -317,6 +327,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 317 | 327 | |
| 318 | 328 | /** |
| 319 | 329 | * シェーディング情報を出力する。 |
| 330 | + * | |
| 320 | 331 | * @param material マテリアル情報 |
| 321 | 332 | * @throws IOException 出力エラー |
| 322 | 333 | * @throws IllegalTextExportException ファイル名が長すぎる |
| @@ -343,6 +354,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 343 | 354 | |
| 344 | 355 | /** |
| 345 | 356 | * シェーディングファイル情報を出力する。 |
| 357 | + * | |
| 346 | 358 | * @param shade シェーディング情報 |
| 347 | 359 | * @throws IOException 出力エラー |
| 348 | 360 | * @throws IllegalTextExportException ファイル名が長すぎる |
| @@ -372,6 +384,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 372 | 384 | |
| 373 | 385 | /** |
| 374 | 386 | * ボーンリストを出力する。 |
| 387 | + * | |
| 375 | 388 | * @param model モデルデータ |
| 376 | 389 | * @throws IOException 出力エラー |
| 377 | 390 | * @throws IllegalTextExportException ボーン名が長すぎる |
| @@ -394,6 +407,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 394 | 407 | |
| 395 | 408 | /** |
| 396 | 409 | * 個別のボーン情報を出力する。 |
| 410 | + * | |
| 397 | 411 | * @param bone ボーン情報 |
| 398 | 412 | * @throws IOException 出力エラー |
| 399 | 413 | * @throws IllegalTextExportException ボーン名が長すぎる |
| @@ -431,6 +445,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 431 | 445 | |
| 432 | 446 | /** |
| 433 | 447 | * IKチェーンリストを出力する。 |
| 448 | + * | |
| 434 | 449 | * @param model モデルデータ |
| 435 | 450 | * @throws IOException 出力エラー |
| 436 | 451 | */ |
| @@ -452,6 +467,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 452 | 467 | |
| 453 | 468 | /** |
| 454 | 469 | * IKチェーンを出力する。 |
| 470 | + * | |
| 455 | 471 | * @param chain IKチェーン |
| 456 | 472 | * @throws IOException 出力エラー |
| 457 | 473 | */ |
| @@ -485,6 +501,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 485 | 501 | |
| 486 | 502 | /** |
| 487 | 503 | * モーフリストを出力する。 |
| 504 | + * | |
| 488 | 505 | * @param model モデルデータ |
| 489 | 506 | * @throws IOException 出力エラー |
| 490 | 507 | * @throws IllegalTextExportException モーフ名が長すぎる |
| @@ -493,7 +510,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 493 | 510 | throws IOException, IllegalTextExportException{ |
| 494 | 511 | Map<MorphType, List<MorphPart>> morphMap = model.getMorphMap(); |
| 495 | 512 | Set<MorphType> typeSet = morphMap.keySet(); |
| 496 | - List<MorphPart> morphPartList = new LinkedList<MorphPart>(); | |
| 513 | + List<MorphPart> morphPartList = new LinkedList<>(); | |
| 497 | 514 | |
| 498 | 515 | for(MorphType type : typeSet){ |
| 499 | 516 | List<MorphPart> partList = morphMap.get(type); |
| @@ -533,6 +550,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 533 | 550 | |
| 534 | 551 | /** |
| 535 | 552 | * BASEモーフを出力する。 |
| 553 | + * | |
| 536 | 554 | * @param model モデルデータ |
| 537 | 555 | * @throws IOException 出力エラー |
| 538 | 556 | * @throws IllegalTextExportException モーフ名が長すぎる |
| @@ -557,6 +575,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 557 | 575 | |
| 558 | 576 | /** |
| 559 | 577 | * モーフグループを出力する。 |
| 578 | + * | |
| 560 | 579 | * @param model モデルデータ |
| 561 | 580 | * @throws IOException 出力エラー |
| 562 | 581 | */ |
| @@ -573,7 +592,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 573 | 592 | } |
| 574 | 593 | dumpByte(totalMorph); |
| 575 | 594 | |
| 576 | - List<MorphType> typeList = new LinkedList<MorphType>(); | |
| 595 | + List<MorphType> typeList = new LinkedList<>(); | |
| 577 | 596 | for(MorphType type : typeSet){ |
| 578 | 597 | assert ! type.isBase(); |
| 579 | 598 | typeList.add(type); |
| @@ -596,6 +615,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 596 | 615 | /** |
| 597 | 616 | * ボーングループリストを出力する。 |
| 598 | 617 | * デフォルトボーングループ内訳は出力されない。 |
| 618 | + * | |
| 599 | 619 | * @param model モデルデータ |
| 600 | 620 | * @throws IOException 出力エラー |
| 601 | 621 | * @throws IllegalTextExportException ボーングループ名が長すぎる |
| @@ -632,6 +652,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 632 | 652 | /** |
| 633 | 653 | * 各種通し番号をshort値で出力する。 |
| 634 | 654 | * short値に収まらない上位ビットは捨てられる。 |
| 655 | + * | |
| 635 | 656 | * @param obj 番号づけられたオブジェクト |
| 636 | 657 | * @throws IOException 出力エラー |
| 637 | 658 | */ |
| @@ -644,6 +665,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 644 | 665 | |
| 645 | 666 | /** |
| 646 | 667 | * 2次元位置情報を出力する。 |
| 668 | + * | |
| 647 | 669 | * @param position 2次元位置情報 |
| 648 | 670 | * @throws IOException 出力エラー |
| 649 | 671 | */ |
| @@ -659,6 +681,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 659 | 681 | |
| 660 | 682 | /** |
| 661 | 683 | * 3次元位置情報を出力する。 |
| 684 | + * | |
| 662 | 685 | * @param position 3次元位置情報 |
| 663 | 686 | * @throws IOException 出力エラー |
| 664 | 687 | */ |
| @@ -676,6 +699,7 @@ public class PmdExporterBase extends BinaryExporter{ | ||
| 676 | 699 | |
| 677 | 700 | /** |
| 678 | 701 | * 3次元ベクトル情報を出力する。 |
| 702 | + * | |
| 679 | 703 | * @param vector 3次元ベクトル |
| 680 | 704 | * @throws IOException 出力エラー |
| 681 | 705 | */ |
| @@ -22,14 +22,15 @@ import jp.sfjp.mikutoga.pmd.model.PmdModel; | ||
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * PMDファイルのエクスポーター(拡張1:英名対応)。 |
| 25 | - * <p> | |
| 26 | - * 任意のトゥーンファイル名対応以降のPMDファイルフォーマットを | |
| 25 | + * | |
| 26 | + * <p>任意のトゥーンファイル名対応以降のPMDファイルフォーマットを | |
| 27 | 27 | * 使いたくない場合はこのエクスポーターを用いて出力せよ。 |
| 28 | 28 | */ |
| 29 | 29 | public class PmdExporterExt1 extends PmdExporterBase{ |
| 30 | 30 | |
| 31 | 31 | /** |
| 32 | 32 | * コンストラクタ。 |
| 33 | + * | |
| 33 | 34 | * @param stream 出力ストリーム |
| 34 | 35 | * @throws NullPointerException 引数がnull |
| 35 | 36 | */ |
| @@ -41,6 +42,7 @@ public class PmdExporterExt1 extends PmdExporterBase{ | ||
| 41 | 42 | |
| 42 | 43 | /** |
| 43 | 44 | * {@inheritDoc} |
| 45 | + * | |
| 44 | 46 | * @param model {@inheritDoc} |
| 45 | 47 | * @throws IOException {@inheritDoc} |
| 46 | 48 | * @throws IllegalPmdDataException {@inheritDoc} |
| @@ -57,6 +59,7 @@ public class PmdExporterExt1 extends PmdExporterBase{ | ||
| 57 | 59 | |
| 58 | 60 | /** |
| 59 | 61 | * 英語名情報を出力する。 |
| 62 | + * | |
| 60 | 63 | * @param model モデルデータ |
| 61 | 64 | * @throws IOException 出力エラー |
| 62 | 65 | * @throws IllegalPmdDataException 文字列が長すぎる。 |
| @@ -87,6 +90,7 @@ public class PmdExporterExt1 extends PmdExporterBase{ | ||
| 87 | 90 | |
| 88 | 91 | /** |
| 89 | 92 | * モデル基本情報を英語で出力する。 |
| 93 | + * | |
| 90 | 94 | * @param model モデルデータ |
| 91 | 95 | * @throws IOException 出力エラー |
| 92 | 96 | * @throws IllegalTextExportException 文字列が長すぎる。 |
| @@ -106,6 +110,7 @@ public class PmdExporterExt1 extends PmdExporterBase{ | ||
| 106 | 110 | |
| 107 | 111 | /** |
| 108 | 112 | * ボーン英語名情報を出力する。 |
| 113 | + * | |
| 109 | 114 | * @param model モデルデータ |
| 110 | 115 | * @throws IOException 出力エラー |
| 111 | 116 | * @throws IllegalTextExportException 文字列が長すぎる。 |
| @@ -123,6 +128,7 @@ public class PmdExporterExt1 extends PmdExporterBase{ | ||
| 123 | 128 | |
| 124 | 129 | /** |
| 125 | 130 | * モーフ英語名情報を出力する。 |
| 131 | + * | |
| 126 | 132 | * @param model モデルデータ |
| 127 | 133 | * @throws IOException 出力エラー |
| 128 | 134 | * @throws IllegalTextExportException 文字列が長すぎる。 |
| @@ -147,6 +153,7 @@ public class PmdExporterExt1 extends PmdExporterBase{ | ||
| 147 | 153 | |
| 148 | 154 | /** |
| 149 | 155 | * ボーングループ英語名情報を出力する。 |
| 156 | + * | |
| 150 | 157 | * @param model モデルデータ |
| 151 | 158 | * @throws IOException 出力エラー |
| 152 | 159 | * @throws IllegalTextExportException 文字列が長すぎる |
| @@ -17,14 +17,15 @@ import jp.sfjp.mikutoga.pmd.model.ToonMap; | ||
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * PMDファイルのエクスポーター(拡張2:任意のトゥーンファイル名対応)。 |
| 20 | - * <p> | |
| 21 | - * 物理演算対応以降のPMDファイルフォーマットを | |
| 20 | + * | |
| 21 | + * <p>物理演算対応以降のPMDファイルフォーマットを | |
| 22 | 22 | * 使いたくない場合はこのエクスポーターを用いて出力せよ。 |
| 23 | 23 | */ |
| 24 | 24 | public class PmdExporterExt2 extends PmdExporterExt1{ |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * コンストラクタ。 |
| 28 | + * | |
| 28 | 29 | * @param stream 出力ストリーム |
| 29 | 30 | * @throws NullPointerException 引数がnull |
| 30 | 31 | */ |
| @@ -36,6 +37,7 @@ public class PmdExporterExt2 extends PmdExporterExt1{ | ||
| 36 | 37 | |
| 37 | 38 | /** |
| 38 | 39 | * {@inheritDoc} |
| 40 | + * | |
| 39 | 41 | * @param model {@inheritDoc} |
| 40 | 42 | * @throws IOException {@inheritDoc} |
| 41 | 43 | * @throws IllegalPmdDataException {@inheritDoc} |
| @@ -56,6 +58,7 @@ public class PmdExporterExt2 extends PmdExporterExt1{ | ||
| 56 | 58 | |
| 57 | 59 | /** |
| 58 | 60 | * 独自トゥーンファイルテーブルを出力する。 |
| 61 | + * | |
| 59 | 62 | * @param model モデルデータ |
| 60 | 63 | * @throws IOException 出力エラー |
| 61 | 64 | * @throws IllegalTextExportException トゥーンファイル名が長すぎる |
| @@ -27,8 +27,8 @@ import jp.sfjp.mikutoga.pmd.model.RigidShape; | ||
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * PMDファイルのエクスポーター(拡張3:物理演算対応)。 |
| 30 | - * <p> | |
| 31 | - * 物理演算対応のPMDファイルフォーマットを | |
| 30 | + * | |
| 31 | + * <p>物理演算対応のPMDファイルフォーマットを | |
| 32 | 32 | * 使いたい場合はこのエクスポーターを用いて出力せよ。 |
| 33 | 33 | */ |
| 34 | 34 | public class PmdExporterExt3 extends PmdExporterExt2{ |
| @@ -37,6 +37,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * コンストラクタ。 |
| 40 | + * | |
| 40 | 41 | * @param stream 出力ストリーム |
| 41 | 42 | * @throws NullPointerException 引数がnull |
| 42 | 43 | */ |
| @@ -48,6 +49,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 48 | 49 | |
| 49 | 50 | /** |
| 50 | 51 | * {@inheritDoc} |
| 52 | + * | |
| 51 | 53 | * @param model {@inheritDoc} |
| 52 | 54 | * @throws IOException {@inheritDoc} |
| 53 | 55 | * @throws IllegalPmdDataException {@inheritDoc} |
| @@ -69,6 +71,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 69 | 71 | |
| 70 | 72 | /** |
| 71 | 73 | * 剛体リストを出力する。 |
| 74 | + * | |
| 72 | 75 | * @param model モデルデータ |
| 73 | 76 | * @throws IOException 出力エラー |
| 74 | 77 | * @throws IllegalTextExportException 長すぎる剛体名 |
| @@ -90,6 +93,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 90 | 93 | |
| 91 | 94 | /** |
| 92 | 95 | * 個別の剛体情報を出力する。 |
| 96 | + * | |
| 93 | 97 | * @param rigid 剛体 |
| 94 | 98 | * @throws IOException 出力エラー |
| 95 | 99 | * @throws IllegalTextExportException 長すぎる剛体名 |
| @@ -130,6 +134,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 130 | 134 | |
| 131 | 135 | /** |
| 132 | 136 | * 剛体形状を出力する。 |
| 137 | + * | |
| 133 | 138 | * @param shape 剛体形状 |
| 134 | 139 | * @throws IOException 出力エラー |
| 135 | 140 | */ |
| @@ -151,6 +156,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 151 | 156 | |
| 152 | 157 | /** |
| 153 | 158 | * 力学設定を出力する。 |
| 159 | + * | |
| 154 | 160 | * @param dynamics 力学設定 |
| 155 | 161 | * @throws IOException 出力エラー |
| 156 | 162 | */ |
| @@ -173,6 +179,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 173 | 179 | |
| 174 | 180 | /** |
| 175 | 181 | * ジョイントリストを出力する。 |
| 182 | + * | |
| 176 | 183 | * @param model モデルデータ |
| 177 | 184 | * @throws IOException 出力エラー |
| 178 | 185 | * @throws IllegalTextExportException 長すぎるジョイント名 |
| @@ -194,6 +201,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 194 | 201 | |
| 195 | 202 | /** |
| 196 | 203 | * 個別のジョイント情報を出力する。 |
| 204 | + * | |
| 197 | 205 | * @param joint ジョイント |
| 198 | 206 | * @throws IOException 出力エラー |
| 199 | 207 | * @throws IllegalTextExportException 長すぎるジョイント名 |
| @@ -223,6 +231,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 223 | 231 | |
| 224 | 232 | /** |
| 225 | 233 | * 3次元範囲制約を出力する。 |
| 234 | + * | |
| 226 | 235 | * @param range 3次元範囲制約 |
| 227 | 236 | * @throws IOException 出力エラー |
| 228 | 237 | */ |
| @@ -248,6 +257,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 248 | 257 | |
| 249 | 258 | /** |
| 250 | 259 | * ラジアンによる3次元姿勢情報を出力する。 |
| 260 | + * | |
| 251 | 261 | * @param rad 3次元姿勢情報 |
| 252 | 262 | * @throws IOException 出力エラー |
| 253 | 263 | */ |
| @@ -265,6 +275,7 @@ public class PmdExporterExt3 extends PmdExporterExt2{ | ||
| 265 | 275 | |
| 266 | 276 | /** |
| 267 | 277 | * 度数法による3次元姿勢情報を出力する。 |
| 278 | + * | |
| 268 | 279 | * @param deg 3次元姿勢情報 |
| 269 | 280 | * @throws IOException 出力エラー |
| 270 | 281 | */ |
| @@ -40,8 +40,10 @@ public class PmdLoader { | ||
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * 正常パース時に読み残したデータがあったか判定する。 |
| 43 | + * | |
| 43 | 44 | * <p>MMDでの仕様拡張による |
| 44 | 45 | * PMDファイルフォーマットの拡張が行われた場合を想定。 |
| 46 | + * | |
| 45 | 47 | * @return 読み残したデータがあればtrue |
| 46 | 48 | * @throws IllegalStateException まだパースを試みていない。 |
| 47 | 49 | */ |
| @@ -53,6 +55,7 @@ public class PmdLoader { | ||
| 53 | 55 | /** |
| 54 | 56 | * PMDファイルの読み込みを行いモデル情報を返す。 |
| 55 | 57 | * 1インスタンスにつき一度しかロードできない。 |
| 58 | + * | |
| 56 | 59 | * @param source PMDファイル入力ソース |
| 57 | 60 | * @return モデル情報 |
| 58 | 61 | * @throws IOException 入力エラー |
| @@ -78,7 +81,7 @@ public class PmdLoader { | ||
| 78 | 81 | RigidBuilder rigidBuilder = new RigidBuilder(model); |
| 79 | 82 | JointBuilder jointBuilder = new JointBuilder(model); |
| 80 | 83 | |
| 81 | - List<MorphPart> morphPartList = new ArrayList<MorphPart>(); | |
| 84 | + List<MorphPart> morphPartList = new ArrayList<>(); | |
| 82 | 85 | morphBuilder.setMorphPartList(morphPartList); |
| 83 | 86 | textBuilder.setMorphPartList(morphPartList); |
| 84 | 87 |
| @@ -18,6 +18,12 @@ import java.lang.annotation.Target; | ||
| 18 | 18 | @Target(ElementType.METHOD) |
| 19 | 19 | @Retention(RetentionPolicy.RUNTIME) |
| 20 | 20 | @interface CloseXmlMark { |
| 21 | - /** タグ指定。 */ | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * タグ指定。 | |
| 24 | + * | |
| 25 | + * @return tag | |
| 26 | + */ | |
| 22 | 27 | PmdTag value(); |
| 28 | + | |
| 23 | 29 | } |
| @@ -18,6 +18,12 @@ import java.lang.annotation.Target; | ||
| 18 | 18 | @Target(ElementType.METHOD) |
| 19 | 19 | @Retention(RetentionPolicy.RUNTIME) |
| 20 | 20 | @interface OpenXmlMark { |
| 21 | - /** タグ指定。 */ | |
| 21 | + | |
| 22 | + /** | |
| 23 | + * タグ指定。 | |
| 24 | + * | |
| 25 | + * @return tag | |
| 26 | + */ | |
| 22 | 27 | PmdTag value(); |
| 28 | + | |
| 23 | 29 | } |
| @@ -93,7 +93,7 @@ enum PmdTag { | ||
| 93 | 93 | ; |
| 94 | 94 | |
| 95 | 95 | private static final Map<String, PmdTag> NAME_MAP = |
| 96 | - new HashMap<String, PmdTag>(); | |
| 96 | + new HashMap<>(); | |
| 97 | 97 | |
| 98 | 98 | static{ |
| 99 | 99 | for(PmdTag tag : values()){ |
| @@ -11,7 +11,7 @@ import java.io.IOException; | ||
| 11 | 11 | import jp.sfjp.mikutoga.corelib.I18nText; |
| 12 | 12 | import jp.sfjp.mikutoga.pmd.model.PmdModel; |
| 13 | 13 | import jp.sfjp.mikutoga.xml.BasicXmlExporter; |
| 14 | -import jp.sfjp.mikutoga.xml.XmlResourceResolver; | |
| 14 | +import jp.sfjp.mikutoga.xml.SchemaUtil; | |
| 15 | 15 | |
| 16 | 16 | /** |
| 17 | 17 | * PMDモーションデータをXMLへエクスポートする。 |
| @@ -225,7 +225,7 @@ public class PmdXmlExporter extends BasicXmlExporter{ | ||
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | ind().putAttr("xmlns", namespace).ln(); |
| 228 | - ind().putAttr("xmlns:" + XSINS, XmlResourceResolver.NS_XSD).ln(); | |
| 228 | + ind().putAttr("xmlns:" + XSINS, SchemaUtil.NS_XSD).ln(); | |
| 229 | 229 | |
| 230 | 230 | ind().putRawText(XSINS).putRawText(":schemaLocation=") |
| 231 | 231 | .putRawCh('"'); |
| @@ -28,41 +28,41 @@ class RefHelper { | ||
| 28 | 28 | |
| 29 | 29 | // マテリアル関連 |
| 30 | 30 | private final List<IdRefHolder<Material>> materialSfcGroupIdRefList = |
| 31 | - new LinkedList<IdRefHolder<Material>>(); | |
| 31 | + new LinkedList<>(); | |
| 32 | 32 | private final List<IdRefHolder<Material>> materialToonIdRefList = |
| 33 | - new LinkedList<IdRefHolder<Material>>(); | |
| 33 | + new LinkedList<>(); | |
| 34 | 34 | private final Map<String, Integer> toonIdxMap = |
| 35 | - new HashMap<String, Integer>(); | |
| 35 | + new HashMap<>(); | |
| 36 | 36 | |
| 37 | 37 | // ボーン関連 |
| 38 | 38 | private final Map<String, BoneInfo> boneIdMap = |
| 39 | - new HashMap<String, BoneInfo>(); | |
| 39 | + new HashMap<>(); | |
| 40 | 40 | private final List<IdRefHolder<BoneInfo>> boneChainIdRefList = |
| 41 | - new LinkedList<IdRefHolder<BoneInfo>>(); | |
| 41 | + new LinkedList<>(); | |
| 42 | 42 | private final List<IdRefHolder<BoneInfo>> boneSourceIdRefList = |
| 43 | - new LinkedList<IdRefHolder<BoneInfo>>(); | |
| 43 | + new LinkedList<>(); | |
| 44 | 44 | |
| 45 | 45 | // モーフ関連 |
| 46 | 46 | private final List<IdRefHolder<MorphVertex>> morphVertexIdRefList = |
| 47 | - new LinkedList<IdRefHolder<MorphVertex>>(); | |
| 47 | + new LinkedList<>(); | |
| 48 | 48 | |
| 49 | 49 | // 剛体関連 |
| 50 | 50 | private final Map<String, RigidInfo> rigidIdMap = |
| 51 | - new HashMap<String, RigidInfo>(); | |
| 51 | + new HashMap<>(); | |
| 52 | 52 | private final Map<String, RigidGroup> rigidGroupIdMap = |
| 53 | - new HashMap<String, RigidGroup>(); | |
| 53 | + new HashMap<>(); | |
| 54 | 54 | private final List<IdRefHolder<RigidInfo>> thghRigidGroupIdRefList = |
| 55 | - new LinkedList<IdRefHolder<RigidInfo>>(); | |
| 55 | + new LinkedList<>(); | |
| 56 | 56 | |
| 57 | 57 | // 面関連 |
| 58 | 58 | private final Map<String, List<Surface>> surfaceGroupIdMap = |
| 59 | - new HashMap<String, List<Surface>>(); | |
| 59 | + new HashMap<>(); | |
| 60 | 60 | private final List<IdRefHolder<Surface>> surfaceVertexIdRef = |
| 61 | - new LinkedList<IdRefHolder<Surface>>(); | |
| 61 | + new LinkedList<>(); | |
| 62 | 62 | |
| 63 | 63 | // 頂点関連 |
| 64 | 64 | private final Map<String, Vertex> vertexIdMap = |
| 65 | - new HashMap<String, Vertex>(); | |
| 65 | + new HashMap<>(); | |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | /** |
| @@ -81,7 +81,7 @@ class RefHelper { | ||
| 81 | 81 | */ |
| 82 | 82 | void addSurfaceGroupIdRef(Material material, String idRef){ |
| 83 | 83 | IdRefHolder<Material> holder = |
| 84 | - new IdRefHolder<Material>(material, idRef); | |
| 84 | + new IdRefHolder<>(material, idRef); | |
| 85 | 85 | this.materialSfcGroupIdRefList.add(holder); |
| 86 | 86 | |
| 87 | 87 | return; |
| @@ -96,7 +96,7 @@ class RefHelper { | ||
| 96 | 96 | List<Surface> surfaceGroup = |
| 97 | 97 | this.surfaceGroupIdMap.get(surfaceGroupId); |
| 98 | 98 | if(surfaceGroup == null){ |
| 99 | - surfaceGroup = new LinkedList<Surface>(); | |
| 99 | + surfaceGroup = new LinkedList<>(); | |
| 100 | 100 | this.surfaceGroupIdMap.put(surfaceGroupId, surfaceGroup); |
| 101 | 101 | } |
| 102 | 102 |
| @@ -130,7 +130,7 @@ class RefHelper { | ||
| 130 | 130 | */ |
| 131 | 131 | void addToonFileIdRef(Material material, String idRef){ |
| 132 | 132 | IdRefHolder<Material> holder = |
| 133 | - new IdRefHolder<Material>(material, idRef); | |
| 133 | + new IdRefHolder<>(material, idRef); | |
| 134 | 134 | this.materialToonIdRefList.add(holder); |
| 135 | 135 | return; |
| 136 | 136 | } |
| @@ -190,7 +190,7 @@ class RefHelper { | ||
| 190 | 190 | void addBoneChain(BoneInfo bone, |
| 191 | 191 | String prevBoneIdRef, String nextBoneIdRef ){ |
| 192 | 192 | IdRefHolder<BoneInfo> holder = |
| 193 | - new IdRefHolder<BoneInfo>(bone, prevBoneIdRef, nextBoneIdRef); | |
| 193 | + new IdRefHolder<>(bone, prevBoneIdRef, nextBoneIdRef); | |
| 194 | 194 | this.boneChainIdRefList.add(holder); |
| 195 | 195 | return; |
| 196 | 196 | } |
| @@ -225,7 +225,7 @@ class RefHelper { | ||
| 225 | 225 | */ |
| 226 | 226 | void addSrcBoneIdRef(BoneInfo bone, String srcBoneIdRef){ |
| 227 | 227 | IdRefHolder<BoneInfo> holder = |
| 228 | - new IdRefHolder<BoneInfo>(bone, srcBoneIdRef); | |
| 228 | + new IdRefHolder<>(bone, srcBoneIdRef); | |
| 229 | 229 | this.boneSourceIdRefList.add(holder); |
| 230 | 230 | return; |
| 231 | 231 | } |
| @@ -253,7 +253,7 @@ class RefHelper { | ||
| 253 | 253 | */ |
| 254 | 254 | void addMorphVertexIdRef(MorphVertex morphVertex, String vertexIdRef){ |
| 255 | 255 | IdRefHolder<MorphVertex> holder = |
| 256 | - new IdRefHolder<MorphVertex>(morphVertex, vertexIdRef); | |
| 256 | + new IdRefHolder<>(morphVertex, vertexIdRef); | |
| 257 | 257 | this.morphVertexIdRefList.add(holder); |
| 258 | 258 | return; |
| 259 | 259 | } |
| @@ -285,7 +285,7 @@ class RefHelper { | ||
| 285 | 285 | */ |
| 286 | 286 | void addThroughRigidGroupIdRef(RigidInfo rigid, String rigidGroupIdRef){ |
| 287 | 287 | IdRefHolder<RigidInfo> holder = |
| 288 | - new IdRefHolder<RigidInfo>(rigid, rigidGroupIdRef); | |
| 288 | + new IdRefHolder<>(rigid, rigidGroupIdRef); | |
| 289 | 289 | this.thghRigidGroupIdRefList.add(holder); |
| 290 | 290 | return; |
| 291 | 291 | } |
| @@ -329,10 +329,10 @@ class RefHelper { | ||
| 329 | 329 | String vtxIdRef2, |
| 330 | 330 | String vtxIdRef3 ){ |
| 331 | 331 | IdRefHolder<Surface> holder = |
| 332 | - new IdRefHolder<Surface>(surface, | |
| 333 | - vtxIdRef1, | |
| 334 | - vtxIdRef2, | |
| 335 | - vtxIdRef3 ); | |
| 332 | + new IdRefHolder<>(surface, | |
| 333 | + vtxIdRef1, | |
| 334 | + vtxIdRef2, | |
| 335 | + vtxIdRef3 ); | |
| 336 | 336 | |
| 337 | 337 | this.surfaceVertexIdRef.add(holder); |
| 338 | 338 |
| @@ -53,7 +53,7 @@ class SaxListener { | ||
| 53 | 53 | */ |
| 54 | 54 | private static Collection<Method> filtMethod(Class<?> klass, |
| 55 | 55 | Class<? extends Annotation> filter ){ |
| 56 | - Collection<Method> result = new LinkedList<Method>(); | |
| 56 | + Collection<Method> result = new LinkedList<>(); | |
| 57 | 57 | |
| 58 | 58 | for(Method method : klass.getDeclaredMethods()){ |
| 59 | 59 | int modifiers = method.getModifiers(); |
| @@ -77,7 +77,7 @@ class SaxListener { | ||
| 77 | 77 | */ |
| 78 | 78 | private static Map<PmdTag, Method> getOpenDispatcher(Class<?> klass){ |
| 79 | 79 | Map<PmdTag, Method> result = |
| 80 | - new EnumMap<PmdTag, Method>(PmdTag.class); | |
| 80 | + new EnumMap<>(PmdTag.class); | |
| 81 | 81 | |
| 82 | 82 | for(Method method : filtMethod(klass, OpenXmlMark.class)){ |
| 83 | 83 | Annotation anno = method.getAnnotation(OpenXmlMark.class); |
| @@ -96,7 +96,7 @@ class SaxListener { | ||
| 96 | 96 | */ |
| 97 | 97 | private static Map<PmdTag, Method> getCloseDispatcher(Class<?> klass){ |
| 98 | 98 | Map<PmdTag, Method> result = |
| 99 | - new EnumMap<PmdTag, Method>(PmdTag.class); | |
| 99 | + new EnumMap<>(PmdTag.class); | |
| 100 | 100 | |
| 101 | 101 | for(Method method : filtMethod(klass, CloseXmlMark.class)){ |
| 102 | 102 | Annotation anno = method.getAnnotation(CloseXmlMark.class); |
| @@ -54,7 +54,7 @@ class SaxMorphListener extends SaxListener{ | ||
| 54 | 54 | void closeMorphList(){ |
| 55 | 55 | Map<MorphType, List<MorphPart>> morphMap = |
| 56 | 56 | getPmdModel().getMorphMap(); |
| 57 | - List<MorphPart> tempList = new LinkedList<MorphPart>(); | |
| 57 | + List<MorphPart> tempList = new LinkedList<>(); | |
| 58 | 58 | |
| 59 | 59 | tempList.addAll(morphMap.get(MorphType.EYEBROW)); |
| 60 | 60 | tempList.addAll(morphMap.get(MorphType.EYE)); |
| @@ -9,15 +9,11 @@ package jp.sfjp.mikutoga.pmd.model.xml; | ||
| 9 | 9 | |
| 10 | 10 | import java.net.URI; |
| 11 | 11 | import java.net.URISyntaxException; |
| 12 | -import jp.sfjp.mikutoga.xml.LocalXmlResource; | |
| 13 | 12 | |
| 14 | 13 | /** |
| 15 | 14 | * 101009形式XML各種リソースの定義。 |
| 16 | 15 | */ |
| 17 | -public final class Schema101009 implements LocalXmlResource{ | |
| 18 | - | |
| 19 | - /** 唯一のシングルトン。 */ | |
| 20 | - public static final Schema101009 SINGLETON; | |
| 16 | +public final class Schema101009{ | |
| 21 | 17 | |
| 22 | 18 | /** 名前空間。 */ |
| 23 | 19 | public static final String NS_PMDXML = |
| @@ -32,8 +28,10 @@ public final class Schema101009 implements LocalXmlResource{ | ||
| 32 | 28 | public static final String LOCAL_SCHEMA_PMDXML = |
| 33 | 29 | "resources/pmdxml-101009.xsd"; |
| 34 | 30 | |
| 35 | - private static final URI URI_SCHEMA_PMDXML = URI.create(SCHEMA_PMDXML); | |
| 36 | - private static final URI RES_SCHEMA_PMDXML; | |
| 31 | + /** schema URI. */ | |
| 32 | + public static final URI URI_SCHEMA_PMDXML = URI.create(SCHEMA_PMDXML); | |
| 33 | + /** local resource URI. */ | |
| 34 | + public static final URI RES_SCHEMA_PMDXML; | |
| 37 | 35 | |
| 38 | 36 | private static final Class<?> THISCLASS = Schema101009.class; |
| 39 | 37 |
| @@ -44,8 +42,6 @@ public final class Schema101009 implements LocalXmlResource{ | ||
| 44 | 42 | }catch(URISyntaxException e){ |
| 45 | 43 | throw new ExceptionInInitializerError(e); |
| 46 | 44 | } |
| 47 | - | |
| 48 | - SINGLETON = new Schema101009(); | |
| 49 | 45 | } |
| 50 | 46 | |
| 51 | 47 |
| @@ -53,30 +49,7 @@ public final class Schema101009 implements LocalXmlResource{ | ||
| 53 | 49 | * コンストラクタ。 |
| 54 | 50 | */ |
| 55 | 51 | private Schema101009(){ |
| 56 | - super(); | |
| 57 | - assert this.getClass() == THISCLASS; | |
| 58 | - return; | |
| 59 | - } | |
| 60 | - | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * {@inheritDoc} | |
| 64 | - * @return {@inheritDoc} | |
| 65 | - * ※101009版。 | |
| 66 | - */ | |
| 67 | - @Override | |
| 68 | - public URI getOriginalResource(){ | |
| 69 | - return URI_SCHEMA_PMDXML; | |
| 70 | - } | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * {@inheritDoc} | |
| 74 | - * ※101009版。 | |
| 75 | - * @return {@inheritDoc} | |
| 76 | - */ | |
| 77 | - @Override | |
| 78 | - public URI getLocalResource(){ | |
| 79 | - return RES_SCHEMA_PMDXML; | |
| 52 | + assert false; | |
| 80 | 53 | } |
| 81 | 54 | |
| 82 | 55 | } |
| @@ -9,15 +9,11 @@ package jp.sfjp.mikutoga.pmd.model.xml; | ||
| 9 | 9 | |
| 10 | 10 | import java.net.URI; |
| 11 | 11 | import java.net.URISyntaxException; |
| 12 | -import jp.sfjp.mikutoga.xml.LocalXmlResource; | |
| 13 | 12 | |
| 14 | 13 | /** |
| 15 | 14 | * 130128形式XML各種リソースの定義。 |
| 16 | 15 | */ |
| 17 | -public final class Schema130128 implements LocalXmlResource{ | |
| 18 | - | |
| 19 | - /** 唯一のシングルトン。 */ | |
| 20 | - public static final Schema130128 SINGLETON; | |
| 16 | +public final class Schema130128{ | |
| 21 | 17 | |
| 22 | 18 | /** 名前空間。 */ |
| 23 | 19 | public static final String NS_PMDXML = |
| @@ -32,8 +28,10 @@ public final class Schema130128 implements LocalXmlResource{ | ||
| 32 | 28 | public static final String LOCAL_SCHEMA_PMDXML = |
| 33 | 29 | "resources/pmdxml-130128.xsd"; |
| 34 | 30 | |
| 35 | - private static final URI URI_SCHEMA_PMDXML = URI.create(SCHEMA_PMDXML); | |
| 36 | - private static final URI RES_SCHEMA_PMDXML; | |
| 31 | + /** schema URI. */ | |
| 32 | + public static final URI URI_SCHEMA_PMDXML = URI.create(SCHEMA_PMDXML); | |
| 33 | + /** local resource URI. */ | |
| 34 | + public static final URI RES_SCHEMA_PMDXML; | |
| 37 | 35 | |
| 38 | 36 | private static final Class<?> THISCLASS = Schema130128.class; |
| 39 | 37 |
| @@ -44,8 +42,6 @@ public final class Schema130128 implements LocalXmlResource{ | ||
| 44 | 42 | }catch(URISyntaxException e){ |
| 45 | 43 | throw new ExceptionInInitializerError(e); |
| 46 | 44 | } |
| 47 | - | |
| 48 | - SINGLETON = new Schema130128(); | |
| 49 | 45 | } |
| 50 | 46 | |
| 51 | 47 |
| @@ -53,30 +49,7 @@ public final class Schema130128 implements LocalXmlResource{ | ||
| 53 | 49 | * コンストラクタ。 |
| 54 | 50 | */ |
| 55 | 51 | private Schema130128(){ |
| 56 | - super(); | |
| 57 | - assert this.getClass() == THISCLASS; | |
| 58 | - return; | |
| 59 | - } | |
| 60 | - | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * {@inheritDoc} | |
| 64 | - * ※130128版。 | |
| 65 | - * @return {@inheritDoc} | |
| 66 | - */ | |
| 67 | - @Override | |
| 68 | - public URI getOriginalResource(){ | |
| 69 | - return URI_SCHEMA_PMDXML; | |
| 70 | - } | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * {@inheritDoc} | |
| 74 | - * ※130128版。 | |
| 75 | - * @return {@inheritDoc} | |
| 76 | - */ | |
| 77 | - @Override | |
| 78 | - public URI getLocalResource(){ | |
| 79 | - return RES_SCHEMA_PMDXML; | |
| 52 | + assert false; | |
| 80 | 53 | } |
| 81 | 54 | |
| 82 | 55 | } |
| @@ -17,6 +17,7 @@ import org.xml.sax.SAXException; | ||
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * XMLモデルファイルパース用SAXハンドラ。 |
| 20 | + * | |
| 20 | 21 | * <p>下位リスナに各種通知が振り分けられる。 |
| 21 | 22 | */ |
| 22 | 23 | class XmlHandler implements ContentHandler{ |
| @@ -44,7 +45,7 @@ class XmlHandler implements ContentHandler{ | ||
| 44 | 45 | SaxListener dynamicsListener = new SaxDynamicsListener(helper); |
| 45 | 46 | SaxListener shapeListener = new SaxShapeListener(helper); |
| 46 | 47 | |
| 47 | - this.listenerMap = new EnumMap<PmdTag, SaxListener>(PmdTag.class); | |
| 48 | + this.listenerMap = new EnumMap<>(PmdTag.class); | |
| 48 | 49 | this.listenerMap.put(PmdTag.PMD_MODEL, modelListener); |
| 49 | 50 | this.listenerMap.put(PmdTag.MATERIAL_LIST, materialListener); |
| 50 | 51 | this.listenerMap.put(PmdTag.BONE_LIST, boneListener); |
| @@ -58,6 +59,7 @@ class XmlHandler implements ContentHandler{ | ||
| 58 | 59 | |
| 59 | 60 | /** |
| 60 | 61 | * ビルド対象のモデルを返す。 |
| 62 | + * | |
| 61 | 63 | * @return ビルド対象のモデル。ビルド前ならnull |
| 62 | 64 | */ |
| 63 | 65 | PmdModel getPmdModel(){ |
| @@ -66,6 +68,7 @@ class XmlHandler implements ContentHandler{ | ||
| 66 | 68 | |
| 67 | 69 | /** |
| 68 | 70 | * {@inheritDoc} |
| 71 | + * | |
| 69 | 72 | * @throws SAXException {@inheritDoc} |
| 70 | 73 | */ |
| 71 | 74 | @Override |
| @@ -81,6 +84,7 @@ class XmlHandler implements ContentHandler{ | ||
| 81 | 84 | |
| 82 | 85 | /** |
| 83 | 86 | * {@inheritDoc} |
| 87 | + * | |
| 84 | 88 | * @throws SAXException {@inheritDoc} |
| 85 | 89 | */ |
| 86 | 90 | @Override |
| @@ -92,6 +96,7 @@ class XmlHandler implements ContentHandler{ | ||
| 92 | 96 | |
| 93 | 97 | /** |
| 94 | 98 | * {@inheritDoc} |
| 99 | + * | |
| 95 | 100 | * @param prefix {@inheritDoc} |
| 96 | 101 | * @param uri {@inheritDoc} |
| 97 | 102 | * @throws SAXException {@inheritDoc} |
| @@ -99,8 +104,8 @@ class XmlHandler implements ContentHandler{ | ||
| 99 | 104 | @Override |
| 100 | 105 | public void startPrefixMapping(String prefix, String uri) |
| 101 | 106 | throws SAXException { |
| 102 | - if( Schema101009.NS_PMDXML.equals(uri) | |
| 103 | - || Schema130128.NS_PMDXML.equals(uri) ){ | |
| 107 | + if( Schema101009.NS_PMDXML.equals(uri) | |
| 108 | + || Schema130128.NS_PMDXML.equals(uri) ){ | |
| 104 | 109 | this.nspfx = prefix; |
| 105 | 110 | this.nsuri = uri; |
| 106 | 111 | } |
| @@ -109,6 +114,7 @@ class XmlHandler implements ContentHandler{ | ||
| 109 | 114 | |
| 110 | 115 | /** |
| 111 | 116 | * {@inheritDoc} |
| 117 | + * | |
| 112 | 118 | * @param prefix {@inheritDoc} |
| 113 | 119 | * @throws SAXException {@inheritDoc} |
| 114 | 120 | */ |
| @@ -123,6 +129,7 @@ class XmlHandler implements ContentHandler{ | ||
| 123 | 129 | |
| 124 | 130 | /** |
| 125 | 131 | * {@inheritDoc} |
| 132 | + * | |
| 126 | 133 | * @param uri {@inheritDoc} |
| 127 | 134 | * @param localName {@inheritDoc} |
| 128 | 135 | * @param qName {@inheritDoc} |
| @@ -150,6 +157,7 @@ class XmlHandler implements ContentHandler{ | ||
| 150 | 157 | |
| 151 | 158 | /** |
| 152 | 159 | * タグ出現に従い通知リスナを切り替える。 |
| 160 | + * | |
| 153 | 161 | * @param tag タグ種別 |
| 154 | 162 | */ |
| 155 | 163 | private void switchListener(PmdTag tag){ |
| @@ -163,6 +171,7 @@ class XmlHandler implements ContentHandler{ | ||
| 163 | 171 | |
| 164 | 172 | /** |
| 165 | 173 | * {@inheritDoc} |
| 174 | + * | |
| 166 | 175 | * @param uri {@inheritDoc} |
| 167 | 176 | * @param localName {@inheritDoc} |
| 168 | 177 | * @param qName {@inheritDoc} |
| @@ -185,6 +194,7 @@ class XmlHandler implements ContentHandler{ | ||
| 185 | 194 | |
| 186 | 195 | /** |
| 187 | 196 | * {@inheritDoc} |
| 197 | + * | |
| 188 | 198 | * @param locator {@inheritDoc} |
| 189 | 199 | */ |
| 190 | 200 | @Override |
| @@ -195,6 +205,7 @@ class XmlHandler implements ContentHandler{ | ||
| 195 | 205 | |
| 196 | 206 | /** |
| 197 | 207 | * {@inheritDoc} |
| 208 | + * | |
| 198 | 209 | * @param target {@inheritDoc} |
| 199 | 210 | * @param data {@inheritDoc} |
| 200 | 211 | * @throws SAXException {@inheritDoc} |
| @@ -208,6 +219,7 @@ class XmlHandler implements ContentHandler{ | ||
| 208 | 219 | |
| 209 | 220 | /** |
| 210 | 221 | * {@inheritDoc} |
| 222 | + * | |
| 211 | 223 | * @param ch {@inheritDoc} |
| 212 | 224 | * @param start {@inheritDoc} |
| 213 | 225 | * @param length {@inheritDoc} |
| @@ -223,6 +235,7 @@ class XmlHandler implements ContentHandler{ | ||
| 223 | 235 | |
| 224 | 236 | /** |
| 225 | 237 | * {@inheritDoc} |
| 238 | + * | |
| 226 | 239 | * @param ch {@inheritDoc} |
| 227 | 240 | * @param start {@inheritDoc} |
| 228 | 241 | * @param length {@inheritDoc} |
| @@ -237,6 +250,7 @@ class XmlHandler implements ContentHandler{ | ||
| 237 | 250 | |
| 238 | 251 | /** |
| 239 | 252 | * {@inheritDoc} |
| 253 | + * | |
| 240 | 254 | * @param name {@inheritDoc} |
| 241 | 255 | * @throws SAXException {@inheritDoc} |
| 242 | 256 | */ |
| @@ -14,8 +14,8 @@ public enum XmlModelFileType { | ||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * XMLファイル。 |
| 17 | - * <p>読み込み時のスキーマ判別は自動。 | |
| 18 | - * 出力時のスキーマ種別は最新。 | |
| 17 | + * | |
| 18 | + * <p>読み込み時のスキーマ判別は自動。出力時のスキーマ種別は最新。 | |
| 19 | 19 | */ |
| 20 | 20 | XML_AUTO, |
| 21 | 21 |
| @@ -27,7 +27,9 @@ public class XmlPmdLoader { | ||
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * コンストラクタ。 |
| 30 | + * | |
| 30 | 31 | * <p>XMLリーダは名前空間をサポートしていなければならない。 |
| 32 | + * | |
| 31 | 33 | * @param reader XMLリーダ |
| 32 | 34 | * @throws NullPointerException 引数がnull |
| 33 | 35 | * @throws SAXException 機能不足のXMLリーダが渡された |
| @@ -49,6 +51,7 @@ public class XmlPmdLoader { | ||
| 49 | 51 | |
| 50 | 52 | /** |
| 51 | 53 | * XMLのパースを開始する。 |
| 54 | + * | |
| 52 | 55 | * @param source XML入力 |
| 53 | 56 | * @return モデルデータ |
| 54 | 57 | * @throws SAXException 構文エラー |
| @@ -33,6 +33,7 @@ final class CmdLine { | ||
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * コマンドライン解析を行う。 |
| 36 | + * | |
| 36 | 37 | * @param args コマンドライン |
| 37 | 38 | * @return 解析されたコマンドライン並び |
| 38 | 39 | */ |
| @@ -43,11 +44,12 @@ final class CmdLine { | ||
| 43 | 44 | |
| 44 | 45 | /** |
| 45 | 46 | * コマンドライン解析を行う。 |
| 47 | + * | |
| 46 | 48 | * @param argList コマンドライン |
| 47 | 49 | * @return 解析されたコマンドライン並び |
| 48 | 50 | */ |
| 49 | 51 | static List<CmdLine> parse(List<String> argList){ |
| 50 | - List<CmdLine> result = new LinkedList<CmdLine>(); | |
| 52 | + List<CmdLine> result = new LinkedList<>(); | |
| 51 | 53 | |
| 52 | 54 | Iterator<String> it = argList.iterator(); |
| 53 | 55 | while (it.hasNext()) { |
| @@ -62,7 +64,7 @@ final class CmdLine { | ||
| 62 | 64 | if (info.opt != null) { |
| 63 | 65 | exArgNum = info.opt.getExArgNum(); |
| 64 | 66 | } |
| 65 | - info.optArgs = new ArrayList<String>(exArgNum + 1); | |
| 67 | + info.optArgs = new ArrayList<>(exArgNum + 1); | |
| 66 | 68 | |
| 67 | 69 | info.optArgs.add(arg); |
| 68 | 70 |
| @@ -81,8 +83,9 @@ final class CmdLine { | ||
| 81 | 83 | |
| 82 | 84 | /** |
| 83 | 85 | * オプション識別子を返す。 |
| 86 | + * | |
| 84 | 87 | * @return オプション識別子。 |
| 85 | - * オプションを伴わない単純なコマンドライン引数の場合はnullを返す。 | |
| 88 | + * オプションを伴わない単純なコマンドライン引数の場合はnullを返す。 | |
| 86 | 89 | */ |
| 87 | 90 | OptSwitch getOptSwitch() { |
| 88 | 91 | return this.opt; |
| @@ -90,9 +93,10 @@ final class CmdLine { | ||
| 90 | 93 | |
| 91 | 94 | /** |
| 92 | 95 | * オプションに付随する引数群を返す。 |
| 96 | + * | |
| 93 | 97 | * @return オプションに付随する引数群。 |
| 94 | - * 先頭要素はオプション識別子。 | |
| 95 | - * 単純なコマンドライン引数の場合は自身が1要素のみを占める。 | |
| 98 | + * 先頭要素はオプション識別子。 | |
| 99 | + * 単純なコマンドライン引数の場合は自身が1要素のみを占める。 | |
| 96 | 100 | */ |
| 97 | 101 | List<String> getOptArgs() { |
| 98 | 102 | return this.optArgs; |
| @@ -26,7 +26,9 @@ public enum ModelFileType { | ||
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * XMLファイル。 |
| 29 | + * | |
| 29 | 30 | * <p>読み込み時のスキーマ判別は自動。 |
| 31 | + * | |
| 30 | 32 | * <p>書き込み時のスキーマは最新。 |
| 31 | 33 | */ |
| 32 | 34 | XML_AUTO, |
| @@ -51,13 +53,15 @@ public enum ModelFileType { | ||
| 51 | 53 | /** |
| 52 | 54 | * コンストラクタ。 |
| 53 | 55 | */ |
| 54 | - private ModelFileType(){ | |
| 56 | + ModelFileType(){ | |
| 55 | 57 | return; |
| 56 | 58 | } |
| 57 | 59 | |
| 58 | 60 | /** |
| 59 | 61 | * ファイル種別をXMLファイル種別に変換する。 |
| 62 | + * | |
| 60 | 63 | * <p>未定義の場合はXML_AUTOを返す。 |
| 64 | + * | |
| 61 | 65 | * @return XMLファイル種別 |
| 62 | 66 | */ |
| 63 | 67 | public XmlModelFileType toXmlType(){ |
| @@ -83,6 +87,7 @@ public enum ModelFileType { | ||
| 83 | 87 | |
| 84 | 88 | /** |
| 85 | 89 | * ファイル種別がXMLか判定する。 |
| 90 | + * | |
| 86 | 91 | * @return XMLならtrue |
| 87 | 92 | */ |
| 88 | 93 | public boolean isXml(){ |
| @@ -104,6 +109,7 @@ public enum ModelFileType { | ||
| 104 | 109 | |
| 105 | 110 | /** |
| 106 | 111 | * ファイル種別がPMDか判定する。 |
| 112 | + * | |
| 107 | 113 | * @return PMDならtrue |
| 108 | 114 | */ |
| 109 | 115 | public boolean isPmd(){ |
| @@ -73,6 +73,7 @@ final class OptInfo { | ||
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * フォーマット種別指定子をデコードする。 |
| 76 | + * | |
| 76 | 77 | * @param arg 文字列 |
| 77 | 78 | * @return デコード結果。 |
| 78 | 79 | * @throws CmdLineException 不正なフォーマット種別 |
| @@ -99,6 +100,7 @@ final class OptInfo { | ||
| 99 | 100 | |
| 100 | 101 | /** |
| 101 | 102 | * 改行文字指定子をデコードする。 |
| 103 | + * | |
| 102 | 104 | * @param arg 文字列 |
| 103 | 105 | * @return デコード結果。 |
| 104 | 106 | * @throws CmdLineException 不正なフォーマット種別 |
| @@ -121,6 +123,7 @@ final class OptInfo { | ||
| 121 | 123 | |
| 122 | 124 | /** |
| 123 | 125 | * ブール指定子をデコードする。 |
| 126 | + * | |
| 124 | 127 | * @param arg 文字列 |
| 125 | 128 | * @return デコード結果。 |
| 126 | 129 | * @throws CmdLineException 不正なフォーマット種別 |
| @@ -129,9 +132,9 @@ final class OptInfo { | ||
| 129 | 132 | throws CmdLineException{ |
| 130 | 133 | boolean result; |
| 131 | 134 | |
| 132 | - if( "on" .equals(arg) | |
| 133 | - || "true".equals(arg) | |
| 134 | - || "yes" .equals(arg) ){ | |
| 135 | + if( "on" .equals(arg) | |
| 136 | + || "true".equals(arg) | |
| 137 | + || "yes" .equals(arg) ){ | |
| 135 | 138 | result = true; |
| 136 | 139 | }else if( "off" .equals(arg) |
| 137 | 140 | || "false".equals(arg) |
| @@ -147,7 +150,9 @@ final class OptInfo { | ||
| 147 | 150 | |
| 148 | 151 | /** |
| 149 | 152 | * ファイル名からファイル種別を類推する。 |
| 153 | + * | |
| 150 | 154 | * <p>拡張子が「pmd」ならPMDファイル、「xml」ならXMLファイル。 |
| 155 | + * | |
| 151 | 156 | * @param fileName ファイル名 |
| 152 | 157 | * @return ファイル種別 |
| 153 | 158 | */ |
| @@ -164,6 +169,7 @@ final class OptInfo { | ||
| 164 | 169 | |
| 165 | 170 | /** |
| 166 | 171 | * コマンドラインを解析する。 |
| 172 | + * | |
| 167 | 173 | * @param args コマンドライン |
| 168 | 174 | * @return オプション情報 |
| 169 | 175 | * @throws CmdLineException 不正なコマンドライン |
| @@ -233,7 +239,9 @@ final class OptInfo { | ||
| 233 | 239 | |
| 234 | 240 | /** |
| 235 | 241 | * 単純なコマンドラインエラーを検出する。 |
| 242 | + * | |
| 236 | 243 | * <p>検出項目は未知のオプションおよび不正な引数の個数 |
| 244 | + * | |
| 237 | 245 | * @param cmdLines コマンドライン |
| 238 | 246 | * @throws CmdLineException 異常系 |
| 239 | 247 | */ |
| @@ -266,6 +274,7 @@ final class OptInfo { | ||
| 266 | 274 | |
| 267 | 275 | /** |
| 268 | 276 | * ファイルフォーマット情報の推測を行う。 |
| 277 | + * | |
| 269 | 278 | * @param result オプション情報 |
| 270 | 279 | */ |
| 271 | 280 | private static void fixFormat(OptInfo result){ |
| @@ -282,6 +291,7 @@ final class OptInfo { | ||
| 282 | 291 | |
| 283 | 292 | /** |
| 284 | 293 | * オプション整合性の事後検査。 |
| 294 | + * | |
| 285 | 295 | * @param result オプション情報 |
| 286 | 296 | * @throws CmdLineException 不正なオプション設定 |
| 287 | 297 | */ |
| @@ -309,6 +319,7 @@ final class OptInfo { | ||
| 309 | 319 | |
| 310 | 320 | /** |
| 311 | 321 | * ヘルプ表示が必要か否か判定する。 |
| 322 | + * | |
| 312 | 323 | * @return 必要ならtrue |
| 313 | 324 | */ |
| 314 | 325 | boolean needHelp(){ |
| @@ -317,6 +328,7 @@ final class OptInfo { | ||
| 317 | 328 | |
| 318 | 329 | /** |
| 319 | 330 | * 入力ファイル種別を返す。 |
| 331 | + * | |
| 320 | 332 | * @return 入力ファイル種別 |
| 321 | 333 | */ |
| 322 | 334 | ModelFileType getInFileType(){ |
| @@ -325,6 +337,7 @@ final class OptInfo { | ||
| 325 | 337 | |
| 326 | 338 | /** |
| 327 | 339 | * 出力ファイル種別を返す。 |
| 340 | + * | |
| 328 | 341 | * @return 出力ファイル種別 |
| 329 | 342 | */ |
| 330 | 343 | ModelFileType getOutFileType(){ |
| @@ -333,6 +346,7 @@ final class OptInfo { | ||
| 333 | 346 | |
| 334 | 347 | /** |
| 335 | 348 | * 入力ファイル名を返す。 |
| 349 | + * | |
| 336 | 350 | * @return 入力ファイル名 |
| 337 | 351 | */ |
| 338 | 352 | String getInFilename(){ |
| @@ -341,6 +355,7 @@ final class OptInfo { | ||
| 341 | 355 | |
| 342 | 356 | /** |
| 343 | 357 | * 出力ファイル名を返す。 |
| 358 | + * | |
| 344 | 359 | * @return 出力ファイル名 |
| 345 | 360 | */ |
| 346 | 361 | String getOutFilename(){ |
| @@ -349,6 +364,7 @@ final class OptInfo { | ||
| 349 | 364 | |
| 350 | 365 | /** |
| 351 | 366 | * 上書きモードか否か返す。 |
| 367 | + * | |
| 352 | 368 | * @return 上書きモードならtrue |
| 353 | 369 | */ |
| 354 | 370 | boolean overwriteMode(){ |
| @@ -357,6 +373,7 @@ final class OptInfo { | ||
| 357 | 373 | |
| 358 | 374 | /** |
| 359 | 375 | * XML改行文字を返す。 |
| 376 | + * | |
| 360 | 377 | * @return 改行文字 |
| 361 | 378 | */ |
| 362 | 379 | String getNewline(){ |
| @@ -365,6 +382,7 @@ final class OptInfo { | ||
| 365 | 382 | |
| 366 | 383 | /** |
| 367 | 384 | * ジェネレータ名を返す。 |
| 385 | + * | |
| 368 | 386 | * @return ジェネレータ名。表示したくない時はnull |
| 369 | 387 | */ |
| 370 | 388 | String getGenerator(){ |
| @@ -18,14 +18,14 @@ import java.util.Map; | ||
| 18 | 18 | */ |
| 19 | 19 | enum OptSwitch { |
| 20 | 20 | |
| 21 | - OPT_HELP (0, "-h", "-help", "-?"), | |
| 22 | - OPT_INFILE (1, "-i"), | |
| 23 | - OPT_OUTFILE (1, "-o"), | |
| 24 | - OPT_FORCE (0, "-f"), | |
| 25 | - OPT_NEWLINE (1, "-nl"), | |
| 26 | - OPT_GENOUT (1, "-genout"), | |
| 27 | - OPT_IFORM (1, "-iform"), | |
| 28 | - OPT_OFORM (1, "-oform"), | |
| 21 | + OPT_HELP( 0, "-h", "-help", "-?"), | |
| 22 | + OPT_INFILE( 1, "-i"), | |
| 23 | + OPT_OUTFILE( 1, "-o"), | |
| 24 | + OPT_FORCE( 0, "-f"), | |
| 25 | + OPT_NEWLINE( 1, "-nl"), | |
| 26 | + OPT_GENOUT( 1, "-genout"), | |
| 27 | + OPT_IFORM( 1, "-iform"), | |
| 28 | + OPT_OFORM( 1, "-oform"), | |
| 29 | 29 | ; |
| 30 | 30 | |
| 31 | 31 | private static final String HELP_CONSOLE = |
| @@ -50,7 +50,7 @@ enum OptSwitch { | ||
| 50 | 50 | private static final Map<String, OptSwitch> MAP_OPT; |
| 51 | 51 | |
| 52 | 52 | static{ |
| 53 | - Map<String, OptSwitch> map = new HashMap<String, OptSwitch>(); | |
| 53 | + Map<String, OptSwitch> map = new HashMap<>(); | |
| 54 | 54 | |
| 55 | 55 | for(OptSwitch opt : values()){ |
| 56 | 56 | for(String cmdarg : opt.cmdopts){ |
| @@ -69,10 +69,11 @@ enum OptSwitch { | ||
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * コンストラクタ。 |
| 72 | + * | |
| 72 | 73 | * @param argnum 必要な引数の数 |
| 73 | 74 | * @param cmdopts オプションスイッチパターン群 |
| 74 | 75 | */ |
| 75 | - private OptSwitch(int argnum, String... cmdopts) { | |
| 76 | + OptSwitch(int argnum, String... cmdopts) { | |
| 76 | 77 | this.exArgNum = argnum; |
| 77 | 78 | |
| 78 | 79 | List<String> optlist; |
| @@ -86,6 +87,7 @@ enum OptSwitch { | ||
| 86 | 87 | |
| 87 | 88 | /** |
| 88 | 89 | * コンソール提示用ヘルプ出力文字列を返す。 |
| 90 | + * | |
| 89 | 91 | * @return オプションヘルプ文字列 |
| 90 | 92 | */ |
| 91 | 93 | static String getConsoleHelp(){ |
| @@ -94,7 +96,9 @@ enum OptSwitch { | ||
| 94 | 96 | |
| 95 | 97 | /** |
| 96 | 98 | * 文字列に合致するオプションを返す。 |
| 99 | + * | |
| 97 | 100 | * <p>一つのオプションが複数の表記に合致する場合がある。 |
| 101 | + * | |
| 98 | 102 | * @param cmd 文字列 |
| 99 | 103 | * @return オプション種別。合致する物が見つからなければnull |
| 100 | 104 | */ |
| @@ -106,7 +110,9 @@ enum OptSwitch { | ||
| 106 | 110 | |
| 107 | 111 | /** |
| 108 | 112 | * 各オプションに後続する引数の数を返す。 |
| 113 | + * | |
| 109 | 114 | * <p>引数をとらないオプションは0を返す。 |
| 115 | + * | |
| 110 | 116 | * @return 引数の数 |
| 111 | 117 | */ |
| 112 | 118 | int getExArgNum(){ |
| @@ -71,7 +71,7 @@ public final class Pmd2Xml { | ||
| 71 | 71 | + "If you want to overwrite, use -f."; |
| 72 | 72 | |
| 73 | 73 | private static final String MSG_OLDJRE = "You need JRE {0} or later."; |
| 74 | - private static final String REQUIRED_JRE = "1.6"; | |
| 74 | + private static final String REQUIRED_JRE = "1.8"; | |
| 75 | 75 | |
| 76 | 76 | static{ |
| 77 | 77 | THISCLASS = Pmd2Xml.class; |
| @@ -110,6 +110,7 @@ public final class Pmd2Xml { | ||
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * VMを終了させる。 |
| 113 | + * | |
| 113 | 114 | * @param code 終了コード |
| 114 | 115 | * @see java.lang.System#exit(int) |
| 115 | 116 | */ |
| @@ -121,6 +122,7 @@ public final class Pmd2Xml { | ||
| 121 | 122 | |
| 122 | 123 | /** |
| 123 | 124 | * 共通エラーメッセージを出力する。 |
| 125 | + * | |
| 124 | 126 | * @param text 個別メッセージ |
| 125 | 127 | */ |
| 126 | 128 | private static void errMsg(String text){ |
| @@ -131,6 +133,7 @@ public final class Pmd2Xml { | ||
| 131 | 133 | |
| 132 | 134 | /** |
| 133 | 135 | * 標準エラー出力へ例外情報出力。 |
| 136 | + * | |
| 134 | 137 | * @param ex 例外 |
| 135 | 138 | * @param dumpStack スタックトレースを出力するならtrue |
| 136 | 139 | */ |
| @@ -147,6 +150,7 @@ public final class Pmd2Xml { | ||
| 147 | 150 | |
| 148 | 151 | /** |
| 149 | 152 | * 標準エラー出力へ例外情報出力。 |
| 153 | + * | |
| 150 | 154 | * @param ex 例外 |
| 151 | 155 | */ |
| 152 | 156 | private static void thPrintln(Throwable ex){ |
| @@ -157,6 +161,7 @@ public final class Pmd2Xml { | ||
| 157 | 161 | /** |
| 158 | 162 | * 入出力エラー処理。 |
| 159 | 163 | * 例外を出力してVM終了する。 |
| 164 | + * | |
| 160 | 165 | * @param ex 例外 |
| 161 | 166 | */ |
| 162 | 167 | private static void ioError(IOException ex){ |
| @@ -167,6 +172,7 @@ public final class Pmd2Xml { | ||
| 167 | 172 | /** |
| 168 | 173 | * XML構文エラー処理。 |
| 169 | 174 | * 例外を出力してVM終了する。 |
| 175 | + * | |
| 170 | 176 | * @param ex 例外 |
| 171 | 177 | */ |
| 172 | 178 | private static void xmlError(Throwable ex){ |
| @@ -177,6 +183,7 @@ public final class Pmd2Xml { | ||
| 177 | 183 | /** |
| 178 | 184 | * PMDファイルフォーマットエラー処理。 |
| 179 | 185 | * 例外を出力してVM終了する。 |
| 186 | + * | |
| 180 | 187 | * @param ex 例外 |
| 181 | 188 | */ |
| 182 | 189 | private static void pmdError(MmdFormatException ex){ |
| @@ -187,6 +194,7 @@ public final class Pmd2Xml { | ||
| 187 | 194 | /** |
| 188 | 195 | * 内部エラー処理。 |
| 189 | 196 | * 例外を出力してVM終了する。 |
| 197 | + * | |
| 190 | 198 | * @param ex 例外 |
| 191 | 199 | */ |
| 192 | 200 | private static void internalError(Throwable ex){ |
| @@ -222,8 +230,11 @@ public final class Pmd2Xml { | ||
| 222 | 230 | |
| 223 | 231 | /** |
| 224 | 232 | * ファイルサイズを0に切り詰める。 |
| 233 | + * | |
| 225 | 234 | * <p>ファイルが存在しなければなにもしない。 |
| 235 | + * | |
| 226 | 236 | * <p>通常ファイルでなければなにもしない。 |
| 237 | + * | |
| 227 | 238 | * @param file ファイル |
| 228 | 239 | * @throws IOException 入出力エラー |
| 229 | 240 | */ |
| @@ -250,7 +261,9 @@ public final class Pmd2Xml { | ||
| 250 | 261 | |
| 251 | 262 | /** |
| 252 | 263 | * 入力ソースを準備する。 |
| 264 | + * | |
| 253 | 265 | * <p>入力ファイルが通常ファイルとして存在しなければエラー終了。 |
| 266 | + * | |
| 254 | 267 | * @param optInfo オプション情報 |
| 255 | 268 | * @return 入力ソース |
| 256 | 269 | */ |
| @@ -272,8 +285,11 @@ public final class Pmd2Xml { | ||
| 272 | 285 | |
| 273 | 286 | /** |
| 274 | 287 | * 出力ストリームを準備する。 |
| 288 | + * | |
| 275 | 289 | * <p>出力ファイルが通常ファイルでない場合はエラー終了。 |
| 290 | + * | |
| 276 | 291 | * <p>既存の出力ファイルに上書き指示が伴っていなければエラー終了。 |
| 292 | + * | |
| 277 | 293 | * @param optInfo オプション情報 |
| 278 | 294 | * @return 出力ストリーム |
| 279 | 295 | */ |
| @@ -318,13 +334,14 @@ public final class Pmd2Xml { | ||
| 318 | 334 | |
| 319 | 335 | /** |
| 320 | 336 | * オプション情報に従いコンバータを生成する。 |
| 337 | + * | |
| 321 | 338 | * @param optInfo オプション情報 |
| 322 | 339 | * @return コンバータ |
| 323 | 340 | */ |
| 324 | 341 | private static Pmd2XmlConv buildConverter(OptInfo optInfo){ |
| 325 | 342 | Pmd2XmlConv converter = new Pmd2XmlConv(); |
| 326 | 343 | |
| 327 | - converter.setInType (optInfo.getInFileType()); | |
| 344 | + converter.setInType( optInfo.getInFileType()); | |
| 328 | 345 | converter.setOutType(optInfo.getOutFileType()); |
| 329 | 346 | |
| 330 | 347 | converter.setNewline(optInfo.getNewline()); |
| @@ -335,7 +352,9 @@ public final class Pmd2Xml { | ||
| 335 | 352 | |
| 336 | 353 | /** |
| 337 | 354 | * 実際のコンバート作業と異常系処理を行う。 |
| 355 | + * | |
| 338 | 356 | * <p>異常系が起きた場合、このメソッドは制御を戻さない。 |
| 357 | + * | |
| 339 | 358 | * @param converter コンバータ |
| 340 | 359 | * @param source 入力ソース |
| 341 | 360 | * @param ostream 出力ストリーム |
| @@ -362,11 +381,13 @@ public final class Pmd2Xml { | ||
| 362 | 381 | |
| 363 | 382 | /** |
| 364 | 383 | * コマンドライン文字列をオプション情報としてパースする。 |
| 384 | + * | |
| 365 | 385 | * <p>異常系が起きた場合、このメソッドは制御を戻さない。 |
| 386 | + * | |
| 366 | 387 | * @param args コマンドライン文字列群 |
| 367 | 388 | * @return オプション情報 |
| 368 | 389 | */ |
| 369 | - private static OptInfo parseOption(String[] args){ | |
| 390 | + private static OptInfo parseOption(String... args){ | |
| 370 | 391 | OptInfo optInfo; |
| 371 | 392 | |
| 372 | 393 | try{ |
| @@ -385,6 +406,7 @@ public final class Pmd2Xml { | ||
| 385 | 406 | |
| 386 | 407 | /** |
| 387 | 408 | * Mainエントリ。 |
| 409 | + * | |
| 388 | 410 | * @param args コマンドパラメータ |
| 389 | 411 | */ |
| 390 | 412 | public static void main(String[] args){ |
| @@ -53,6 +53,7 @@ public class Pmd2XmlConv { | ||
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * 入力ファイル種別を設定する。 |
| 56 | + * | |
| 56 | 57 | * @param type ファイル種別 |
| 57 | 58 | * @throws NullPointerException 引数がnull |
| 58 | 59 | * @throws IllegalArgumentException 具体的な種別を渡さなかった |
| @@ -67,6 +68,7 @@ public class Pmd2XmlConv { | ||
| 67 | 68 | |
| 68 | 69 | /** |
| 69 | 70 | * 入力ファイル種別を返す。 |
| 71 | + * | |
| 70 | 72 | * @return ファイル種別 |
| 71 | 73 | */ |
| 72 | 74 | public ModelFileType getInTypes(){ |
| @@ -75,6 +77,7 @@ public class Pmd2XmlConv { | ||
| 75 | 77 | |
| 76 | 78 | /** |
| 77 | 79 | * 出力ファイル種別を設定する。 |
| 80 | + * | |
| 78 | 81 | * @param type ファイル種別 |
| 79 | 82 | * @throws NullPointerException 引数がnull |
| 80 | 83 | * @throws IllegalArgumentException 具体的な種別を渡さなかった |
| @@ -89,6 +92,7 @@ public class Pmd2XmlConv { | ||
| 89 | 92 | |
| 90 | 93 | /** |
| 91 | 94 | * 出力ファイル種別を返す。 |
| 95 | + * | |
| 92 | 96 | * @return ファイル種別 |
| 93 | 97 | */ |
| 94 | 98 | public ModelFileType getOutTypes(){ |
| @@ -97,6 +101,7 @@ public class Pmd2XmlConv { | ||
| 97 | 101 | |
| 98 | 102 | /** |
| 99 | 103 | * XML出力用改行文字列を設定する。 |
| 104 | + * | |
| 100 | 105 | * @param newline 改行文字 |
| 101 | 106 | */ |
| 102 | 107 | public void setNewline(String newline){ |
| @@ -106,6 +111,7 @@ public class Pmd2XmlConv { | ||
| 106 | 111 | |
| 107 | 112 | /** |
| 108 | 113 | * XML出力用改行文字列を返す。 |
| 114 | + * | |
| 109 | 115 | * @return 改行文字 |
| 110 | 116 | */ |
| 111 | 117 | public String getNewline(){ |
| @@ -114,6 +120,7 @@ public class Pmd2XmlConv { | ||
| 114 | 120 | |
| 115 | 121 | /** |
| 116 | 122 | * ジェネレータ名を設定する。 |
| 123 | + * | |
| 117 | 124 | * @param generator ジェネレータ名。表示したくない場合はnull |
| 118 | 125 | */ |
| 119 | 126 | public void setGenerator(String generator){ |
| @@ -123,6 +130,7 @@ public class Pmd2XmlConv { | ||
| 123 | 130 | |
| 124 | 131 | /** |
| 125 | 132 | * ジェネレータ名を返す。 |
| 133 | + * | |
| 126 | 134 | * @return ジェネレータ名。非表示の場合はnullを返す。 |
| 127 | 135 | */ |
| 128 | 136 | public String getGenerator(){ |
| @@ -131,8 +139,10 @@ public class Pmd2XmlConv { | ||
| 131 | 139 | |
| 132 | 140 | /** |
| 133 | 141 | * ファイル変換を行う。 |
| 142 | + * | |
| 134 | 143 | * <p>XML入力の場合は{@link #convert(InputSource, OutputStream)}を |
| 135 | 144 | * 推奨する。 |
| 145 | + * | |
| 136 | 146 | * @param is 入力ストリーム |
| 137 | 147 | * @param os 出力ストリーム |
| 138 | 148 | * @throws IOException 入力エラー |
| @@ -154,10 +164,13 @@ public class Pmd2XmlConv { | ||
| 154 | 164 | |
| 155 | 165 | /** |
| 156 | 166 | * ファイル変換を行う。 |
| 167 | + * | |
| 157 | 168 | * <p>PMD入力の場合は{@link InputStream}に |
| 158 | 169 | * バイトストリームが直接設定されていなければならない。 |
| 170 | + * | |
| 159 | 171 | * <p>XML入力の場合は{@link InputStream}に |
| 160 | 172 | * URL(systemId)のみの設定を推奨する。 |
| 173 | + * | |
| 161 | 174 | * @param source 入力ソース |
| 162 | 175 | * @param os 出力ストリーム |
| 163 | 176 | * @throws IOException 入力エラー |
| @@ -179,8 +192,10 @@ public class Pmd2XmlConv { | ||
| 179 | 192 | |
| 180 | 193 | /** |
| 181 | 194 | * モデルファイルを読み込む。 |
| 195 | + * | |
| 182 | 196 | * <p>XML読み込みの場合は、 |
| 183 | 197 | * こちらより{@link #readModel(InputSource)}版を推奨する。 |
| 198 | + * | |
| 184 | 199 | * @param is 入力ストリーム |
| 185 | 200 | * @return モデルデータ |
| 186 | 201 | * @throws IOException 入力エラー |
| @@ -208,6 +223,7 @@ public class Pmd2XmlConv { | ||
| 208 | 223 | |
| 209 | 224 | /** |
| 210 | 225 | * モデルファイルを読み込む。 |
| 226 | + * | |
| 211 | 227 | * @param source 入力ソース |
| 212 | 228 | * @return モデルデータ |
| 213 | 229 | * @throws IOException 入力エラー |
| @@ -240,6 +256,7 @@ public class Pmd2XmlConv { | ||
| 240 | 256 | |
| 241 | 257 | /** |
| 242 | 258 | * モデルファイルを出力する。 |
| 259 | + * | |
| 243 | 260 | * @param model モデルデータ |
| 244 | 261 | * @param os 出力ストリーム |
| 245 | 262 | * @throws IOException 出力エラー |
| @@ -261,6 +278,7 @@ public class Pmd2XmlConv { | ||
| 261 | 278 | |
| 262 | 279 | /** |
| 263 | 280 | * PMDファイルからモデルデータを読み込む。 |
| 281 | + * | |
| 264 | 282 | * @param is 入力ストリーム |
| 265 | 283 | * @return モデルデータ |
| 266 | 284 | * @throws IOException 入力エラー |
| @@ -275,6 +293,7 @@ public class Pmd2XmlConv { | ||
| 275 | 293 | |
| 276 | 294 | /** |
| 277 | 295 | * XMLファイルからモデルデータを読み込む。 |
| 296 | + * | |
| 278 | 297 | * @param source 入力ソース |
| 279 | 298 | * @return モデルデータ |
| 280 | 299 | * @throws IOException 入力エラー |
| @@ -293,6 +312,7 @@ public class Pmd2XmlConv { | ||
| 293 | 312 | |
| 294 | 313 | /** |
| 295 | 314 | * モデルデータをPMDファイルに出力する。 |
| 315 | + * | |
| 296 | 316 | * @param model モデルデータ |
| 297 | 317 | * @param ostream 出力ストリーム |
| 298 | 318 | * @throws IOException 出力エラー |
| @@ -308,6 +328,7 @@ public class Pmd2XmlConv { | ||
| 308 | 328 | |
| 309 | 329 | /** |
| 310 | 330 | * モデルデータをXMLファイルに出力する。 |
| 331 | + * | |
| 311 | 332 | * @param model モデルデータ |
| 312 | 333 | * @param ostream 出力ストリーム |
| 313 | 334 | * @throws IOException 出力エラー |
| @@ -14,6 +14,7 @@ import java.io.InputStream; | ||
| 14 | 14 | import java.net.MalformedURLException; |
| 15 | 15 | import java.net.URI; |
| 16 | 16 | import java.net.URL; |
| 17 | +import javax.xml.XMLConstants; | |
| 17 | 18 | import javax.xml.parsers.ParserConfigurationException; |
| 18 | 19 | import javax.xml.parsers.SAXParser; |
| 19 | 20 | import javax.xml.parsers.SAXParserFactory; |
| @@ -21,11 +22,12 @@ import javax.xml.validation.Schema; | ||
| 21 | 22 | import jp.sfjp.mikutoga.pmd.model.xml.Schema101009; |
| 22 | 23 | import jp.sfjp.mikutoga.pmd.model.xml.Schema130128; |
| 23 | 24 | import jp.sfjp.mikutoga.xml.BotherHandler; |
| 24 | -import jp.sfjp.mikutoga.xml.LocalXmlResource; | |
| 25 | +import jp.sfjp.mikutoga.xml.NoopEntityResolver; | |
| 25 | 26 | import jp.sfjp.mikutoga.xml.SchemaUtil; |
| 26 | -import jp.sfjp.mikutoga.xml.XmlResourceResolver; | |
| 27 | 27 | import org.xml.sax.InputSource; |
| 28 | 28 | import org.xml.sax.SAXException; |
| 29 | +import org.xml.sax.SAXNotRecognizedException; | |
| 30 | +import org.xml.sax.SAXNotSupportedException; | |
| 29 | 31 | import org.xml.sax.XMLReader; |
| 30 | 32 | |
| 31 | 33 | /** |
| @@ -33,6 +35,16 @@ import org.xml.sax.XMLReader; | ||
| 33 | 35 | */ |
| 34 | 36 | final class XmlInputUtil { |
| 35 | 37 | |
| 38 | + private static final String F_DISALLOW_DOCTYPE_DECL = | |
| 39 | + "http://apache.org/xml/features/disallow-doctype-decl"; | |
| 40 | + private static final String F_EXTERNAL_GENERAL_ENTITIES = | |
| 41 | + "http://xml.org/sax/features/external-general-entities"; | |
| 42 | + private static final String F_EXTERNAL_PARAMETER_ENTITIES = | |
| 43 | + "http://xml.org/sax/features/external-parameter-entities"; | |
| 44 | + private static final String F_LOAD_EXTERNAL_DTD = | |
| 45 | + "http://apache.org/xml/features/nonvalidating/load-external-dtd"; | |
| 46 | + | |
| 47 | + | |
| 36 | 48 | /** |
| 37 | 49 | * 隠しコンストラクタ。 |
| 38 | 50 | */ |
| @@ -44,6 +56,7 @@ final class XmlInputUtil { | ||
| 44 | 56 | |
| 45 | 57 | /** |
| 46 | 58 | * 実在ファイルからXML入力ソースを得る。 |
| 59 | + * | |
| 47 | 60 | * @param file 実在ファイル |
| 48 | 61 | * @return XML入力ソース |
| 49 | 62 | */ |
| @@ -70,8 +83,10 @@ final class XmlInputUtil { | ||
| 70 | 83 | |
| 71 | 84 | /** |
| 72 | 85 | * InputSourceからInputStreamを得る。 |
| 86 | + * | |
| 73 | 87 | * <p>入力ソースには、少なくともバイトストリームか |
| 74 | 88 | * URL文字列(SystemId)のいずれかが設定されていなければならない。 |
| 89 | + * | |
| 75 | 90 | * @param source 入力ソース |
| 76 | 91 | * @return 入力バイトストリーム |
| 77 | 92 | * @throws IllegalArgumentException 入力ソースの設定が足りない。 |
| @@ -98,11 +113,13 @@ final class XmlInputUtil { | ||
| 98 | 113 | |
| 99 | 114 | /** |
| 100 | 115 | * SAXパーサファクトリを生成する。 |
| 116 | + * | |
| 101 | 117 | * <ul> |
| 102 | 118 | * <li>XML名前空間機能は有効になる。 |
| 103 | 119 | * <li>DTDによる形式検証は無効となる。 |
| 104 | 120 | * <li>XIncludeによる差し込み機能は無効となる。 |
| 105 | 121 | * </ul> |
| 122 | + * | |
| 106 | 123 | * @param schema スキーマ |
| 107 | 124 | * @return ファクトリ |
| 108 | 125 | */ |
| @@ -112,7 +129,19 @@ final class XmlInputUtil { | ||
| 112 | 129 | factory.setNamespaceAware(true); |
| 113 | 130 | factory.setValidating(false); |
| 114 | 131 | factory.setXIncludeAware(false); |
| 115 | -// factory.setFeature(name, value); | |
| 132 | + | |
| 133 | + try{ | |
| 134 | + factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); | |
| 135 | + factory.setFeature(F_DISALLOW_DOCTYPE_DECL, true); | |
| 136 | + factory.setFeature(F_EXTERNAL_GENERAL_ENTITIES, false); | |
| 137 | + factory.setFeature(F_EXTERNAL_PARAMETER_ENTITIES, false); | |
| 138 | + factory.setFeature(F_LOAD_EXTERNAL_DTD, false); | |
| 139 | + }catch( ParserConfigurationException | |
| 140 | + | SAXNotRecognizedException | |
| 141 | + | SAXNotSupportedException e ){ | |
| 142 | + assert false; | |
| 143 | + throw new AssertionError(e); | |
| 144 | + } | |
| 116 | 145 | |
| 117 | 146 | factory.setSchema(schema); |
| 118 | 147 |
| @@ -121,6 +150,7 @@ final class XmlInputUtil { | ||
| 121 | 150 | |
| 122 | 151 | /** |
| 123 | 152 | * SAXパーサを生成する。 |
| 153 | + * | |
| 124 | 154 | * @param schema スキーマ |
| 125 | 155 | * @return SAXパーサ |
| 126 | 156 | */ |
| @@ -130,64 +160,72 @@ final class XmlInputUtil { | ||
| 130 | 160 | SAXParser parser; |
| 131 | 161 | try{ |
| 132 | 162 | parser = factory.newSAXParser(); |
| 133 | - }catch(ParserConfigurationException e){ | |
| 163 | + }catch(ParserConfigurationException | SAXException e){ | |
| 134 | 164 | assert false; |
| 135 | 165 | throw new AssertionError(e); |
| 136 | - }catch(SAXException e){ | |
| 166 | + } | |
| 167 | + | |
| 168 | + try{ | |
| 169 | + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, ""); | |
| 170 | + parser.setProperty(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); | |
| 171 | + }catch(SAXNotRecognizedException | SAXNotSupportedException e){ | |
| 137 | 172 | assert false; |
| 138 | 173 | throw new AssertionError(e); |
| 139 | 174 | } |
| 140 | 175 | |
| 141 | -// parser.setProperty(name, value); | |
| 142 | - | |
| 143 | 176 | return parser; |
| 144 | 177 | } |
| 145 | 178 | |
| 146 | 179 | /** |
| 147 | 180 | * スキーマを生成する。 |
| 148 | - * @param resolver リゾルバ | |
| 181 | + * | |
| 149 | 182 | * @param xmlInType 入力XML種別 |
| 150 | 183 | * @return スキーマ |
| 151 | 184 | */ |
| 152 | - private static Schema builsSchema(XmlResourceResolver resolver, | |
| 153 | - ModelFileType xmlInType ){ | |
| 154 | - LocalXmlResource[] schemaArray; | |
| 185 | + private static Schema buildSchema(ModelFileType xmlInType ){ | |
| 186 | + URI[] schemaUris; | |
| 155 | 187 | switch(xmlInType){ |
| 156 | 188 | case XML_101009: |
| 157 | - schemaArray = new LocalXmlResource[]{ | |
| 158 | - Schema101009.SINGLETON, | |
| 189 | + schemaUris = new URI[]{ | |
| 190 | + Schema101009.RES_SCHEMA_PMDXML, | |
| 159 | 191 | }; |
| 160 | 192 | break; |
| 161 | 193 | case XML_130128: |
| 162 | - schemaArray = new LocalXmlResource[]{ | |
| 163 | - Schema130128.SINGLETON, | |
| 194 | + schemaUris = new URI[]{ | |
| 195 | + Schema130128.RES_SCHEMA_PMDXML, | |
| 164 | 196 | }; |
| 165 | 197 | break; |
| 166 | 198 | case XML_AUTO: |
| 167 | - schemaArray = new LocalXmlResource[]{ | |
| 168 | - Schema101009.SINGLETON, | |
| 169 | - Schema130128.SINGLETON, | |
| 199 | + schemaUris = new URI[]{ | |
| 200 | + Schema101009.RES_SCHEMA_PMDXML, | |
| 201 | + Schema130128.RES_SCHEMA_PMDXML, | |
| 170 | 202 | }; |
| 171 | 203 | break; |
| 172 | 204 | default: |
| 173 | 205 | throw new IllegalStateException(); |
| 174 | 206 | } |
| 175 | 207 | |
| 176 | - Schema schema = SchemaUtil.newSchema(resolver, schemaArray); | |
| 208 | + Schema schema; | |
| 209 | + try{ | |
| 210 | + schema = SchemaUtil.newSchema(schemaUris); | |
| 211 | + }catch(IOException | SAXException e){ | |
| 212 | + assert false; | |
| 213 | + throw new AssertionError(e); | |
| 214 | + } | |
| 177 | 215 | |
| 178 | 216 | return schema; |
| 179 | 217 | } |
| 180 | 218 | |
| 181 | 219 | /** |
| 182 | 220 | * XMLリーダを生成する。 |
| 221 | + * | |
| 183 | 222 | * <p>エラーハンドラには{@link BotherHandler}が指定される。 |
| 223 | + * | |
| 184 | 224 | * @param xmlInType 入力XML種別 |
| 185 | 225 | * @return XMLリーダ |
| 186 | 226 | */ |
| 187 | 227 | static XMLReader buildReader(ModelFileType xmlInType){ |
| 188 | - XmlResourceResolver resolver = new XmlResourceResolver(); | |
| 189 | - | |
| 190 | - Schema schema = builsSchema(resolver, xmlInType); | |
| 228 | + Schema schema = buildSchema(xmlInType); | |
| 191 | 229 | |
| 192 | 230 | SAXParser parser = buildParser(schema); |
| 193 | 231 |
| @@ -199,7 +237,7 @@ final class XmlInputUtil { | ||
| 199 | 237 | throw new AssertionError(e); |
| 200 | 238 | } |
| 201 | 239 | |
| 202 | - reader.setEntityResolver(resolver); | |
| 240 | + reader.setEntityResolver(NoopEntityResolver.NOOP_RESOLVER); | |
| 203 | 241 | reader.setErrorHandler(BotherHandler.HANDLER); |
| 204 | 242 | |
| 205 | 243 | return reader; |