svnno****@sourc*****
svnno****@sourc*****
2009年 10月 8日 (木) 02:46:12 JST
Revision: 3726 http://sourceforge.jp/projects/jiemamy/svn/view?view=rev&revision=3726 Author: daisuke_m Date: 2009-10-08 02:46:12 +0900 (Thu, 08 Oct 2009) Log Message: ----------- svnプロパティの指定漏れ対策。 Modified Paths: -------------- hestia/trunk/jiemamy-hestia/resolve_dependency.bat metis/jiemamy-tutorial/trunk/run-jetty-server.bat sandbox/jiemamy-stax/LICENSE.txt sandbox/jiemamy-stax/license/LICENSE.hamcrest.txt sandbox/jiemamy-stax/license/LICENSE.logback.txt sandbox/jiemamy-stax/license/LICENSE.slf4j.txt sandbox/jiemamy-stax/license/LICENSE.stax.txt sandbox/jiemamy-stax/pom.xml sandbox/jiemamy-stax/src/main/java/javanet/staxutils/IndentingXMLEventWriter.java sandbox/jiemamy-stax/src/main/java/javanet/staxutils/package-info.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/AttributeIterator.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandContextImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandDestination.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandSource.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandInputStream.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandOutputStream.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommandException.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/NullCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/ObjectCommandDestination.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandDestination.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandSource.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/XmlCommandContext.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/package-info.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/DialectCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/RootModelCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventWriterAdapter.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/Resolvable.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/ResolvableQueue.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/StaxUtil.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java sandbox/jiemamy-stax/src/test/resources/logback.xml sandbox/jiemamy-stax/src/test/resources/minimal.jiemamy-core.xml sandbox/jiemamy-stax/src/test/resources/minimal.xml Property Changed: ---------------- hestia/trunk/jiemamy-hestia/resolve_dependency.bat leto/factory-enhancer/trunk/.settings/findbugs.xml leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/ReferenceListener.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/ReferenceQueueMonitor.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/SwapException.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/SwapObject.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/Swapper.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/package-info.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractCollectionVisitor.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractMapVisitor.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractResultSetVisitor.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractTypeSafeResultSetVisitor.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/swap/SwapperTest.java metis/jiemamy-tutorial/trunk/run-jetty-server.bat sandbox/jiemamy-stax/LICENSE.txt sandbox/jiemamy-stax/license/LICENSE.hamcrest.txt sandbox/jiemamy-stax/license/LICENSE.logback.txt sandbox/jiemamy-stax/license/LICENSE.slf4j.txt sandbox/jiemamy-stax/license/LICENSE.stax.txt sandbox/jiemamy-stax/license/LICENSE.woodstox.txt sandbox/jiemamy-stax/pom.xml sandbox/jiemamy-stax/src/main/java/javanet/staxutils/IndentingXMLEventWriter.java sandbox/jiemamy-stax/src/main/java/javanet/staxutils/package-info.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/AttributeIterator.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandContextImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandDestination.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandSource.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandInputStream.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandOutputStream.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommandException.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/NullCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/ObjectCommandDestination.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommandImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandDestination.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandSource.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/XmlCommandContext.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/package-info.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/DialectCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/RootModelCommand.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamImpl.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventWriterAdapter.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/Resolvable.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/ResolvableQueue.java sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/StaxUtil.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java sandbox/jiemamy-stax/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java sandbox/jiemamy-stax/src/test/resources/logback.xml sandbox/jiemamy-stax/src/test/resources/minimal.jiemamy-core.xml sandbox/jiemamy-stax/src/test/resources/minimal.xml sandbox/nekotter/nb-configuration.xml sandbox/nekotter/nbactions.xml sandbox/nekotter/pom.xml sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/NekotterAction.java sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/NekotterTopComponent.java sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/config/ConfigOptionsPanelController.java sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/config/ConfigPanel.java sandbox/nekotter/src/main/nbm/module.xml sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/Bundle.properties sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/NekotterTopComponentSettings.xml sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/NekotterTopComponentWstcref.xml sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/layer.xml sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/window/Bundle.properties sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/window/config/Bundle.properties Modified: hestia/trunk/jiemamy-hestia/resolve_dependency.bat =================================================================== --- hestia/trunk/jiemamy-hestia/resolve_dependency.bat 2009-10-07 17:37:58 UTC (rev 3725) +++ hestia/trunk/jiemamy-hestia/resolve_dependency.bat 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,32 +1,32 @@ - @ echo off - -:CHANGE_DIR -REM ==== change to root directory of jiemamy-hestia -cd /d %~dp0 - -IF DEFINED JAVA6_HOME GOTO SET_JAVA_HOME - -:JAVA_CHECK -REM ==== search Java6 -FOR /d %%J IN ("C:\Program Files\Java\jdk1.6.*") DO set JAVA6_HOME=%%J -IF DEFINED JAVA6_HOME goto SET_JAVA_HOME - -echo Java6 not found. -pause -exit - -:SET_JAVA_HOME -REM ==== set environment JAVA_HOME as Java6 -set JAVA_HOME=%JAVA6_HOME% - -:RUN_MAVEN -REM ==== build jiemamy -IF DEFINED MAVEN_OPTS ( - SET MAVEN_OPTS=%MAVEN_OPTS% -Xmx512M -) ELSE ( - SET MAVEN_OPTS=-Xmx512M -) - -call mvn clean package - -pause + @ echo off + +:CHANGE_DIR +REM ==== change to root directory of jiemamy-hestia +cd /d %~dp0 + +IF DEFINED JAVA6_HOME GOTO SET_JAVA_HOME + +:JAVA_CHECK +REM ==== search Java6 +FOR /d %%J IN ("C:\Program Files\Java\jdk1.6.*") DO set JAVA6_HOME=%%J +IF DEFINED JAVA6_HOME goto SET_JAVA_HOME + +echo Java6 not found. +pause +exit + +:SET_JAVA_HOME +REM ==== set environment JAVA_HOME as Java6 +set JAVA_HOME=%JAVA6_HOME% + +:RUN_MAVEN +REM ==== build jiemamy +IF DEFINED MAVEN_OPTS ( + SET MAVEN_OPTS=%MAVEN_OPTS% -Xmx512M +) ELSE ( + SET MAVEN_OPTS=-Xmx512M +) + +call mvn clean package + +pause Property changes on: hestia/trunk/jiemamy-hestia/resolve_dependency.bat ___________________________________________________________________ Modified: svn:eol-style - CRLF + native Property changes on: leto/factory-enhancer/trunk/.settings/findbugs.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/ReferenceListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/ReferenceQueueMonitor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/SwapException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/SwapObject.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/Swapper.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/swap/package-info.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractCollectionVisitor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractMapVisitor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractResultSetVisitor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/visitor/AbstractTypeSafeResultSetVisitor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/swap/SwapperTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: metis/jiemamy-tutorial/trunk/run-jetty-server.bat =================================================================== --- metis/jiemamy-tutorial/trunk/run-jetty-server.bat 2009-10-07 17:37:58 UTC (rev 3725) +++ metis/jiemamy-tutorial/trunk/run-jetty-server.bat 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,5 +1,5 @@ -cd %~p0 - -call mvn jetty:run - +cd %~p0 + +call mvn jetty:run + pause \ No newline at end of file Property changes on: metis/jiemamy-tutorial/trunk/run-jetty-server.bat ___________________________________________________________________ Modified: svn:eol-style - CRLF + native Modified: sandbox/jiemamy-stax/LICENSE.txt =================================================================== --- sandbox/jiemamy-stax/LICENSE.txt 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/LICENSE.txt 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,202 +1,202 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. Property changes on: sandbox/jiemamy-stax/LICENSE.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/license/LICENSE.hamcrest.txt =================================================================== --- sandbox/jiemamy-stax/license/LICENSE.hamcrest.txt 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/license/LICENSE.hamcrest.txt 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,27 +1,27 @@ -BSD License - -Copyright (c) 2000-2006, www.hamcrest.org -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this list of -conditions and the following disclaimer. Redistributions in binary form must reproduce -the above copyright notice, this list of conditions and the following disclaimer in -the documentation and/or other materials provided with the distribution. - -Neither the name of Hamcrest nor the names of its contributors may be used to endorse -or promote products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT -SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY -WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -DAMAGE. +BSD License + +Copyright (c) 2000-2006, www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. Property changes on: sandbox/jiemamy-stax/license/LICENSE.hamcrest.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/license/LICENSE.logback.txt =================================================================== --- sandbox/jiemamy-stax/license/LICENSE.logback.txt 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/license/LICENSE.logback.txt 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,22 +1,22 @@ -Logback LICENSE ---------------- - -Logback: the reliable, generic, fast and flexible logging library for -Java. - -Copyright (C) 2000-2008, QOS.ch - -Source code and binaries for logback, including logback-core, -logback-classic and logback-access modules, are distributed under the -GNU Lesser General Public License Version 2.1, as published by the -Free Software Foundation. - -This library is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as -published by the Free Software Foundation; either version 2.1 of the -License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. +Logback LICENSE +--------------- + +Logback: the reliable, generic, fast and flexible logging library for +Java. + +Copyright (C) 2000-2008, QOS.ch + +Source code and binaries for logback, including logback-core, +logback-classic and logback-access modules, are distributed under the +GNU Lesser General Public License Version 2.1, as published by the +Free Software Foundation. + +This library is free software; you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as +published by the Free Software Foundation; either version 2.1 of the +License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. Property changes on: sandbox/jiemamy-stax/license/LICENSE.logback.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/license/LICENSE.slf4j.txt =================================================================== --- sandbox/jiemamy-stax/license/LICENSE.slf4j.txt 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/license/LICENSE.slf4j.txt 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,24 +1,24 @@ -Copyright (c) 2004-2008 QOS.ch -All rights reserved. - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - +Copyright (c) 2004-2008 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + + Property changes on: sandbox/jiemamy-stax/license/LICENSE.slf4j.txt ___________________________________________________________________ Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/license/LICENSE.stax.txt =================================================================== --- sandbox/jiemamy-stax/license/LICENSE.stax.txt 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/license/LICENSE.stax.txt 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,201 +1,201 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. Property changes on: sandbox/jiemamy-stax/license/LICENSE.stax.txt ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/jiemamy-stax/license/LICENSE.woodstox.txt ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/pom.xml =================================================================== --- sandbox/jiemamy-stax/pom.xml 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/pom.xml 2009-10-07 17:46:12 UTC (rev 3726) @@ -2,10 +2,10 @@ <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> + <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.jiemamy</groupId> - <artifactId>master</artifactId> + <artifactId>master</artifactId> <version>1.1</version> </parent> <groupId>org.jiemamy</groupId> @@ -33,19 +33,19 @@ <developerConnection>scm:svn:svn+ssh://svn.sourceforge.jp/svnroot/jiemamy/sandbox/jiemamy-stax</developerConnection> <url>http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi/sandbox/jiemamy-stax/?root=jiemamy</url> </scm> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.5</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <version>1.1</version> - <scope>test</scope> - </dependency> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.5</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-library</artifactId> + <version>1.1</version> + <scope>test</scope> + </dependency> <dependency> <groupId>org.slf4j</groupId> @@ -83,7 +83,7 @@ <version>3.2.7</version> </dependency> - <dependency> + <dependency> <groupId>org.jiemamy</groupId> <artifactId>jiemamy-spec-core</artifactId> <version>0.3-SNAPSHOT</version> @@ -93,12 +93,12 @@ <artifactId>jiemamy-commons</artifactId> <version>0.0.4</version> </dependency> - </dependencies> - <distributionManagement> - <site> - <id>jiemamy-report</id> - <name>maven-jiemamy-plugin-site</name> - <url>scp://report.jiemamy.org/var/www/report/jiemamy-stax</url> - </site> - </distributionManagement> + </dependencies> + <distributionManagement> + <site> + <id>jiemamy-report</id> + <name>maven-jiemamy-plugin-site</name> + <url>scp://report.jiemamy.org/var/www/report/jiemamy-stax</url> + </site> + </distributionManagement> </project> \ No newline at end of file Property changes on: sandbox/jiemamy-stax/pom.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/javanet/staxutils/IndentingXMLEventWriter.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/javanet/staxutils/IndentingXMLEventWriter.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/javanet/staxutils/IndentingXMLEventWriter.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,455 +1,455 @@ -/* $Id: IndentingXMLEventWriter.java,v 1.2 2004/06/24 22:06:11 kohsuke Exp $ -* -* Copyright (c) 2004, Sun Microsystems, Inc. -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are -* met: -* -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* -* * Redistributions in binary form must reproduce the above -* copyright notice, this list of conditions and the following -* disclaimer in the documentation and/or other materials provided -* with the distribution. -* -* * Neither the name of Sun Microsystems, Inc. nor the names of its -* contributors may be used to endorse or promote products derived -* from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ -package javanet.staxutils; - -import java.io.IOException; -import java.io.Writer; - -import javax.xml.namespace.NamespaceContext; -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.Characters; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -/** - * Wraps another {@link XMLEventWriter} and does the indentation. - * - * <p>CAUTION; オリジナルコードではなく、カスタマイズ済みです。</p> - * - * <p> - * {@link XMLEventWriter} API doesn't provide any portable way of - * doing pretty-printing. This {@link XMLEventWriter} filter provides - * a portable indentation support by wrapping another {@link XMLEventWriter} - * and adding proper {@link Characters} event for indentation. - * - * <p> - * Because whitespace handling in XML is tricky, this is not an - * one-size-fit-all indentation engine. Instead, this class is - * focused on handling so-called "data-oritented XML" like follows: - * - * <pre><xmp> - * <cards> - * <card id="kk.152"> - * <firstName>Kohsuke</firstName> - * <lastName>Kawaguchi</lastName> - * </card> - * </cards> - * </xmp></pre> - * - * <p> - * We'll discuss more about the supported subset of XML later. - * - * <p> - * To use this engine, do as follows: - * <pre> - * {@link XMLEventWriter} w = xmlOutputFactory.createXMLEventWriter(...); - * w = new {@link IndentingXMLEventWriter}(w); - * - * // start writing - * </pre> - * - * <p> - * Use {@link #setIndent(String)} and {@link #setNewLine(String)} to - * control the indentation if you want. - * - * - * <h2>What Subset Does This Support?</h2> - * <p> - * This engine works when the content model of each element is either - * element-only or #PCDATA (but not mixed content model.) IOW, it - * assumes that the children of any element is either (a) only elements - * and no #PCDATA or (b) #PCDATA only and no elements. - * - * <p> - * The engine also tries to handle comments, PIs, and a DOCTYPE decl, - * but in general it works only when those things appear in the - * element-only content model. - * - * - * <h2>For Maintainers</h2> - * <p> - * Please don't try to make this class into an almighty indentation class. - * I've seen it attempted in Xerces and it's not gonna be pretty. - * - * <p> - * If you come up with an idea of another pretty-printer - * that supports another subset, please go ahead and write your own class. - * - * - * - * @author - * Kohsuke Kawaguchi (kohsu****@sun*****) - */ -public class IndentingXMLEventWriter implements XMLEventWriter { - - private final XMLEventWriter core; - - /** - * String used for indentation. - */ - private String indent = " "; - - /** - * String for EOL. - */ - private String newLine; - - /** - * Current nest level. - */ - private int depth = 0; - - /** - * True if the current element has text. - */ - private boolean hasText; - - private int prevEventType; - - /** - * {@link XMLEvent} constant that returns the {@link #newLine}. - */ - private final Characters newLineEvent = new CharactersImpl() { - - public String getData() { - return newLine; - } - }; - - /** - * {@link XMLEvent} constant that returns the {@link #indent}. - */ - private final Characters indentEvent = new CharactersImpl() { - - public String getData() { - return indent; - } - }; - - - /** - * インスタンスを生成する。 - * @param core - */ - public IndentingXMLEventWriter(XMLEventWriter core) { - if (core == null) { - throw new IllegalArgumentException(); - } - this.core = core; - - // get the default line separator - try { - newLine = System.getProperty("line.separator"); - } catch (SecurityException e) { - // use '\n' if we can't figure it out - newLine = "\n"; - } - } - - public void add(XMLEvent event) throws XMLStreamException { - switch (event.getEventType()) { - case XMLStreamConstants.CHARACTERS: - case XMLStreamConstants.CDATA: - case XMLStreamConstants.SPACE: - if (event.asCharacters().isWhiteSpace()) { - // skip any indentation given by the client - // we are running the risk of ignoring the non-ignorable - // significant whitespaces, but that's a risk explained - // in the class javadoc. - return; - } - - hasText = true; - core.add(event); - break; - - case XMLStreamConstants.START_ELEMENT: - newLine(); - core.add(event); - hasText = false; - depth++; - break; - - case XMLStreamConstants.END_ELEMENT: - depth--; - if (hasText == false && prevEventType != XMLStreamConstants.START_ELEMENT) { - newLine(); - } - core.add(event); - hasText = false; - break; - - case XMLStreamConstants.PROCESSING_INSTRUCTION: - case XMLStreamConstants.COMMENT: - case XMLStreamConstants.DTD: - // those things can be mixed with text, - // and at this point we don't know if text follows this - // like <foo><?pi?>text</foo> - // - // but we make a bold assumption that the those primitives - // only appear as a part of the element-only content model. - // so we always indent them as: - // <foo> - // <?pi?> - // ... - // </foo> - if (hasText == false && prevEventType != XMLStreamConstants.START_ELEMENT) { - // if we know that we already had a text, I see no - // reason to indent - newLine(); - } - core.add(event); - return; - - case XMLStreamConstants.END_DOCUMENT: - core.add(event); - // some implementation does the buffering by default, - // and it prevents the output from appearing. - // this has been a confusion for many people. - // calling flush wouldn't hurt decent impls, and it - // prevent such unnecessary confusion. - flush(); - break; - - default: - core.add(event); - break; - } - - prevEventType = event.getEventType(); - } - - public void add(XMLEventReader reader) throws XMLStreamException { - // we can't just delegate to the core - // because we need to do indentation. - if (reader == null) { - throw new IllegalArgumentException(); - } - while (reader.hasNext()) { - add(reader.nextEvent()); - } - } - - public void close() throws XMLStreamException { - core.close(); - } - - public void flush() throws XMLStreamException { - core.flush(); - } - - /** - * Returns the string used for indentation. - * @return the string used for indentation - */ - public String getIndent() { - return indent; - } - - public NamespaceContext getNamespaceContext() { - return core.getNamespaceContext(); - } - - /** - * Returns the string used for newline. - * @return the string used for newline - */ - public String getNewLine() { - return newLine; - } - - public String getPrefix(String uri) throws XMLStreamException { - return core.getPrefix(uri); - } - - public void setDefaultNamespace(String uri) throws XMLStreamException { - core.setDefaultNamespace(uri); - } - - /** - * Sets the string used for indentation. - * - * <p> - * By default, this is set to two space chars. - * - * @param indent - * A string like " ", "\\t". Must not be null. - */ - public void setIndent(String indent) { - if (indent == null) { - throw new IllegalArgumentException(); - } - this.indent = indent; - } - - public void setNamespaceContext(NamespaceContext context) throws XMLStreamException { - core.setNamespaceContext(context); - } - - /** - * Sets the string used for newline. - * - * <p> - * By default, this is set to the platform default new line. - * - * @param newLine - * A string like "\\n" or "\\r\\n". Must not be null. - */ - public void setNewLine(String newLine) { - if (newLine == null) { - throw new IllegalArgumentException(); - } - this.newLine = newLine; - } - - public void setPrefix(String prefix, String uri) throws XMLStreamException { - core.setPrefix(prefix, uri); - } - - /** - * Prints out a new line and indent. - * @throws XMLStreamException - */ - private void newLine() throws XMLStreamException { - core.add(newLineEvent); - for (int i = 0; i < depth; i++) { - core.add(indentEvent); - } - } - - - /** - * Partial implementation of {@link Characters} event. - */ - private abstract static class CharactersImpl implements Characters { - - public Characters asCharacters() { - return this; - } - - public EndElement asEndElement() { - return null; - } - - public StartElement asStartElement() { - return null; - } - - public int getEventType() { - // it's not clear if we are supposed to return SPACES - return XMLStreamConstants.CHARACTERS; - } - - public Location getLocation() { - // spec isn't clear if we can return null, but it doesn't say we can't. - return null; - } - - public QName getSchemaType() { - return null; - } - - public boolean isAttribute() { - return false; - } - - public boolean isCData() { - return false; - } - - public boolean isCharacters() { - return true; - } - - public boolean isEndDocument() { - return false; - } - - public boolean isEndElement() { - return false; - } - - public boolean isEntityReference() { - return false; - } - - public boolean isIgnorableWhiteSpace() { - // this is hard call. On one hand, we want the indentation to - // get through whatever pipeline, so we are tempted to return false. - // also DTD isn't necessarily present. - // - // But on the other hand, this IS an ignorable whitespace - // in its intended meaning. - return true; - } - - public boolean isNamespace() { - return false; - } - - public boolean isProcessingInstruction() { - return false; - } - - public boolean isStartDocument() { - return false; - } - - public boolean isStartElement() { - return false; - } - - public boolean isWhiteSpace() { - return true; - } - - public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException { - try { - // technically we need to do escaping, for we allow - // any characters to be used for indent and newLine. - // but in practice, who'll use something other than 0x20,0x0D,0x0A,0x08? - writer.write(getData()); - } catch (IOException e) { - throw new XMLStreamException(e); - } - } - - } -} +/* $Id$ +* +* Copyright (c) 2004, Sun Microsystems, Inc. +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are +* met: +* +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* +* * Redistributions in binary form must reproduce the above +* copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. +* +* * Neither the name of Sun Microsystems, Inc. nor the names of its +* contributors may be used to endorse or promote products derived +* from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package javanet.staxutils; + +import java.io.IOException; +import java.io.Writer; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.Characters; +import javax.xml.stream.events.EndElement; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +/** + * Wraps another {@link XMLEventWriter} and does the indentation. + * + * <p>CAUTION; オリジナルコードではなく、カスタマイズ済みです。</p> + * + * <p> + * {@link XMLEventWriter} API doesn't provide any portable way of + * doing pretty-printing. This {@link XMLEventWriter} filter provides + * a portable indentation support by wrapping another {@link XMLEventWriter} + * and adding proper {@link Characters} event for indentation. + * + * <p> + * Because whitespace handling in XML is tricky, this is not an + * one-size-fit-all indentation engine. Instead, this class is + * focused on handling so-called "data-oritented XML" like follows: + * + * <pre><xmp> + * <cards> + * <card id="kk.152"> + * <firstName>Kohsuke</firstName> + * <lastName>Kawaguchi</lastName> + * </card> + * </cards> + * </xmp></pre> + * + * <p> + * We'll discuss more about the supported subset of XML later. + * + * <p> + * To use this engine, do as follows: + * <pre> + * {@link XMLEventWriter} w = xmlOutputFactory.createXMLEventWriter(...); + * w = new {@link IndentingXMLEventWriter}(w); + * + * // start writing + * </pre> + * + * <p> + * Use {@link #setIndent(String)} and {@link #setNewLine(String)} to + * control the indentation if you want. + * + * + * <h2>What Subset Does This Support?</h2> + * <p> + * This engine works when the content model of each element is either + * element-only or #PCDATA (but not mixed content model.) IOW, it + * assumes that the children of any element is either (a) only elements + * and no #PCDATA or (b) #PCDATA only and no elements. + * + * <p> + * The engine also tries to handle comments, PIs, and a DOCTYPE decl, + * but in general it works only when those things appear in the + * element-only content model. + * + * + * <h2>For Maintainers</h2> + * <p> + * Please don't try to make this class into an almighty indentation class. + * I've seen it attempted in Xerces and it's not gonna be pretty. + * + * <p> + * If you come up with an idea of another pretty-printer + * that supports another subset, please go ahead and write your own class. + * + * + * + * @author + * Kohsuke Kawaguchi (kohsu****@sun*****) + */ +public class IndentingXMLEventWriter implements XMLEventWriter { + + private final XMLEventWriter core; + + /** + * String used for indentation. + */ + private String indent = " "; + + /** + * String for EOL. + */ + private String newLine; + + /** + * Current nest level. + */ + private int depth = 0; + + /** + * True if the current element has text. + */ + private boolean hasText; + + private int prevEventType; + + /** + * {@link XMLEvent} constant that returns the {@link #newLine}. + */ + private final Characters newLineEvent = new CharactersImpl() { + + public String getData() { + return newLine; + } + }; + + /** + * {@link XMLEvent} constant that returns the {@link #indent}. + */ + private final Characters indentEvent = new CharactersImpl() { + + public String getData() { + return indent; + } + }; + + + /** + * インスタンスを生成する。 + * @param core + */ + public IndentingXMLEventWriter(XMLEventWriter core) { + if (core == null) { + throw new IllegalArgumentException(); + } + this.core = core; + + // get the default line separator + try { + newLine = System.getProperty("line.separator"); + } catch (SecurityException e) { + // use '\n' if we can't figure it out + newLine = "\n"; + } + } + + public void add(XMLEvent event) throws XMLStreamException { + switch (event.getEventType()) { + case XMLStreamConstants.CHARACTERS: + case XMLStreamConstants.CDATA: + case XMLStreamConstants.SPACE: + if (event.asCharacters().isWhiteSpace()) { + // skip any indentation given by the client + // we are running the risk of ignoring the non-ignorable + // significant whitespaces, but that's a risk explained + // in the class javadoc. + return; + } + + hasText = true; + core.add(event); + break; + + case XMLStreamConstants.START_ELEMENT: + newLine(); + core.add(event); + hasText = false; + depth++; + break; + + case XMLStreamConstants.END_ELEMENT: + depth--; + if (hasText == false && prevEventType != XMLStreamConstants.START_ELEMENT) { + newLine(); + } + core.add(event); + hasText = false; + break; + + case XMLStreamConstants.PROCESSING_INSTRUCTION: + case XMLStreamConstants.COMMENT: + case XMLStreamConstants.DTD: + // those things can be mixed with text, + // and at this point we don't know if text follows this + // like <foo><?pi?>text</foo> + // + // but we make a bold assumption that the those primitives + // only appear as a part of the element-only content model. + // so we always indent them as: + // <foo> + // <?pi?> + // ... + // </foo> + if (hasText == false && prevEventType != XMLStreamConstants.START_ELEMENT) { + // if we know that we already had a text, I see no + // reason to indent + newLine(); + } + core.add(event); + return; + + case XMLStreamConstants.END_DOCUMENT: + core.add(event); + // some implementation does the buffering by default, + // and it prevents the output from appearing. + // this has been a confusion for many people. + // calling flush wouldn't hurt decent impls, and it + // prevent such unnecessary confusion. + flush(); + break; + + default: + core.add(event); + break; + } + + prevEventType = event.getEventType(); + } + + public void add(XMLEventReader reader) throws XMLStreamException { + // we can't just delegate to the core + // because we need to do indentation. + if (reader == null) { + throw new IllegalArgumentException(); + } + while (reader.hasNext()) { + add(reader.nextEvent()); + } + } + + public void close() throws XMLStreamException { + core.close(); + } + + public void flush() throws XMLStreamException { + core.flush(); + } + + /** + * Returns the string used for indentation. + * @return the string used for indentation + */ + public String getIndent() { + return indent; + } + + public NamespaceContext getNamespaceContext() { + return core.getNamespaceContext(); + } + + /** + * Returns the string used for newline. + * @return the string used for newline + */ + public String getNewLine() { + return newLine; + } + + public String getPrefix(String uri) throws XMLStreamException { + return core.getPrefix(uri); + } + + public void setDefaultNamespace(String uri) throws XMLStreamException { + core.setDefaultNamespace(uri); + } + + /** + * Sets the string used for indentation. + * + * <p> + * By default, this is set to two space chars. + * + * @param indent + * A string like " ", "\\t". Must not be null. + */ + public void setIndent(String indent) { + if (indent == null) { + throw new IllegalArgumentException(); + } + this.indent = indent; + } + + public void setNamespaceContext(NamespaceContext context) throws XMLStreamException { + core.setNamespaceContext(context); + } + + /** + * Sets the string used for newline. + * + * <p> + * By default, this is set to the platform default new line. + * + * @param newLine + * A string like "\\n" or "\\r\\n". Must not be null. + */ + public void setNewLine(String newLine) { + if (newLine == null) { + throw new IllegalArgumentException(); + } + this.newLine = newLine; + } + + public void setPrefix(String prefix, String uri) throws XMLStreamException { + core.setPrefix(prefix, uri); + } + + /** + * Prints out a new line and indent. + * @throws XMLStreamException + */ + private void newLine() throws XMLStreamException { + core.add(newLineEvent); + for (int i = 0; i < depth; i++) { + core.add(indentEvent); + } + } + + + /** + * Partial implementation of {@link Characters} event. + */ + private abstract static class CharactersImpl implements Characters { + + public Characters asCharacters() { + return this; + } + + public EndElement asEndElement() { + return null; + } + + public StartElement asStartElement() { + return null; + } + + public int getEventType() { + // it's not clear if we are supposed to return SPACES + return XMLStreamConstants.CHARACTERS; + } + + public Location getLocation() { + // spec isn't clear if we can return null, but it doesn't say we can't. + return null; + } + + public QName getSchemaType() { + return null; + } + + public boolean isAttribute() { + return false; + } + + public boolean isCData() { + return false; + } + + public boolean isCharacters() { + return true; + } + + public boolean isEndDocument() { + return false; + } + + public boolean isEndElement() { + return false; + } + + public boolean isEntityReference() { + return false; + } + + public boolean isIgnorableWhiteSpace() { + // this is hard call. On one hand, we want the indentation to + // get through whatever pipeline, so we are tempted to return false. + // also DTD isn't necessarily present. + // + // But on the other hand, this IS an ignorable whitespace + // in its intended meaning. + return true; + } + + public boolean isNamespace() { + return false; + } + + public boolean isProcessingInstruction() { + return false; + } + + public boolean isStartDocument() { + return false; + } + + public boolean isStartElement() { + return false; + } + + public boolean isWhiteSpace() { + return true; + } + + public void writeAsEncodedUnicode(Writer writer) throws XMLStreamException { + try { + // technically we need to do escaping, for we allow + // any characters to be used for indent and newLine. + // but in practice, who'll use something other than 0x20,0x0D,0x0A,0x08? + writer.write(getData()); + } catch (IOException e) { + throw new XMLStreamException(e); + } + } + + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/javanet/staxutils/IndentingXMLEventWriter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/javanet/staxutils/package-info.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/javanet/staxutils/package-info.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/javanet/staxutils/package-info.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,11 +1,11 @@ -/** - * StAXによるXML出力を整形するXMLEventWriterのラッパー用パッケージ。 - * - * <p>stax-utilsからコードを拝借し、Jiemamy用に修正を加えた。</p> - * - * <p>https://stax-utils.dev.java.net/</p> - * - * @author daisuke - */ -package javanet.staxutils; - +/** + * StAXによるXML出力を整形するXMLEventWriterのラッパー用パッケージ。 + * + * <p>stax-utilsからコードを拝借し、Jiemamy用に修正を加えた。</p> + * + * <p>https://stax-utils.dev.java.net/</p> + * + * @author daisuke + */ +package javanet.staxutils; + Property changes on: sandbox/jiemamy-stax/src/main/java/javanet/staxutils/package-info.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/AttributeIterator.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/AttributeIterator.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/AttributeIterator.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,60 +1,60 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/26 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import javax.xml.namespace.QName; -import javax.xml.stream.events.Attribute; - -/** - * XML属性のイテレータ実装。 - * - * @author daisuke - */ -class AttributeIterator implements Iterator<Attribute> { - - /** XML属性の完全修飾名と値を保持する{@link Map.Entry}のイテレータ */ - private Iterator<Entry<QName, String>> mapIter; - - - /** - * インスタンスを生成する。 - * - * @param map - */ - AttributeIterator(Map<QName, String> map) { - mapIter = map.entrySet().iterator(); - } - - public boolean hasNext() { - return mapIter.hasNext(); - } - - public Attribute next() { - Entry<QName, String> entry = mapIter.next(); - return StaxCommandDestination.EVENT_FACTORY.createAttribute(entry.getKey(), entry.getValue()); - } - - public void remove() { - throw new UnsupportedOperationException(); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/26 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import javax.xml.namespace.QName; +import javax.xml.stream.events.Attribute; + +/** + * XML属性のイテレータ実装。 + * + * @author daisuke + */ +class AttributeIterator implements Iterator<Attribute> { + + /** XML属性の完全修飾名と値を保持する{@link Map.Entry}のイテレータ */ + private Iterator<Entry<QName, String>> mapIter; + + + /** + * インスタンスを生成する。 + * + * @param map + */ + AttributeIterator(Map<QName, String> map) { + mapIter = map.entrySet().iterator(); + } + + public boolean hasNext() { + return mapIter.hasNext(); + } + + public Attribute next() { + Entry<QName, String> entry = mapIter.next(); + return StaxCommandDestination.EVENT_FACTORY.createAttribute(entry.getKey(), entry.getValue()); + } + + public void remove() { + throw new UnsupportedOperationException(); + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/AttributeIterator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,28 +1,28 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * XMLコマンドストリームの終了を表すXMLコマンド。 - * - * @author daisuke - */ -public interface CloseCommand extends JiemamyXmlCommand { - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * XMLコマンドストリームの終了を表すXMLコマンド。 + * + * @author daisuke + */ +public interface CloseCommand extends JiemamyXmlCommand { + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommandImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommandImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommandImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,28 +1,28 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * モデルに対する操作終了を表すXMLコマンド。 - * - * @author daisuke - */ -public class CloseCommandImpl implements CloseCommand { - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * モデルに対する操作終了を表すXMLコマンド。 + * + * @author daisuke + */ +public class CloseCommandImpl implements CloseCommand { + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CloseCommandImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandContextImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandContextImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandContextImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,109 +1,109 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import org.jiemamy.utils.ArrayEssentialStack; -import org.jiemamy.utils.EssentialStack; - -/** - * XMLコマンド実行のコンテキスト(履歴というか状況というか)を保持するクラス。 - * - * @author daisuke - */ -public class CommandContextImpl implements XmlCommandContext { - - private EssentialStack<JiemamyXmlCommand> commandStack = new ArrayEssentialStack<JiemamyXmlCommand>(); - - - public void begin(OpenCommand command) throws JiemamyXmlCommandException { - if (isOpen()) { - throw new JiemamyXmlCommandException(); - } - commandStack.push(command); - assert isOpen(); - } - - public void begin(StartElementCommand command) throws JiemamyXmlCommandException { - if (isOpen() == false) { - throw new JiemamyXmlCommandException(); - } - commandStack.push(command); - assert isOpen(); - } - - public void end(CloseCommand command) throws JiemamyXmlCommandException { - if (isOpen() == false) { - throw new JiemamyXmlCommandException(); - } - JiemamyXmlCommand pop = commandStack.pop(); - if (pop instanceof OpenCommand == false) { - throw new JiemamyXmlCommandException(); - } - - assert isOpen() == false; - } - - public StartElementCommand end(EndElementCommand command) throws JiemamyXmlCommandException { - if (isOpen() == false) { - throw new JiemamyXmlCommandException(); - } - JiemamyXmlCommand pop = commandStack.pop(); - if (pop instanceof StartElementCommand == false) { - throw new JiemamyXmlCommandException(); - } - StartElementCommand start = (StartElementCommand) pop; - if (start.getQName().equals(command.getQName()) == false) { - throw new JiemamyXmlCommandException(); - } - - assert isOpen(); - - return start; - } - - public boolean isOpen() { - return commandStack.isEmpty() == false; - } - - public DataCommand popData() throws JiemamyXmlCommandException { - if (isOpen() == false) { - throw new JiemamyXmlCommandException(); - } - DataCommand dataCommand; - if (commandStack.peek() instanceof DataCommand) { - dataCommand = (DataCommand) commandStack.pop(); - } else if (commandStack.peek() instanceof StartElementCommand) { - return new DataCommandImpl(null); - } else { - throw new JiemamyXmlCommandException(); - } - - assert isOpen(); - - return dataCommand; - } - - public void pushData(DataCommand command) throws JiemamyXmlCommandException { - if (isOpen() == false) { - throw new JiemamyXmlCommandException(); - } - commandStack.push(command); - assert isOpen(); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import org.jiemamy.utils.ArrayEssentialStack; +import org.jiemamy.utils.EssentialStack; + +/** + * XMLコマンド実行のコンテキスト(履歴というか状況というか)を保持するクラス。 + * + * @author daisuke + */ +public class CommandContextImpl implements XmlCommandContext { + + private EssentialStack<JiemamyXmlCommand> commandStack = new ArrayEssentialStack<JiemamyXmlCommand>(); + + + public void begin(OpenCommand command) throws JiemamyXmlCommandException { + if (isOpen()) { + throw new JiemamyXmlCommandException(); + } + commandStack.push(command); + assert isOpen(); + } + + public void begin(StartElementCommand command) throws JiemamyXmlCommandException { + if (isOpen() == false) { + throw new JiemamyXmlCommandException(); + } + commandStack.push(command); + assert isOpen(); + } + + public void end(CloseCommand command) throws JiemamyXmlCommandException { + if (isOpen() == false) { + throw new JiemamyXmlCommandException(); + } + JiemamyXmlCommand pop = commandStack.pop(); + if (pop instanceof OpenCommand == false) { + throw new JiemamyXmlCommandException(); + } + + assert isOpen() == false; + } + + public StartElementCommand end(EndElementCommand command) throws JiemamyXmlCommandException { + if (isOpen() == false) { + throw new JiemamyXmlCommandException(); + } + JiemamyXmlCommand pop = commandStack.pop(); + if (pop instanceof StartElementCommand == false) { + throw new JiemamyXmlCommandException(); + } + StartElementCommand start = (StartElementCommand) pop; + if (start.getQName().equals(command.getQName()) == false) { + throw new JiemamyXmlCommandException(); + } + + assert isOpen(); + + return start; + } + + public boolean isOpen() { + return commandStack.isEmpty() == false; + } + + public DataCommand popData() throws JiemamyXmlCommandException { + if (isOpen() == false) { + throw new JiemamyXmlCommandException(); + } + DataCommand dataCommand; + if (commandStack.peek() instanceof DataCommand) { + dataCommand = (DataCommand) commandStack.pop(); + } else if (commandStack.peek() instanceof StartElementCommand) { + return new DataCommandImpl(null); + } else { + throw new JiemamyXmlCommandException(); + } + + assert isOpen(); + + return dataCommand; + } + + public void pushData(DataCommand command) throws JiemamyXmlCommandException { + if (isOpen() == false) { + throw new JiemamyXmlCommandException(); + } + commandStack.push(command); + assert isOpen(); + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandContextImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandDestination.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandDestination.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandDestination.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,35 +1,35 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/26 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * {@link JiemamyXmlCommand}を適用する、行き先リソース。 - * - * @author daisuke - */ -public interface CommandDestination { - - /** - * オブジェクトに対してcommandを実行する。 - * - * @param command 実行するXMLコマンド - * @throws JiemamyXmlCommandException - */ - void apply(JiemamyXmlCommand command) throws JiemamyXmlCommandException; -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/26 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * {@link JiemamyXmlCommand}を適用する、行き先リソース。 + * + * @author daisuke + */ +public interface CommandDestination { + + /** + * オブジェクトに対してcommandを実行する。 + * + * @param command 実行するXMLコマンド + * @throws JiemamyXmlCommandException + */ + void apply(JiemamyXmlCommand command) throws JiemamyXmlCommandException; +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandDestination.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandSource.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandSource.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandSource.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,35 +1,35 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * {@link JiemamyXmlCommand}インスタンスを生成する元となるリソース。 - * - * @author daisuke - */ -public interface CommandSource { - - /** - * XMLコマンドを取得する。 - * - * @return XMLコマンド - */ - JiemamyXmlCommand getCommand(); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * {@link JiemamyXmlCommand}インスタンスを生成する元となるリソース。 + * + * @author daisuke + */ +public interface CommandSource { + + /** + * XMLコマンドを取得する。 + * + * @return XMLコマンド + */ + JiemamyXmlCommand getCommand(); + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/CommandSource.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,35 +1,35 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * モデル操作の内容を表すXMLコマンド。 - * - * @author daisuke - */ -public interface DataCommand extends JiemamyXmlCommand { - - /** - * 操作内容を示す文字列を取得する。 - * - * @return 文字列 - */ - String getData(); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * モデル操作の内容を表すXMLコマンド。 + * + * @author daisuke + */ +public interface DataCommand extends JiemamyXmlCommand { + + /** + * 操作内容を示す文字列を取得する。 + * + * @return 文字列 + */ + String getData(); + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommandImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommandImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommandImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,44 +1,44 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/19 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * モデルの実データを表すXMLコマンド。 - * - * @author daisuke - */ -public class DataCommandImpl implements DataCommand { - - private String data; - - - /** - * インスタンスを生成する。 - * - * @param data - */ - public DataCommandImpl(String data) { - this.data = data; - } - - public String getData() { - return data; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/19 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * モデルの実データを表すXMLコマンド。 + * + * @author daisuke + */ +public class DataCommandImpl implements DataCommand { + + private String data; + + + /** + * インスタンスを生成する。 + * + * @param data + */ + public DataCommandImpl(String data) { + this.data = data; + } + + public String getData() { + return data; + } + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/DataCommandImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,37 +1,37 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import javax.xml.namespace.QName; - -/** - * モデル操作の終了を表すXMLコマンド。 - * - * @author daisuke - */ -public interface EndElementCommand extends JiemamyXmlCommand { - - /** - * 完全修飾名を取得する。 - * - * @return 完全修飾名 - */ - QName getQName(); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import javax.xml.namespace.QName; + +/** + * モデル操作の終了を表すXMLコマンド。 + * + * @author daisuke + */ +public interface EndElementCommand extends JiemamyXmlCommand { + + /** + * 完全修飾名を取得する。 + * + * @return 完全修飾名 + */ + QName getQName(); + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommandImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommandImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommandImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,58 +1,58 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import javax.xml.namespace.QName; - -import org.jiemamy.xml.JiemamyQName; - -/** - * モデルの要素データ定義の終了を表すXMLコマンド。 - * - * @author daisuke - */ -public class EndElementCommandImpl implements EndElementCommand { - - /** 完全修飾名 */ - private QName qName; - - - /** - * インスタンスを生成する。 - * - * @param qName - */ - public EndElementCommandImpl(JiemamyQName qName) { - this(qName.getQName()); - } - - /** - * インスタンスを生成する。 - * - * @param qName - */ - public EndElementCommandImpl(QName qName) { - this.qName = qName; - } - - public QName getQName() { - return qName; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import javax.xml.namespace.QName; + +import org.jiemamy.xml.JiemamyQName; + +/** + * モデルの要素データ定義の終了を表すXMLコマンド。 + * + * @author daisuke + */ +public class EndElementCommandImpl implements EndElementCommand { + + /** 完全修飾名 */ + private QName qName; + + + /** + * インスタンスを生成する。 + * + * @param qName + */ + public EndElementCommandImpl(JiemamyQName qName) { + this(qName.getQName()); + } + + /** + * インスタンスを生成する。 + * + * @param qName + */ + public EndElementCommandImpl(QName qName) { + this.qName = qName; + } + + public QName getQName() { + return qName; + } + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/EndElementCommandImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandInputStream.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandInputStream.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandInputStream.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,57 +1,57 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import java.util.NoSuchElementException; - -/** - * JiemamyModelの各種表現をcommand streamとして読み出す為のインターフェイス。 - * - * @author daisuke - */ -public interface JiemamyCommandInputStream { - - /** - * Command streamをcloseし、リソースを破棄する。 - * - * @throws JiemamyXmlCommandException - * @throws IllegalStateException Writerが既にcloseされていた場合 - */ - void close() throws JiemamyXmlCommandException; - - /** - * 読み出せる次のXMLコマンドがあるかどうか調べる。 - * - * @return 次のXMLコマンドがある場合{@code true}、無い場合{@code false}を返す - * @throws JiemamyXmlCommandException - * @throws IllegalStateException Command streamが既にcloseされていた場合 - */ - boolean hasNext() throws JiemamyXmlCommandException; - - /** - * 読み出せる次のXMLコマンドを取得する。 - * - * @return XMLコマンド - * @throws JiemamyXmlCommandException - * @throws NoSuchElementException 読み出せる次のXMLコマンドが存在しない場合 - * @throws IllegalStateException Command streamが既にcloseされていた場合 - */ - JiemamyXmlCommand nextCommand() throws JiemamyXmlCommandException; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import java.util.NoSuchElementException; + +/** + * JiemamyModelの各種表現をcommand streamとして読み出す為のインターフェイス。 + * + * @author daisuke + */ +public interface JiemamyCommandInputStream { + + /** + * Command streamをcloseし、リソースを破棄する。 + * + * @throws JiemamyXmlCommandException + * @throws IllegalStateException Writerが既にcloseされていた場合 + */ + void close() throws JiemamyXmlCommandException; + + /** + * 読み出せる次のXMLコマンドがあるかどうか調べる。 + * + * @return 次のXMLコマンドがある場合{@code true}、無い場合{@code false}を返す + * @throws JiemamyXmlCommandException + * @throws IllegalStateException Command streamが既にcloseされていた場合 + */ + boolean hasNext() throws JiemamyXmlCommandException; + + /** + * 読み出せる次のXMLコマンドを取得する。 + * + * @return XMLコマンド + * @throws JiemamyXmlCommandException + * @throws NoSuchElementException 読み出せる次のXMLコマンドが存在しない場合 + * @throws IllegalStateException Command streamが既にcloseされていた場合 + */ + JiemamyXmlCommand nextCommand() throws JiemamyXmlCommandException; + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandInputStream.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandOutputStream.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandOutputStream.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandOutputStream.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,49 +1,49 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * {@link JiemamyXmlCommand}で表されるJiemamyのモデルの内容を書き出す、Writerのインターフェイス。 - * - * <p>TODO XMLコマンド順番規約について</p> - * - * @author daisuke - */ -public interface JiemamyCommandOutputStream { - - /** - * Command streamをcloseし、リソースを破棄する。 - * - * @throws JiemamyXmlCommandException - * @throws IllegalStateException Command streamが既にcloseされていた場合 - */ - void close() throws JiemamyXmlCommandException; - - /** - * XMLコマンドの内容をモデルに書き出す。 - * - * @param command XMLコマンド - * @throws JiemamyXmlCommandException - * @throws IllegalStateException XMLコマンドの順番が規約に従っていなかった場合。 - * @throws IllegalStateException Command streamが既にcloseされていた場合 - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - void write(JiemamyXmlCommand command) throws JiemamyXmlCommandException; - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * {@link JiemamyXmlCommand}で表されるJiemamyのモデルの内容を書き出す、Writerのインターフェイス。 + * + * <p>TODO XMLコマンド順番規約について</p> + * + * @author daisuke + */ +public interface JiemamyCommandOutputStream { + + /** + * Command streamをcloseし、リソースを破棄する。 + * + * @throws JiemamyXmlCommandException + * @throws IllegalStateException Command streamが既にcloseされていた場合 + */ + void close() throws JiemamyXmlCommandException; + + /** + * XMLコマンドの内容をモデルに書き出す。 + * + * @param command XMLコマンド + * @throws JiemamyXmlCommandException + * @throws IllegalStateException XMLコマンドの順番が規約に従っていなかった場合。 + * @throws IllegalStateException Command streamが既にcloseされていた場合 + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + void write(JiemamyXmlCommand command) throws JiemamyXmlCommandException; + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyCommandOutputStream.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,28 +1,28 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * Jiemamyのモデル操作をあらわすXMLコマンドオブジェクト。 - * - * @author daisuke - */ -public interface JiemamyXmlCommand { - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * Jiemamyのモデル操作をあらわすXMLコマンドオブジェクト。 + * + * @author daisuke + */ +public interface JiemamyXmlCommand { + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommandException.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommandException.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommandException.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,64 +1,64 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * XMLコマンドの読み出し・書き出しに失敗した場合。 - * - * @author daisuke - */ - @ SuppressWarnings("serial") -public class JiemamyXmlCommandException extends Exception { - - /** - * インスタンスを生成する。 - */ - public JiemamyXmlCommandException() { - super(); - } - - /** - * インスタンスを生成する。 - * - * @param message 例外メッセージ - */ - public JiemamyXmlCommandException(String message) { - super(message); - } - - /** - * インスタンスを生成する。 - * - * @param message 例外メッセージ - * @param cause 起因例外 - */ - public JiemamyXmlCommandException(String message, Throwable cause) { - super(message, cause); - } - - /** - * インスタンスを生成する。 - * - * @param cause 起因例外 - */ - public JiemamyXmlCommandException(Throwable cause) { - super(cause); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * XMLコマンドの読み出し・書き出しに失敗した場合。 + * + * @author daisuke + */ + @ SuppressWarnings("serial") +public class JiemamyXmlCommandException extends Exception { + + /** + * インスタンスを生成する。 + */ + public JiemamyXmlCommandException() { + super(); + } + + /** + * インスタンスを生成する。 + * + * @param message 例外メッセージ + */ + public JiemamyXmlCommandException(String message) { + super(message); + } + + /** + * インスタンスを生成する。 + * + * @param message 例外メッセージ + * @param cause 起因例外 + */ + public JiemamyXmlCommandException(String message, Throwable cause) { + super(message, cause); + } + + /** + * インスタンスを生成する。 + * + * @param cause 起因例外 + */ + public JiemamyXmlCommandException(Throwable cause) { + super(cause); + } + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/JiemamyXmlCommandException.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/NullCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/NullCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/NullCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,28 +1,28 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * 何もしないダミーXMLコマンド。 - * - * @author daisuke - */ -public class NullCommand implements JiemamyXmlCommand { - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * 何もしないダミーXMLコマンド。 + * + * @author daisuke + */ +public class NullCommand implements JiemamyXmlCommand { + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/NullCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/ObjectCommandDestination.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/ObjectCommandDestination.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/ObjectCommandDestination.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,108 +1,108 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/26 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import org.apache.commons.lang.StringUtils; - -import org.jiemamy.Jiemamy; -import org.jiemamy.model.RootModel; -import org.jiemamy.utils.UUIDUtil; -import org.jiemamy.xml.CoreQName; - -/** - * RootModelに対して情報出力を行う{@link CommandDestination}実装クラス。 - * - * @author daisuke - */ -public class ObjectCommandDestination implements CommandDestination { - - private XmlCommandContext ctx = new CommandContextImpl(); - - /** {@link JiemamyXmlCommand}を適用した{@link RootModel} */ - private RootModel rootModel; - - private Jiemamy jiemamy; - - - /** - * インスタンスを生成する。 - * - * @param jiemamy - */ - public ObjectCommandDestination(Jiemamy jiemamy) { - this.jiemamy = jiemamy; - } - - /** - * インスタンスを生成する。 - * - * @param rootModel - */ - public ObjectCommandDestination(RootModel rootModel) { - jiemamy = rootModel.getJiemamy(); - this.rootModel = rootModel; - } - - public void apply(JiemamyXmlCommand command) throws JiemamyXmlCommandException { - if (command instanceof OpenCommand) { - OpenCommand openCommand = (OpenCommand) command; - ctx.begin(openCommand); - } else if (command instanceof StartElementCommand) { - StartElementCommand startCommand = (StartElementCommand) command; - ctx.begin(startCommand); - if (startCommand.getQName().equals(CoreQName.JIEMAMY.getQName())) { - String id = startCommand.getAttributes().get(CoreQName.ID.getQName()); - rootModel = jiemamy.getFactory().getRootModel(UUIDUtil.valueOfOrRandom(id)); - } - } else if (command instanceof DataCommand) { - DataCommand dataCommand = (DataCommand) command; - ctx.pushData(dataCommand); - } else if (command instanceof EndElementCommand) { - EndElementCommand endCommand = (EndElementCommand) command; - DataCommand data = ctx.popData(); - StartElementCommand start = ctx.end(endCommand); - - // FIXME ↓このまま else if が続くのか…? - - // startに対応する場所にdataを変換しつつ代入 - if (start.getQName().equals(CoreQName.DIALECT.getQName())) { - if (StringUtils.isBlank(data.getData()) == false) { - rootModel.setDialectClassName(data.getData()); - } - } - } else if (command instanceof CloseCommand) { - CloseCommand closeCommand = (CloseCommand) command; - ctx.end(closeCommand); - } - } - - /** - * {@link JiemamyXmlCommand}を適用した{@link RootModel}を取得する。 - * - * @return {@link JiemamyXmlCommand}を適用した{@link RootModel} - * @throws IllegalStateException XMLコマンドがOpenされた後、まだCloseされていない場合。 - */ - public RootModel getRootModel() { - if (ctx.isOpen()) { - throw new IllegalStateException(); - } - return rootModel; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/26 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import org.apache.commons.lang.StringUtils; + +import org.jiemamy.Jiemamy; +import org.jiemamy.model.RootModel; +import org.jiemamy.utils.UUIDUtil; +import org.jiemamy.xml.CoreQName; + +/** + * RootModelに対して情報出力を行う{@link CommandDestination}実装クラス。 + * + * @author daisuke + */ +public class ObjectCommandDestination implements CommandDestination { + + private XmlCommandContext ctx = new CommandContextImpl(); + + /** {@link JiemamyXmlCommand}を適用した{@link RootModel} */ + private RootModel rootModel; + + private Jiemamy jiemamy; + + + /** + * インスタンスを生成する。 + * + * @param jiemamy + */ + public ObjectCommandDestination(Jiemamy jiemamy) { + this.jiemamy = jiemamy; + } + + /** + * インスタンスを生成する。 + * + * @param rootModel + */ + public ObjectCommandDestination(RootModel rootModel) { + jiemamy = rootModel.getJiemamy(); + this.rootModel = rootModel; + } + + public void apply(JiemamyXmlCommand command) throws JiemamyXmlCommandException { + if (command instanceof OpenCommand) { + OpenCommand openCommand = (OpenCommand) command; + ctx.begin(openCommand); + } else if (command instanceof StartElementCommand) { + StartElementCommand startCommand = (StartElementCommand) command; + ctx.begin(startCommand); + if (startCommand.getQName().equals(CoreQName.JIEMAMY.getQName())) { + String id = startCommand.getAttributes().get(CoreQName.ID.getQName()); + rootModel = jiemamy.getFactory().getRootModel(UUIDUtil.valueOfOrRandom(id)); + } + } else if (command instanceof DataCommand) { + DataCommand dataCommand = (DataCommand) command; + ctx.pushData(dataCommand); + } else if (command instanceof EndElementCommand) { + EndElementCommand endCommand = (EndElementCommand) command; + DataCommand data = ctx.popData(); + StartElementCommand start = ctx.end(endCommand); + + // FIXME ↓このまま else if が続くのか…? + + // startに対応する場所にdataを変換しつつ代入 + if (start.getQName().equals(CoreQName.DIALECT.getQName())) { + if (StringUtils.isBlank(data.getData()) == false) { + rootModel.setDialectClassName(data.getData()); + } + } + } else if (command instanceof CloseCommand) { + CloseCommand closeCommand = (CloseCommand) command; + ctx.end(closeCommand); + } + } + + /** + * {@link JiemamyXmlCommand}を適用した{@link RootModel}を取得する。 + * + * @return {@link JiemamyXmlCommand}を適用した{@link RootModel} + * @throws IllegalStateException XMLコマンドがOpenされた後、まだCloseされていない場合。 + */ + public RootModel getRootModel() { + if (ctx.isOpen()) { + throw new IllegalStateException(); + } + return rootModel; + } + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/ObjectCommandDestination.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,28 +1,28 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * XMLコマンドストリームの開始を表すXMLコマンド。 - * - * @author daisuke - */ -public interface OpenCommand extends JiemamyXmlCommand { - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * XMLコマンドストリームの開始を表すXMLコマンド。 + * + * @author daisuke + */ +public interface OpenCommand extends JiemamyXmlCommand { + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommandImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommandImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommandImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,28 +1,28 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * モデルに対する操作開始を表すXMLコマンド。 - * - * @author daisuke - */ -public class OpenCommandImpl implements OpenCommand { - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * モデルに対する操作開始を表すXMLコマンド。 + * + * @author daisuke + */ +public class OpenCommandImpl implements OpenCommand { + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/OpenCommandImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,45 +1,45 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import java.util.Map; - -import javax.xml.namespace.QName; - -/** - * モデル操作の開始を表すXMLコマンド。 - * - * @author daisuke - */ -public interface StartElementCommand extends JiemamyXmlCommand { - - /** - * 属性マップを取得する。 - * - * @return 属性マップ - */ - Map<QName, String> getAttributes(); - - /** - * 完全修飾名を取得する。 - * - * @return 完全修飾名 - */ - QName getQName(); -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import java.util.Map; + +import javax.xml.namespace.QName; + +/** + * モデル操作の開始を表すXMLコマンド。 + * + * @author daisuke + */ +public interface StartElementCommand extends JiemamyXmlCommand { + + /** + * 属性マップを取得する。 + * + * @return 属性マップ + */ + Map<QName, String> getAttributes(); + + /** + * 完全修飾名を取得する。 + * + * @return 完全修飾名 + */ + QName getQName(); +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommandImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommandImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommandImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,94 +1,94 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.commons.collections15.MapUtils; -import org.apache.commons.lang.Validate; - -import org.jiemamy.xml.JiemamyQName; - -/** - * モデルの要素データ定義の開始を表すXMLコマンド。 - * - * @author daisuke - */ -public class StartElementCommandImpl implements StartElementCommand { - - /** 属性マップ */ - private final Map<QName, String> attributes; - - /** 完全修飾名 */ - private final QName qName; - - - /** - * インスタンスを生成する。 - * - * @param qName 完全修飾名 - */ - // 空のMapであるため、タイプセーフである。 - @SuppressWarnings("unchecked") - public StartElementCommandImpl(JiemamyQName qName) { - this(qName.getQName(), MapUtils.EMPTY_MAP); - } - - /** - * インスタンスを生成する。 - * - * @param qName 完全修飾名 - * @param attributes 属性マップ - */ - public StartElementCommandImpl(JiemamyQName qName, Map<QName, String> attributes) { - this(qName.getQName(), attributes); - } - - /** - * インスタンスを生成する。 - * @param qName - */ - // 空のMapであるため、タイプセーフである。 - @SuppressWarnings("unchecked") - public StartElementCommandImpl(QName qName) { - this(qName, MapUtils.EMPTY_MAP); - } - - /** - * インスタンスを生成する。 - * @param qName - * @param attributes - */ - public StartElementCommandImpl(QName qName, Map<QName, String> attributes) { - Validate.notNull(qName); - Validate.notNull(attributes); - this.qName = qName; - this.attributes = attributes; - } - - public Map<QName, String> getAttributes() { - return attributes; - } - - public QName getQName() { - return qName; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.commons.collections15.MapUtils; +import org.apache.commons.lang.Validate; + +import org.jiemamy.xml.JiemamyQName; + +/** + * モデルの要素データ定義の開始を表すXMLコマンド。 + * + * @author daisuke + */ +public class StartElementCommandImpl implements StartElementCommand { + + /** 属性マップ */ + private final Map<QName, String> attributes; + + /** 完全修飾名 */ + private final QName qName; + + + /** + * インスタンスを生成する。 + * + * @param qName 完全修飾名 + */ + // 空のMapであるため、タイプセーフである。 + @SuppressWarnings("unchecked") + public StartElementCommandImpl(JiemamyQName qName) { + this(qName.getQName(), MapUtils.EMPTY_MAP); + } + + /** + * インスタンスを生成する。 + * + * @param qName 完全修飾名 + * @param attributes 属性マップ + */ + public StartElementCommandImpl(JiemamyQName qName, Map<QName, String> attributes) { + this(qName.getQName(), attributes); + } + + /** + * インスタンスを生成する。 + * @param qName + */ + // 空のMapであるため、タイプセーフである。 + @SuppressWarnings("unchecked") + public StartElementCommandImpl(QName qName) { + this(qName, MapUtils.EMPTY_MAP); + } + + /** + * インスタンスを生成する。 + * @param qName + * @param attributes + */ + public StartElementCommandImpl(QName qName, Map<QName, String> attributes) { + Validate.notNull(qName); + Validate.notNull(attributes); + this.qName = qName; + this.attributes = attributes; + } + + public Map<QName, String> getAttributes() { + return attributes; + } + + public QName getQName() { + return qName; + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StartElementCommandImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandDestination.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandDestination.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandDestination.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,108 +1,108 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/26 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import java.util.Iterator; - -import javax.xml.stream.XMLEventFactory; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.Characters; - -import org.apache.commons.lang.CharEncoding; -import org.apache.commons.lang.Validate; - -/** - * StAXによりXMLとして情報出力を行う{@link CommandDestination}実装クラス。 - * - * @author daisuke - */ -public class StaxCommandDestination implements CommandDestination { - - /** {@link XMLEventFactory} */ - static final XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance(); - - /** 出力用StAX {@link XMLEventWriter} */ - private XMLEventWriter xmlWriter; - - - /** - * インスタンスを生成する。 - * - * @param xmlWriter - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public StaxCommandDestination(XMLEventWriter xmlWriter) { - Validate.notNull(xmlWriter); - this.xmlWriter = xmlWriter; - } - - public void apply(JiemamyXmlCommand command) throws JiemamyXmlCommandException { - if (command instanceof OpenCommand) { - try { - xmlWriter.add(EVENT_FACTORY.createStartDocument(CharEncoding.UTF_8, "1.0", false)); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } else if (command instanceof StartElementCommand) { - StartElementCommand startCommand = (StartElementCommand) command; - try { - Iterator<Attribute> attributes = new AttributeIterator(startCommand.getAttributes()); - xmlWriter.add(EVENT_FACTORY.createStartElement(startCommand.getQName(), attributes, null)); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } else if (command instanceof DataCommand) { - DataCommand dataCommand = (DataCommand) command; - String data = dataCommand.getData(); - if (data != null) { - Characters characters = EVENT_FACTORY.createCharacters(data); - try { - xmlWriter.add(characters); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } - } else if (command instanceof EndElementCommand) { - EndElementCommand endCommand = (EndElementCommand) command; - try { - xmlWriter.add(EVENT_FACTORY.createEndElement(endCommand.getQName(), null)); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } else if (command instanceof CloseCommand) { - try { - xmlWriter.add(EVENT_FACTORY.createEndDocument()); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } - } - - /** - * 出力用StAX {@link XMLEventWriter}を取得する。 - * - * @return 出力用StAX {@link XMLEventWriter} - */ - public XMLEventWriter getXmlWriter() { - return xmlWriter; - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/26 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import java.util.Iterator; + +import javax.xml.stream.XMLEventFactory; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.Attribute; +import javax.xml.stream.events.Characters; + +import org.apache.commons.lang.CharEncoding; +import org.apache.commons.lang.Validate; + +/** + * StAXによりXMLとして情報出力を行う{@link CommandDestination}実装クラス。 + * + * @author daisuke + */ +public class StaxCommandDestination implements CommandDestination { + + /** {@link XMLEventFactory} */ + static final XMLEventFactory EVENT_FACTORY = XMLEventFactory.newInstance(); + + /** 出力用StAX {@link XMLEventWriter} */ + private XMLEventWriter xmlWriter; + + + /** + * インスタンスを生成する。 + * + * @param xmlWriter + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public StaxCommandDestination(XMLEventWriter xmlWriter) { + Validate.notNull(xmlWriter); + this.xmlWriter = xmlWriter; + } + + public void apply(JiemamyXmlCommand command) throws JiemamyXmlCommandException { + if (command instanceof OpenCommand) { + try { + xmlWriter.add(EVENT_FACTORY.createStartDocument(CharEncoding.UTF_8, "1.0", false)); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } else if (command instanceof StartElementCommand) { + StartElementCommand startCommand = (StartElementCommand) command; + try { + Iterator<Attribute> attributes = new AttributeIterator(startCommand.getAttributes()); + xmlWriter.add(EVENT_FACTORY.createStartElement(startCommand.getQName(), attributes, null)); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } else if (command instanceof DataCommand) { + DataCommand dataCommand = (DataCommand) command; + String data = dataCommand.getData(); + if (data != null) { + Characters characters = EVENT_FACTORY.createCharacters(data); + try { + xmlWriter.add(characters); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } + } else if (command instanceof EndElementCommand) { + EndElementCommand endCommand = (EndElementCommand) command; + try { + xmlWriter.add(EVENT_FACTORY.createEndElement(endCommand.getQName(), null)); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } else if (command instanceof CloseCommand) { + try { + xmlWriter.add(EVENT_FACTORY.createEndDocument()); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } + } + + /** + * 出力用StAX {@link XMLEventWriter}を取得する。 + * + * @return 出力用StAX {@link XMLEventWriter} + */ + public XMLEventWriter getXmlWriter() { + return xmlWriter; + } + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandDestination.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandSource.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandSource.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandSource.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,90 +1,90 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.utils.StaxUtil; - -/** - * XMLコマンドを生成するファクトリクラス。 - * - * @author daisuke - */ -public final class StaxCommandSource implements CommandSource { - - private static Logger logger = LoggerFactory.getLogger(StaxCommandSource.class); - - private XMLEvent xmlEvent; - - - /** - * インスタンスを生成する。 - * - * @param xmlEvent - */ - public StaxCommandSource(XMLEvent xmlEvent) { - this.xmlEvent = xmlEvent; - } - - public JiemamyXmlCommand getCommand() { - logger.info("Type: " + StaxUtil.toEventTypeEnum(xmlEvent.getEventType()).toString()); - - switch (xmlEvent.getEventType()) { - case XMLStreamConstants.START_DOCUMENT: - return new OpenCommandImpl(); - - case XMLStreamConstants.END_DOCUMENT: - return new CloseCommandImpl(); - - case XMLStreamConstants.START_ELEMENT: - StartElement startElement = xmlEvent.asStartElement(); - Map<QName, String> attributes = new HashMap<QName, String>(); - - // StartElement#getAttributes() は、Attributeのイテレータを返す仕様である。 - @SuppressWarnings("unchecked") - Iterator<Attribute> itr = startElement.getAttributes(); - while (itr.hasNext()) { - Attribute attribute = itr.next(); - attributes.put(attribute.getName(), attribute.getValue()); - } - return new StartElementCommandImpl(xmlEvent.asStartElement().getName(), attributes); - - case XMLStreamConstants.END_ELEMENT: - return new EndElementCommandImpl(xmlEvent.asEndElement().getName()); - - case XMLStreamConstants.CHARACTERS: - return new DataCommandImpl(xmlEvent.asCharacters().getData()); - - default: - return new NullCommand(); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/18 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.events.Attribute; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.utils.StaxUtil; + +/** + * XMLコマンドを生成するファクトリクラス。 + * + * @author daisuke + */ +public final class StaxCommandSource implements CommandSource { + + private static Logger logger = LoggerFactory.getLogger(StaxCommandSource.class); + + private XMLEvent xmlEvent; + + + /** + * インスタンスを生成する。 + * + * @param xmlEvent + */ + public StaxCommandSource(XMLEvent xmlEvent) { + this.xmlEvent = xmlEvent; + } + + public JiemamyXmlCommand getCommand() { + logger.info("Type: " + StaxUtil.toEventTypeEnum(xmlEvent.getEventType()).toString()); + + switch (xmlEvent.getEventType()) { + case XMLStreamConstants.START_DOCUMENT: + return new OpenCommandImpl(); + + case XMLStreamConstants.END_DOCUMENT: + return new CloseCommandImpl(); + + case XMLStreamConstants.START_ELEMENT: + StartElement startElement = xmlEvent.asStartElement(); + Map<QName, String> attributes = new HashMap<QName, String>(); + + // StartElement#getAttributes() は、Attributeのイテレータを返す仕様である。 + @SuppressWarnings("unchecked") + Iterator<Attribute> itr = startElement.getAttributes(); + while (itr.hasNext()) { + Attribute attribute = itr.next(); + attributes.put(attribute.getName(), attribute.getValue()); + } + return new StartElementCommandImpl(xmlEvent.asStartElement().getName(), attributes); + + case XMLStreamConstants.END_ELEMENT: + return new EndElementCommandImpl(xmlEvent.asEndElement().getName()); + + case XMLStreamConstants.CHARACTERS: + return new DataCommandImpl(xmlEvent.asCharacters().getData()); + + default: + return new NullCommand(); + } + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/StaxCommandSource.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/XmlCommandContext.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/XmlCommandContext.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/XmlCommandContext.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,83 +1,83 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/25 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.command; - -/** - * XMLコマンド実行状況(どのタグが開いているか、など)を保持するクラス。 - * - * @author daisuke - */ -public interface XmlCommandContext { - - /** - * {@link OpenCommand}を記録する。 - * - * @param command {@link OpenCommand} - * @throws JiemamyXmlCommandException - */ - void begin(OpenCommand command) throws JiemamyXmlCommandException; - - /** - * {@link StartElementCommand}を記録する。 - * - * @param command {@link StartElementCommand} - * @throws JiemamyXmlCommandException - */ - void begin(StartElementCommand command) throws JiemamyXmlCommandException; - - /** - * {@link CloseCommand}を記録する。 - * - * @param command {@link CloseCommand} - * @throws JiemamyXmlCommandException - */ - void end(CloseCommand command) throws JiemamyXmlCommandException; - - /** - * {@link EndElementCommand}を記録する。 - * - * @param command {@link EndElementCommand} - * @return この終了XMLコマンドに対応する開始XMLコマンド - * @throws JiemamyXmlCommandException - */ - StartElementCommand end(EndElementCommand command) throws JiemamyXmlCommandException; - - /** - * XMLコマンドストリームが開いている(OpenCommandを受け、CloseCommandを受けていない状態)かどうか調べる。 - * - * @return XMLコマンドストリームが開いていれば{@code true} - */ - boolean isOpen(); - - /** - * 直前に記録した{@link DataCommand}を取得する。 - * - * @return 直前に記録した{@link DataCommand} - * @throws JiemamyXmlCommandException - */ - DataCommand popData() throws JiemamyXmlCommandException; - - /** - * {@link DataCommand}を記録する。 - * - * @param command {@link DataCommand} - * @throws JiemamyXmlCommandException - */ - void pushData(DataCommand command) throws JiemamyXmlCommandException; -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/25 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.command; + +/** + * XMLコマンド実行状況(どのタグが開いているか、など)を保持するクラス。 + * + * @author daisuke + */ +public interface XmlCommandContext { + + /** + * {@link OpenCommand}を記録する。 + * + * @param command {@link OpenCommand} + * @throws JiemamyXmlCommandException + */ + void begin(OpenCommand command) throws JiemamyXmlCommandException; + + /** + * {@link StartElementCommand}を記録する。 + * + * @param command {@link StartElementCommand} + * @throws JiemamyXmlCommandException + */ + void begin(StartElementCommand command) throws JiemamyXmlCommandException; + + /** + * {@link CloseCommand}を記録する。 + * + * @param command {@link CloseCommand} + * @throws JiemamyXmlCommandException + */ + void end(CloseCommand command) throws JiemamyXmlCommandException; + + /** + * {@link EndElementCommand}を記録する。 + * + * @param command {@link EndElementCommand} + * @return この終了XMLコマンドに対応する開始XMLコマンド + * @throws JiemamyXmlCommandException + */ + StartElementCommand end(EndElementCommand command) throws JiemamyXmlCommandException; + + /** + * XMLコマンドストリームが開いている(OpenCommandを受け、CloseCommandを受けていない状態)かどうか調べる。 + * + * @return XMLコマンドストリームが開いていれば{@code true} + */ + boolean isOpen(); + + /** + * 直前に記録した{@link DataCommand}を取得する。 + * + * @return 直前に記録した{@link DataCommand} + * @throws JiemamyXmlCommandException + */ + DataCommand popData() throws JiemamyXmlCommandException; + + /** + * {@link DataCommand}を記録する。 + * + * @param command {@link DataCommand} + * @throws JiemamyXmlCommandException + */ + void pushData(DataCommand command) throws JiemamyXmlCommandException; +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/XmlCommandContext.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/package-info.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/package-info.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/package-info.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,11 +1,11 @@ -/** - * Jiemamyモデルを操作する、コマンドパターンに基づくXMLコマンドオブジェクトの仕様を定義するパッケージ。 - * - * <p>このパッケージは、Jiemamyモデルに対するXMLコマンド仕様を規定するインターフェイスを含む。</p> - * - * <p>FIXME ドキュメンテーション時点で、仕様がまだ未確定である。</p> - * - * @author daisuke - */ -package org.jiemamy.command; - +/** + * Jiemamyモデルを操作する、コマンドパターンに基づくXMLコマンドオブジェクトの仕様を定義するパッケージ。 + * + * <p>このパッケージは、Jiemamyモデルに対するXMLコマンド仕様を規定するインターフェイスを含む。</p> + * + * <p>FIXME ドキュメンテーション時点で、仕様がまだ未確定である。</p> + * + * @author daisuke + */ +package org.jiemamy.command; + Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/command/package-info.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/DialectCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/DialectCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/DialectCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,56 +1,56 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.command; - -import org.jiemamy.command.DataCommandImpl; -import org.jiemamy.command.EndElementCommandImpl; -import org.jiemamy.command.JiemamyXmlCommand; -import org.jiemamy.command.StartElementCommandImpl; -import org.jiemamy.utils.EssentialQueue; -import org.jiemamy.utils.Resolvable; -import org.jiemamy.utils.ResolvableQueue; -import org.jiemamy.xml.CoreQName; - -/** - * {@link Resolvable}な状態のDialectを表すXMLコマンド。 - * - * @author daisuke - */ -public class DialectCommand implements Resolvable<JiemamyXmlCommand> { - - private final String dialectId; - - - /** - * インスタンスを生成する。 - * - * @param dialectId - */ - public DialectCommand(String dialectId) { - this.dialectId = dialectId; - } - - public EssentialQueue<JiemamyXmlCommand> resolve() { - EssentialQueue<JiemamyXmlCommand> queue = new ResolvableQueue<JiemamyXmlCommand>(); - queue.enqueue(new StartElementCommandImpl(CoreQName.DIALECT)); - queue.enqueue(new DataCommandImpl(dialectId)); - queue.enqueue(new EndElementCommandImpl(CoreQName.DIALECT)); - return queue; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/18 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.command; + +import org.jiemamy.command.DataCommandImpl; +import org.jiemamy.command.EndElementCommandImpl; +import org.jiemamy.command.JiemamyXmlCommand; +import org.jiemamy.command.StartElementCommandImpl; +import org.jiemamy.utils.EssentialQueue; +import org.jiemamy.utils.Resolvable; +import org.jiemamy.utils.ResolvableQueue; +import org.jiemamy.xml.CoreQName; + +/** + * {@link Resolvable}な状態のDialectを表すXMLコマンド。 + * + * @author daisuke + */ +public class DialectCommand implements Resolvable<JiemamyXmlCommand> { + + private final String dialectId; + + + /** + * インスタンスを生成する。 + * + * @param dialectId + */ + public DialectCommand(String dialectId) { + this.dialectId = dialectId; + } + + public EssentialQueue<JiemamyXmlCommand> resolve() { + EssentialQueue<JiemamyXmlCommand> queue = new ResolvableQueue<JiemamyXmlCommand>(); + queue.enqueue(new StartElementCommandImpl(CoreQName.DIALECT)); + queue.enqueue(new DataCommandImpl(dialectId)); + queue.enqueue(new EndElementCommandImpl(CoreQName.DIALECT)); + return queue; + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/DialectCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/RootModelCommand.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/RootModelCommand.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/RootModelCommand.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,68 +1,68 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.command; - -import java.util.HashMap; -import java.util.Map; - -import javax.xml.namespace.QName; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.command.EndElementCommandImpl; -import org.jiemamy.command.JiemamyXmlCommand; -import org.jiemamy.command.StartElementCommandImpl; -import org.jiemamy.model.RootModel; -import org.jiemamy.utils.EssentialQueue; -import org.jiemamy.utils.Resolvable; -import org.jiemamy.utils.ResolvableQueue; -import org.jiemamy.xml.CoreQName; - -/** - * {@link Resolvable}な状態の {@link RootModel}を表すXMLコマンド。 - * - * @author daisuke - */ -public class RootModelCommand implements Resolvable<JiemamyXmlCommand> { - - private final RootModel rootModel; - - - /** - * インスタンスを生成する。 - * - * @param rootModel - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public RootModelCommand(RootModel rootModel) { - Validate.notNull(rootModel); - this.rootModel = rootModel; - } - - public EssentialQueue<JiemamyXmlCommand> resolve() { - Map<QName, String> attributes = new HashMap<QName, String>(); - attributes.put(CoreQName.ID.getQName(), rootModel.getId().toString()); - - ResolvableQueue<JiemamyXmlCommand> queue = new ResolvableQueue<JiemamyXmlCommand>(); - queue.enqueue(new StartElementCommandImpl(CoreQName.JIEMAMY, attributes)); - queue.enqueue(new DialectCommand(rootModel.getDialectClassName())); - queue.enqueue(new EndElementCommandImpl(CoreQName.JIEMAMY)); - return queue; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/18 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.command; + +import java.util.HashMap; +import java.util.Map; + +import javax.xml.namespace.QName; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.command.EndElementCommandImpl; +import org.jiemamy.command.JiemamyXmlCommand; +import org.jiemamy.command.StartElementCommandImpl; +import org.jiemamy.model.RootModel; +import org.jiemamy.utils.EssentialQueue; +import org.jiemamy.utils.Resolvable; +import org.jiemamy.utils.ResolvableQueue; +import org.jiemamy.xml.CoreQName; + +/** + * {@link Resolvable}な状態の {@link RootModel}を表すXMLコマンド。 + * + * @author daisuke + */ +public class RootModelCommand implements Resolvable<JiemamyXmlCommand> { + + private final RootModel rootModel; + + + /** + * インスタンスを生成する。 + * + * @param rootModel + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public RootModelCommand(RootModel rootModel) { + Validate.notNull(rootModel); + this.rootModel = rootModel; + } + + public EssentialQueue<JiemamyXmlCommand> resolve() { + Map<QName, String> attributes = new HashMap<QName, String>(); + attributes.put(CoreQName.ID.getQName(), rootModel.getId().toString()); + + ResolvableQueue<JiemamyXmlCommand> queue = new ResolvableQueue<JiemamyXmlCommand>(); + queue.enqueue(new StartElementCommandImpl(CoreQName.JIEMAMY, attributes)); + queue.enqueue(new DialectCommand(rootModel.getDialectClassName())); + queue.enqueue(new EndElementCommandImpl(CoreQName.JIEMAMY)); + return queue; + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/command/RootModelCommand.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,134 +1,134 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.serializer.stax; - -import java.util.Collection; -import java.util.NoSuchElementException; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.command.CloseCommandImpl; -import org.jiemamy.command.EndElementCommandImpl; -import org.jiemamy.command.JiemamyXmlCommand; -import org.jiemamy.command.JiemamyCommandInputStream; -import org.jiemamy.command.OpenCommandImpl; -import org.jiemamy.command.StartElementCommandImpl; -import org.jiemamy.internal.command.DialectCommand; -import org.jiemamy.internal.command.RootModelCommand; -import org.jiemamy.model.RootModel; -import org.jiemamy.utils.ResolvableQueue; - -/** - * {@link RootModel}の内容を{@link JiemamyXmlCommand}として読み出す、Reader実装。 - * - * <p> - * </p> - * <ul> - * <li>{@link OpenCommandImpl}</li> - * <ul><li>{@link StartElementCommandImpl} of {@link RootModel}</li> - * <ul><li>{@link StartElementCommandImpl} of {@link String} (dialect)</li> - * <ul><li>{@link DialectCommand}</li></ul> - * <li>{@link EndElementCommandImpl} of {@link String} (dialect)</li> - * <li>...</li> - * <li>{@link StartElementCommandImpl} of {@link Collection} (domains)</li> - * <ul><li>...</li></ul> - * <li>{@link EndElementCommandImpl} of {@link Collection} (domains)</li> - * <li>{@link StartElementCommandImpl} of {@link Collection} (nodes)</li> - * <ul><li>...</li></ul> - * <li>{@link EndElementCommandImpl} of {@link Collection} (nodes)</li> - * <li>{@link StartElementCommandImpl} of {@link Collection} (connections)</li> - * <ul><li>...</li></ul> - * <li>{@link EndElementCommandImpl} of {@link Collection} (connections)</li> - * <li>{@link StartElementCommandImpl} of {@link Collection} (insertDataSetModels)</li> - * <ul><li>...</li></ul> - * <li>{@link EndElementCommandImpl} of {@link Collection} (insertDataSetModels)</li> - * <li>{@link StartElementCommandImpl} of {@link Collection} (view:diagramPresentations)</li> - * <ul><li>...</li></ul> - * <li>{@link EndElementCommandImpl} of {@link Collection} (view:diagramPresentations)</li> - * <li>...</li></ul> - * <li>{@link EndElementCommandImpl} of {@link RootModel}</li></ul> - * <li>{@link CloseCommandImpl}</li> - * </ul> - * - * @author daisuke - */ -public class JiemamyCommandInputStreamImpl implements JiemamyCommandInputStream { - - private RootModel rootModel; - - private ResolvableQueue<JiemamyXmlCommand> queue = new ResolvableQueue<JiemamyXmlCommand>(); - - private boolean closed; - - - /** - * インスタンスを生成する。 - * - * @param rootModel - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public JiemamyCommandInputStreamImpl(RootModel rootModel) { - Validate.notNull(rootModel); - this.rootModel = rootModel; - reset(); - } - - public void close() { - checkClosed(); - closed = true; - } - - public boolean hasNext() { - checkClosed(); - return queue.isEmpty() == false; - } - - public JiemamyXmlCommand nextCommand() { - checkClosed(); - checkNext(); - - return queue.dequeue(); - } - - /** - * ストリームをリセットして、最初から読み出せるようにする。 - * - * @throws UnsupportedOperationException - * @throws IllegalStateException Writerが既にcloseされていた場合 - */ - public void reset() { - checkClosed(); - queue.clear(); - queue.enqueue(new OpenCommandImpl()); - queue.enqueue(new RootModelCommand(rootModel)); - queue.enqueue(new CloseCommandImpl()); - } - - private void checkClosed() { - if (closed) { - throw new IllegalStateException("JiemamyCommandInputStream is already closed."); - } - } - - private void checkNext() { - if (hasNext() == false) { - throw new NoSuchElementException(); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.serializer.stax; + +import java.util.Collection; +import java.util.NoSuchElementException; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.command.CloseCommandImpl; +import org.jiemamy.command.EndElementCommandImpl; +import org.jiemamy.command.JiemamyXmlCommand; +import org.jiemamy.command.JiemamyCommandInputStream; +import org.jiemamy.command.OpenCommandImpl; +import org.jiemamy.command.StartElementCommandImpl; +import org.jiemamy.internal.command.DialectCommand; +import org.jiemamy.internal.command.RootModelCommand; +import org.jiemamy.model.RootModel; +import org.jiemamy.utils.ResolvableQueue; + +/** + * {@link RootModel}の内容を{@link JiemamyXmlCommand}として読み出す、Reader実装。 + * + * <p> + * </p> + * <ul> + * <li>{@link OpenCommandImpl}</li> + * <ul><li>{@link StartElementCommandImpl} of {@link RootModel}</li> + * <ul><li>{@link StartElementCommandImpl} of {@link String} (dialect)</li> + * <ul><li>{@link DialectCommand}</li></ul> + * <li>{@link EndElementCommandImpl} of {@link String} (dialect)</li> + * <li>...</li> + * <li>{@link StartElementCommandImpl} of {@link Collection} (domains)</li> + * <ul><li>...</li></ul> + * <li>{@link EndElementCommandImpl} of {@link Collection} (domains)</li> + * <li>{@link StartElementCommandImpl} of {@link Collection} (nodes)</li> + * <ul><li>...</li></ul> + * <li>{@link EndElementCommandImpl} of {@link Collection} (nodes)</li> + * <li>{@link StartElementCommandImpl} of {@link Collection} (connections)</li> + * <ul><li>...</li></ul> + * <li>{@link EndElementCommandImpl} of {@link Collection} (connections)</li> + * <li>{@link StartElementCommandImpl} of {@link Collection} (insertDataSetModels)</li> + * <ul><li>...</li></ul> + * <li>{@link EndElementCommandImpl} of {@link Collection} (insertDataSetModels)</li> + * <li>{@link StartElementCommandImpl} of {@link Collection} (view:diagramPresentations)</li> + * <ul><li>...</li></ul> + * <li>{@link EndElementCommandImpl} of {@link Collection} (view:diagramPresentations)</li> + * <li>...</li></ul> + * <li>{@link EndElementCommandImpl} of {@link RootModel}</li></ul> + * <li>{@link CloseCommandImpl}</li> + * </ul> + * + * @author daisuke + */ +public class JiemamyCommandInputStreamImpl implements JiemamyCommandInputStream { + + private RootModel rootModel; + + private ResolvableQueue<JiemamyXmlCommand> queue = new ResolvableQueue<JiemamyXmlCommand>(); + + private boolean closed; + + + /** + * インスタンスを生成する。 + * + * @param rootModel + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public JiemamyCommandInputStreamImpl(RootModel rootModel) { + Validate.notNull(rootModel); + this.rootModel = rootModel; + reset(); + } + + public void close() { + checkClosed(); + closed = true; + } + + public boolean hasNext() { + checkClosed(); + return queue.isEmpty() == false; + } + + public JiemamyXmlCommand nextCommand() { + checkClosed(); + checkNext(); + + return queue.dequeue(); + } + + /** + * ストリームをリセットして、最初から読み出せるようにする。 + * + * @throws UnsupportedOperationException + * @throws IllegalStateException Writerが既にcloseされていた場合 + */ + public void reset() { + checkClosed(); + queue.clear(); + queue.enqueue(new OpenCommandImpl()); + queue.enqueue(new RootModelCommand(rootModel)); + queue.enqueue(new CloseCommandImpl()); + } + + private void checkClosed() { + if (closed) { + throw new IllegalStateException("JiemamyCommandInputStream is already closed."); + } + } + + private void checkNext() { + if (hasNext() == false) { + throw new NoSuchElementException(); + } + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamImpl.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamImpl.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamImpl.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,80 +1,80 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.serializer.stax; - -import org.jiemamy.Jiemamy; -import org.jiemamy.command.JiemamyXmlCommand; -import org.jiemamy.command.JiemamyXmlCommandException; -import org.jiemamy.command.JiemamyCommandOutputStream; -import org.jiemamy.command.ObjectCommandDestination; -import org.jiemamy.model.RootModel; - -/** - * {@link JiemamyXmlCommand}の内容を{@link RootModel}に書き出す為の、Command stream実装クラス。 - * - * @author daisuke - */ -public class JiemamyCommandOutputStreamImpl implements JiemamyCommandOutputStream { - - private ObjectCommandDestination dest; - - private boolean closed; - - - /** - * インスタンスを生成する。 - * - * @param jiemamy - */ - public JiemamyCommandOutputStreamImpl(Jiemamy jiemamy) { - dest = new ObjectCommandDestination(jiemamy); - } - - public void close() { - checkClosed(); - closed = true; - } - - /** - * 書き出し結果の{@link RootModel}を取得する。 - * - * <p>OpenEventさえも書き込まれていない場合は、{@code null}を返す。</p> - * - * @return 書き出し結果 - * @throws IllegalStateException Writerがまだcloseされていない場合 - */ - public RootModel getRootModel() { - if (closed == false) { - throw new IllegalStateException("JiemamyCommandOutputStream is not closed yet."); - } - return dest.getRootModel(); - } - - public void write(JiemamyXmlCommand command) throws JiemamyXmlCommandException { - checkClosed(); - dest.apply(command); - } - - private void checkClosed() { - if (closed) { - throw new IllegalStateException("JiemamyCommandOutputStream is already closed."); - } - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.serializer.stax; + +import org.jiemamy.Jiemamy; +import org.jiemamy.command.JiemamyXmlCommand; +import org.jiemamy.command.JiemamyXmlCommandException; +import org.jiemamy.command.JiemamyCommandOutputStream; +import org.jiemamy.command.ObjectCommandDestination; +import org.jiemamy.model.RootModel; + +/** + * {@link JiemamyXmlCommand}の内容を{@link RootModel}に書き出す為の、Command stream実装クラス。 + * + * @author daisuke + */ +public class JiemamyCommandOutputStreamImpl implements JiemamyCommandOutputStream { + + private ObjectCommandDestination dest; + + private boolean closed; + + + /** + * インスタンスを生成する。 + * + * @param jiemamy + */ + public JiemamyCommandOutputStreamImpl(Jiemamy jiemamy) { + dest = new ObjectCommandDestination(jiemamy); + } + + public void close() { + checkClosed(); + closed = true; + } + + /** + * 書き出し結果の{@link RootModel}を取得する。 + * + * <p>OpenEventさえも書き込まれていない場合は、{@code null}を返す。</p> + * + * @return 書き出し結果 + * @throws IllegalStateException Writerがまだcloseされていない場合 + */ + public RootModel getRootModel() { + if (closed == false) { + throw new IllegalStateException("JiemamyCommandOutputStream is not closed yet."); + } + return dest.getRootModel(); + } + + public void write(JiemamyXmlCommand command) throws JiemamyXmlCommandException { + checkClosed(); + dest.apply(command); + } + + private void checkClosed() { + if (closed) { + throw new IllegalStateException("JiemamyCommandOutputStream is already closed."); + } + } + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamImpl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,75 +1,75 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.serializer.stax; - -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.XMLEvent; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.command.CommandSource; -import org.jiemamy.command.JiemamyXmlCommand; -import org.jiemamy.command.JiemamyXmlCommandException; -import org.jiemamy.command.JiemamyCommandInputStream; -import org.jiemamy.command.StaxCommandSource; - -/** - * {@link XMLEventReader}を{@link JiemamyCommandInputStream}として扱うアダプタ。 - * - * @author daisuke - */ -public class XmlEventReaderAdapter implements JiemamyCommandInputStream { - - private XMLEventReader xmlEventReader; - - - /** - * インスタンスを生成する。 - * - * @param xmlEventReader readerの実体としての{@link XMLEventReader} - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public XmlEventReaderAdapter(XMLEventReader xmlEventReader) { - Validate.notNull(xmlEventReader); - this.xmlEventReader = xmlEventReader; - } - - public void close() throws JiemamyXmlCommandException { - try { - xmlEventReader.close(); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } - - public boolean hasNext() { - return xmlEventReader.hasNext(); - } - - public JiemamyXmlCommand nextCommand() throws JiemamyXmlCommandException { - try { - XMLEvent xmlEvent = xmlEventReader.nextEvent(); - CommandSource source = new StaxCommandSource(xmlEvent); - return source.getCommand(); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.serializer.stax; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.XMLEvent; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.command.CommandSource; +import org.jiemamy.command.JiemamyXmlCommand; +import org.jiemamy.command.JiemamyXmlCommandException; +import org.jiemamy.command.JiemamyCommandInputStream; +import org.jiemamy.command.StaxCommandSource; + +/** + * {@link XMLEventReader}を{@link JiemamyCommandInputStream}として扱うアダプタ。 + * + * @author daisuke + */ +public class XmlEventReaderAdapter implements JiemamyCommandInputStream { + + private XMLEventReader xmlEventReader; + + + /** + * インスタンスを生成する。 + * + * @param xmlEventReader readerの実体としての{@link XMLEventReader} + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public XmlEventReaderAdapter(XMLEventReader xmlEventReader) { + Validate.notNull(xmlEventReader); + this.xmlEventReader = xmlEventReader; + } + + public void close() throws JiemamyXmlCommandException { + try { + xmlEventReader.close(); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } + + public boolean hasNext() { + return xmlEventReader.hasNext(); + } + + public JiemamyXmlCommand nextCommand() throws JiemamyXmlCommandException { + try { + XMLEvent xmlEvent = xmlEventReader.nextEvent(); + CommandSource source = new StaxCommandSource(xmlEvent); + return source.getCommand(); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventReaderAdapter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventWriterAdapter.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventWriterAdapter.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventWriterAdapter.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,64 +1,64 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.serializer.stax; - -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; - -import org.apache.commons.lang.Validate; - -import org.jiemamy.command.JiemamyXmlCommand; -import org.jiemamy.command.JiemamyXmlCommandException; -import org.jiemamy.command.JiemamyCommandOutputStream; -import org.jiemamy.command.StaxCommandDestination; - -/** - * {@link XMLStreamWriter}を{@link JiemamyCommandOutputStream}として扱うアダプタ。 - * @author daisuke - */ -public class XmlEventWriterAdapter implements JiemamyCommandOutputStream { - - private StaxCommandDestination dest; - - - /** - * インスタンスを生成する。 - * @param eventWriter - * @throws IllegalArgumentException 引数に{@code null}を与えた場合 - */ - public XmlEventWriterAdapter(XMLEventWriter eventWriter) { - Validate.notNull(eventWriter); - dest = new StaxCommandDestination(eventWriter); - } - - public void close() throws JiemamyXmlCommandException { - try { - dest.getXmlWriter().close(); - } catch (XMLStreamException e) { - throw new JiemamyXmlCommandException(e); - } - } - - public void write(JiemamyXmlCommand command) throws JiemamyXmlCommandException { - Validate.notNull(command); - dest.apply(command); - } - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.serializer.stax; + +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.commons.lang.Validate; + +import org.jiemamy.command.JiemamyXmlCommand; +import org.jiemamy.command.JiemamyXmlCommandException; +import org.jiemamy.command.JiemamyCommandOutputStream; +import org.jiemamy.command.StaxCommandDestination; + +/** + * {@link XMLStreamWriter}を{@link JiemamyCommandOutputStream}として扱うアダプタ。 + * @author daisuke + */ +public class XmlEventWriterAdapter implements JiemamyCommandOutputStream { + + private StaxCommandDestination dest; + + + /** + * インスタンスを生成する。 + * @param eventWriter + * @throws IllegalArgumentException 引数に{@code null}を与えた場合 + */ + public XmlEventWriterAdapter(XMLEventWriter eventWriter) { + Validate.notNull(eventWriter); + dest = new StaxCommandDestination(eventWriter); + } + + public void close() throws JiemamyXmlCommandException { + try { + dest.getXmlWriter().close(); + } catch (XMLStreamException e) { + throw new JiemamyXmlCommandException(e); + } + } + + public void write(JiemamyXmlCommand command) throws JiemamyXmlCommandException { + Validate.notNull(command); + dest.apply(command); + } + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/internal/serializer/stax/XmlEventWriterAdapter.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,147 +1,147 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/12 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.serializer; - -import java.io.InputStream; -import java.io.OutputStream; - -import javanet.staxutils.IndentingXMLEventWriter; - -import javax.xml.stream.EventFilter; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.XMLEvent; - -import org.apache.commons.lang.CharUtils; -import org.apache.commons.lang.Validate; - -import org.jiemamy.Jiemamy; -import org.jiemamy.command.JiemamyXmlCommandException; -import org.jiemamy.command.JiemamyCommandInputStream; -import org.jiemamy.command.JiemamyCommandOutputStream; -import org.jiemamy.internal.serializer.stax.JiemamyCommandInputStreamImpl; -import org.jiemamy.internal.serializer.stax.JiemamyCommandOutputStreamImpl; -import org.jiemamy.internal.serializer.stax.XmlEventReaderAdapter; -import org.jiemamy.internal.serializer.stax.XmlEventWriterAdapter; -import org.jiemamy.model.RootModel; - -/** - * シリアライザのStAXによる実装。 - * @author daisuke - */ -public class JiemamyStaxSerializer implements JiemamySerializer { - - /** - * Copy models from a {@link JiemamyXmlCommandException} to a {@link JiemamyCommandOutputStream}. And close both. - * - * @param input resource which send models - * @param output resource which recieve models - * @throws SerializationException - */ - private static void copyAndClose(JiemamyCommandInputStream input, JiemamyCommandOutputStream output) - throws SerializationException { - try { - while (input.hasNext()) { - output.write(input.nextCommand()); - } - } catch (JiemamyXmlCommandException e) { - throw new SerializationException(e); - } finally { - if (input != null) { - try { - input.close(); - } catch (JiemamyXmlCommandException e) { - // ignore - } - } - if (output != null) { - try { - output.close(); - } catch (JiemamyXmlCommandException e) { - // ignore - } - } - } - } - - - /** インスタンス空間を表すオブジェクト */ - private Jiemamy jiemamy; - - - /** - * インスタンスを生成する。 - * @param jiemamy インスタンス空間を表すオブジェクト - */ - public JiemamyStaxSerializer(Jiemamy jiemamy) { - this.jiemamy = jiemamy; - } - - public RootModel deserialize(InputStream in) throws SerializationException { - Validate.notNull(in); - - RootModel result; - try { - XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); - xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); - XMLEventReader xmlEventReader = - xmlInputFactory.createFilteredReader(xmlInputFactory.createXMLEventReader(in), new EventFilter() { - - public boolean accept(XMLEvent event) { - if (event.isCharacters() && event.asCharacters().isWhiteSpace()) { - return false; - } - return true; - } - - }); - JiemamyCommandInputStream input = new XmlEventReaderAdapter(xmlEventReader); - JiemamyCommandOutputStream output = new JiemamyCommandOutputStreamImpl(jiemamy); - - copyAndClose(input, output); - result = ((JiemamyCommandOutputStreamImpl) output).getRootModel(); - } catch (XMLStreamException e) { - throw new SerializationException(e); - } - - return result; - } - - public void serialize(RootModel rootModel, OutputStream out) throws SerializationException { - Validate.notNull(rootModel); - Validate.notNull(out); - - try { - XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); - xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); - XMLEventWriter writer = xmlOutputFactory.createXMLEventWriter(out); - IndentingXMLEventWriter indentingWriter = new IndentingXMLEventWriter(writer); - indentingWriter.setNewLine(String.valueOf(CharUtils.LF)); - JiemamyCommandOutputStream input = new XmlEventWriterAdapter(indentingWriter); - JiemamyCommandInputStream output = new JiemamyCommandInputStreamImpl(rootModel); - - copyAndClose(output, input); - } catch (XMLStreamException e) { - throw new SerializationException(e); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/12 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.serializer; + +import java.io.InputStream; +import java.io.OutputStream; + +import javanet.staxutils.IndentingXMLEventWriter; + +import javax.xml.stream.EventFilter; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.XMLEvent; + +import org.apache.commons.lang.CharUtils; +import org.apache.commons.lang.Validate; + +import org.jiemamy.Jiemamy; +import org.jiemamy.command.JiemamyXmlCommandException; +import org.jiemamy.command.JiemamyCommandInputStream; +import org.jiemamy.command.JiemamyCommandOutputStream; +import org.jiemamy.internal.serializer.stax.JiemamyCommandInputStreamImpl; +import org.jiemamy.internal.serializer.stax.JiemamyCommandOutputStreamImpl; +import org.jiemamy.internal.serializer.stax.XmlEventReaderAdapter; +import org.jiemamy.internal.serializer.stax.XmlEventWriterAdapter; +import org.jiemamy.model.RootModel; + +/** + * シリアライザのStAXによる実装。 + * @author daisuke + */ +public class JiemamyStaxSerializer implements JiemamySerializer { + + /** + * Copy models from a {@link JiemamyXmlCommandException} to a {@link JiemamyCommandOutputStream}. And close both. + * + * @param input resource which send models + * @param output resource which recieve models + * @throws SerializationException + */ + private static void copyAndClose(JiemamyCommandInputStream input, JiemamyCommandOutputStream output) + throws SerializationException { + try { + while (input.hasNext()) { + output.write(input.nextCommand()); + } + } catch (JiemamyXmlCommandException e) { + throw new SerializationException(e); + } finally { + if (input != null) { + try { + input.close(); + } catch (JiemamyXmlCommandException e) { + // ignore + } + } + if (output != null) { + try { + output.close(); + } catch (JiemamyXmlCommandException e) { + // ignore + } + } + } + } + + + /** インスタンス空間を表すオブジェクト */ + private Jiemamy jiemamy; + + + /** + * インスタンスを生成する。 + * @param jiemamy インスタンス空間を表すオブジェクト + */ + public JiemamyStaxSerializer(Jiemamy jiemamy) { + this.jiemamy = jiemamy; + } + + public RootModel deserialize(InputStream in) throws SerializationException { + Validate.notNull(in); + + RootModel result; + try { + XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); + xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); + XMLEventReader xmlEventReader = + xmlInputFactory.createFilteredReader(xmlInputFactory.createXMLEventReader(in), new EventFilter() { + + public boolean accept(XMLEvent event) { + if (event.isCharacters() && event.asCharacters().isWhiteSpace()) { + return false; + } + return true; + } + + }); + JiemamyCommandInputStream input = new XmlEventReaderAdapter(xmlEventReader); + JiemamyCommandOutputStream output = new JiemamyCommandOutputStreamImpl(jiemamy); + + copyAndClose(input, output); + result = ((JiemamyCommandOutputStreamImpl) output).getRootModel(); + } catch (XMLStreamException e) { + throw new SerializationException(e); + } + + return result; + } + + public void serialize(RootModel rootModel, OutputStream out) throws SerializationException { + Validate.notNull(rootModel); + Validate.notNull(out); + + try { + XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); + xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); + XMLEventWriter writer = xmlOutputFactory.createXMLEventWriter(out); + IndentingXMLEventWriter indentingWriter = new IndentingXMLEventWriter(writer); + indentingWriter.setNewLine(String.valueOf(CharUtils.LF)); + JiemamyCommandOutputStream input = new XmlEventWriterAdapter(indentingWriter); + JiemamyCommandInputStream output = new JiemamyCommandInputStreamImpl(rootModel); + + copyAndClose(output, input); + } catch (XMLStreamException e) { + throw new SerializationException(e); + } + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/serializer/JiemamyStaxSerializer.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/Resolvable.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/Resolvable.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/Resolvable.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,36 +1,36 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -/** - * {@link ResolvableQueue}に与えることができる、分割可能要素であることを示すインターフェイス。 - * - * @param <T> 分割後の要素型 - * @author daisuke - */ -public interface Resolvable<T> { - - /** - * 要素を分割する。 - * - * @return 分割された要素を含むキュー - */ - EssentialQueue<T> resolve(); - -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/18 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +/** + * {@link ResolvableQueue}に与えることができる、分割可能要素であることを示すインターフェイス。 + * + * @param <T> 分割後の要素型 + * @author daisuke + */ +public interface Resolvable<T> { + + /** + * 要素を分割する。 + * + * @return 分割された要素を含むキュー + */ + EssentialQueue<T> resolve(); + +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/Resolvable.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/ResolvableQueue.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/ResolvableQueue.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/ResolvableQueue.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,177 +1,177 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.NoSuchElementException; - -/** - * 用時分割キュー。 - * - * <p>TODO 詳しい説明。</p> - * - * @param <E> キューの要素 - * @author daisuke - * @author cactusman - */ -public class ResolvableQueue<E> implements EssentialQueue<E> { - - private List<Object> stock = new LinkedList<Object>(); - - - public void clear() { - stock.clear(); - } - - public E dequeue() { - emptyCheck(); - return getHead(stock); - } - - public void enqueue(E element) { - stock.add(element); - } - - public void enqueue(EssentialQueue<E> queue) { - if (queue instanceof ResolvableQueue) { - // resolvableであった場合は、分割せずにenqueueを行うために、stockを直接読み出す。 - ResolvableQueue<E> resolvableQueue = (ResolvableQueue<E>) queue; - for (Object e : resolvableQueue.stock) { - stock.add(e); - } - } else { - for (E element : queue) { - stock.add(element); - } - } - } - - /** - * 可分割要素を追加する。 - * - * @param element 可分割要素 - */ - public void enqueue(Resolvable<E> element) { - stock.add(element); - } - - public boolean isEmpty() { - return stock.isEmpty(); - } - - public Iterator<E> iterator() { - return new ResolvableIterator(new LinkedList(stock)); - } - - public E peek() { - emptyCheck(); - E head = getHead(stock); - stock.add(0, head); - return head; - } - - public int size() { - int size = 0; - for (Object content : stock) { - if (content instanceof Resolvable) { - EssentialQueue<E> subQueue = ((Resolvable<E>) content).resolve(); - size += subQueue.size(); - } else if (content instanceof EssentialQueue) { - size += ((EssentialQueue) content).size(); - } else { - size++; - } - } - return size; - } - - @Override - public String toString() { - return stock.toString(); - } - - private void emptyCheck() { - if (stock.isEmpty()) { - throw new NoSuchElementException(); - } - } - - private E getHead(List list) { - while (true) { - E head = (E) list.remove(0); - if (head instanceof Resolvable) { - EssentialQueue<E> subQueue = ((Resolvable<E>) head).resolve(); - int index = 0; - if (subQueue instanceof ResolvableQueue) { - // resolvableであった場合は、分割せずにenqueueを行うために、stockを直接読み出す。 - ResolvableQueue<E> resolvableSubQueue = (ResolvableQueue<E>) subQueue; - for (Object element : resolvableSubQueue.stock) { - list.add(index, element); - index++; - } - } else { - for (E element : subQueue) { - list.add(index, element); - index++; - } - } - } else { - return head; - } - } - } - - - /** - * 用事分割イテレータ。 - * - * @author daisuke - */ - private final class ResolvableIterator implements Iterator<E> { - - private final List<E> list; - - - /** - * インスタンスを生成する。 - * - * @param list - */ - private ResolvableIterator(List<E> list) { - this.list = list; - } - - public boolean hasNext() { - return list.isEmpty() == false; - } - - public E next() { - if (hasNext() == false) { - throw new NoSuchElementException(); - } - return getHead(list); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/18 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.NoSuchElementException; + +/** + * 用時分割キュー。 + * + * <p>TODO 詳しい説明。</p> + * + * @param <E> キューの要素 + * @author daisuke + * @author cactusman + */ +public class ResolvableQueue<E> implements EssentialQueue<E> { + + private List<Object> stock = new LinkedList<Object>(); + + + public void clear() { + stock.clear(); + } + + public E dequeue() { + emptyCheck(); + return getHead(stock); + } + + public void enqueue(E element) { + stock.add(element); + } + + public void enqueue(EssentialQueue<E> queue) { + if (queue instanceof ResolvableQueue) { + // resolvableであった場合は、分割せずにenqueueを行うために、stockを直接読み出す。 + ResolvableQueue<E> resolvableQueue = (ResolvableQueue<E>) queue; + for (Object e : resolvableQueue.stock) { + stock.add(e); + } + } else { + for (E element : queue) { + stock.add(element); + } + } + } + + /** + * 可分割要素を追加する。 + * + * @param element 可分割要素 + */ + public void enqueue(Resolvable<E> element) { + stock.add(element); + } + + public boolean isEmpty() { + return stock.isEmpty(); + } + + public Iterator<E> iterator() { + return new ResolvableIterator(new LinkedList(stock)); + } + + public E peek() { + emptyCheck(); + E head = getHead(stock); + stock.add(0, head); + return head; + } + + public int size() { + int size = 0; + for (Object content : stock) { + if (content instanceof Resolvable) { + EssentialQueue<E> subQueue = ((Resolvable<E>) content).resolve(); + size += subQueue.size(); + } else if (content instanceof EssentialQueue) { + size += ((EssentialQueue) content).size(); + } else { + size++; + } + } + return size; + } + + @Override + public String toString() { + return stock.toString(); + } + + private void emptyCheck() { + if (stock.isEmpty()) { + throw new NoSuchElementException(); + } + } + + private E getHead(List list) { + while (true) { + E head = (E) list.remove(0); + if (head instanceof Resolvable) { + EssentialQueue<E> subQueue = ((Resolvable<E>) head).resolve(); + int index = 0; + if (subQueue instanceof ResolvableQueue) { + // resolvableであった場合は、分割せずにenqueueを行うために、stockを直接読み出す。 + ResolvableQueue<E> resolvableSubQueue = (ResolvableQueue<E>) subQueue; + for (Object element : resolvableSubQueue.stock) { + list.add(index, element); + index++; + } + } else { + for (E element : subQueue) { + list.add(index, element); + index++; + } + } + } else { + return head; + } + } + } + + + /** + * 用事分割イテレータ。 + * + * @author daisuke + */ + private final class ResolvableIterator implements Iterator<E> { + + private final List<E> list; + + + /** + * インスタンスを生成する。 + * + * @param list + */ + private ResolvableIterator(List<E> list) { + this.list = list; + } + + public boolean hasNext() { + return list.isEmpty() == false; + } + + public E next() { + if (hasNext() == false) { + throw new NoSuchElementException(); + } + return getHead(list); + } + + public void remove() { + throw new UnsupportedOperationException(); + } + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/ResolvableQueue.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/StaxUtil.java =================================================================== --- sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/StaxUtil.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/StaxUtil.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,127 +1,127 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/15 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import javax.xml.stream.XMLStreamConstants; - -/** - * StAX用のユーティリティクラス。 - * - * @author daisuke - */ -public final class StaxUtil { - - /** - * イベントタイプを表すintから、enumに変換する。 - * - * @param eventType イベントタイプを表すint - * @return イベントタイプを表すenum - */ - public static StaxEventType toEventTypeEnum(int eventType) { - StaxEventType result; - switch (eventType) { - case XMLStreamConstants.START_ELEMENT: - result = StaxEventType.START_ELEMENT; - break; - - case XMLStreamConstants.END_ELEMENT: - result = StaxEventType.END_ELEMENT; - break; - - case XMLStreamConstants.CHARACTERS: - result = StaxEventType.CHARACTERS; - break; - - case XMLStreamConstants.ATTRIBUTE: - result = StaxEventType.ATTRIBUTE; - break; - - case XMLStreamConstants.NAMESPACE: - result = StaxEventType.NAMESPACE; - break; - - case XMLStreamConstants.PROCESSING_INSTRUCTION: - result = StaxEventType.PROCESSING_INSTRUCTION; - break; - - case XMLStreamConstants.COMMENT: - result = StaxEventType.COMMENT; - break; - - case XMLStreamConstants.START_DOCUMENT: - result = StaxEventType.START_DOCUMENT; - break; - - case XMLStreamConstants.END_DOCUMENT: - result = StaxEventType.END_DOCUMENT; - break; - - case XMLStreamConstants.DTD: - result = StaxEventType.DTD; - break; - - default: - result = null; - break; - } - return result; - } - - private StaxUtil() { - } - - - /** - * StAXのイベントタイプ。 - * - * @author daisuke - */ - public static enum StaxEventType { - - /** {@link XMLStreamConstants#START_ELEMENT} */ - START_ELEMENT, - - /** {@link XMLStreamConstants#END_ELEMENT} */ - END_ELEMENT, - - /** {@link XMLStreamConstants#CHARACTERS} */ - CHARACTERS, - - /** {@link XMLStreamConstants#ATTRIBUTE} */ - ATTRIBUTE, - - /** {@link XMLStreamConstants#NAMESPACE} */ - NAMESPACE, - - /** {@link XMLStreamConstants#PROCESSING_INSTRUCTION} */ - PROCESSING_INSTRUCTION, - - /** {@link XMLStreamConstants#COMMENT} */ - COMMENT, - - /** {@link XMLStreamConstants#START_DOCUMENT} */ - START_DOCUMENT, - - /** {@link XMLStreamConstants#END_DOCUMENT} */ - END_DOCUMENT, - - /** {@link XMLStreamConstants#DTD} */ - DTD - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/15 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import javax.xml.stream.XMLStreamConstants; + +/** + * StAX用のユーティリティクラス。 + * + * @author daisuke + */ +public final class StaxUtil { + + /** + * イベントタイプを表すintから、enumに変換する。 + * + * @param eventType イベントタイプを表すint + * @return イベントタイプを表すenum + */ + public static StaxEventType toEventTypeEnum(int eventType) { + StaxEventType result; + switch (eventType) { + case XMLStreamConstants.START_ELEMENT: + result = StaxEventType.START_ELEMENT; + break; + + case XMLStreamConstants.END_ELEMENT: + result = StaxEventType.END_ELEMENT; + break; + + case XMLStreamConstants.CHARACTERS: + result = StaxEventType.CHARACTERS; + break; + + case XMLStreamConstants.ATTRIBUTE: + result = StaxEventType.ATTRIBUTE; + break; + + case XMLStreamConstants.NAMESPACE: + result = StaxEventType.NAMESPACE; + break; + + case XMLStreamConstants.PROCESSING_INSTRUCTION: + result = StaxEventType.PROCESSING_INSTRUCTION; + break; + + case XMLStreamConstants.COMMENT: + result = StaxEventType.COMMENT; + break; + + case XMLStreamConstants.START_DOCUMENT: + result = StaxEventType.START_DOCUMENT; + break; + + case XMLStreamConstants.END_DOCUMENT: + result = StaxEventType.END_DOCUMENT; + break; + + case XMLStreamConstants.DTD: + result = StaxEventType.DTD; + break; + + default: + result = null; + break; + } + return result; + } + + private StaxUtil() { + } + + + /** + * StAXのイベントタイプ。 + * + * @author daisuke + */ + public static enum StaxEventType { + + /** {@link XMLStreamConstants#START_ELEMENT} */ + START_ELEMENT, + + /** {@link XMLStreamConstants#END_ELEMENT} */ + END_ELEMENT, + + /** {@link XMLStreamConstants#CHARACTERS} */ + CHARACTERS, + + /** {@link XMLStreamConstants#ATTRIBUTE} */ + ATTRIBUTE, + + /** {@link XMLStreamConstants#NAMESPACE} */ + NAMESPACE, + + /** {@link XMLStreamConstants#PROCESSING_INSTRUCTION} */ + PROCESSING_INSTRUCTION, + + /** {@link XMLStreamConstants#COMMENT} */ + COMMENT, + + /** {@link XMLStreamConstants#START_DOCUMENT} */ + START_DOCUMENT, + + /** {@link XMLStreamConstants#END_DOCUMENT} */ + END_DOCUMENT, + + /** {@link XMLStreamConstants#DTD} */ + DTD + } +} Property changes on: sandbox/jiemamy-stax/src/main/java/org/jiemamy/utils/StaxUtil.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java =================================================================== --- sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,192 +1,192 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/29 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.serializer.stax; - -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.junit.Assert.assertThat; - -import java.io.InputStream; -import java.util.List; - -import javax.xml.stream.EventFilter; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.events.XMLEvent; - -import org.apache.commons.lang.ClassUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.Jiemamy; -import org.jiemamy.command.CloseCommand; -import org.jiemamy.command.DataCommand; -import org.jiemamy.command.EndElementCommand; -import org.jiemamy.command.JiemamyXmlCommand; -import org.jiemamy.command.JiemamyCommandInputStream; -import org.jiemamy.command.JiemamyXmlCommandException; -import org.jiemamy.command.OpenCommand; -import org.jiemamy.command.StartElementCommand; -import org.jiemamy.model.RootModel; -import org.jiemamy.utils.CollectionsUtil; - -/** - * {@link JiemamyCommandInputStreamImpl}のテストクラス。 - * - * @author daisuke - */ -public class JiemamyCommandInputStreamTest { - - private static Logger logger = LoggerFactory.getLogger(JiemamyCommandInputStreamTest.class); - - private Jiemamy jiemamy; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - jiemamy = Jiemamy.newInstance(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - jiemamy = null; - } - - /** - * Read command stream from {@link RootModel}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_fromRootModel() throws Exception { - RootModel rootModel = jiemamy.getFactory().getRootModel(); - JiemamyCommandInputStream stream = new JiemamyCommandInputStreamImpl(rootModel); - - List<Class<?>> expectedClasses = CollectionsUtil.newArrayList(); - { - expectedClasses.add(OpenCommand.class); - expectedClasses.add(StartElementCommand.class); - expectedClasses.add(StartElementCommand.class); - expectedClasses.add(DataCommand.class); - expectedClasses.add(EndElementCommand.class); - expectedClasses.add(EndElementCommand.class); - expectedClasses.add(CloseCommand.class); - } - - List<JiemamyXmlCommand> actual = asList(stream); - - int index = 0; - for (Class<?> expectedClass : expectedClasses) { - logger.info("expected" + index + " is " + expectedClass); - logger.info("actual " + index + " is " + actual.get(index).getClass()); - assertThat("error index=" + index, actual.get(index), instanceOf(expectedClass)); - index++; - } - - stream.close(); - } - - /** - * Read command stream from XML. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test02_fromXmlModel() throws Exception { - InputStream in = JiemamyCommandInputStreamTest.class.getResourceAsStream("/minimal.jiemamy-core.xml"); - - XMLInputFactory factory = XMLInputFactory.newInstance(); - factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); - XMLEventReader xmlEventReader = - factory.createFilteredReader(factory.createXMLEventReader(in), new EventFilter() { - - public boolean accept(XMLEvent event) { - if (event.isCharacters() && event.asCharacters().isWhiteSpace()) { - return false; - } - return true; - } - - }); - JiemamyCommandInputStream stream = new XmlEventReaderAdapter(xmlEventReader); - - List<Class<? extends JiemamyXmlCommand>> expectedClasses = CollectionsUtil.newArrayList(); - { - // <?xml version='1.0' encoding='UTF-8'?> - expectedClasses.add(OpenCommand.class); - - // <rootModel xmlns="http://jiemamy.org/xml/ns/core" id="ffffffff-ffff-ffff-ffff-ffffffffffff"> - expectedClasses.add(StartElementCommand.class); - - // <dialect> - expectedClasses.add(StartElementCommand.class); - - // com.example.HogeDialect - expectedClasses.add(DataCommand.class); - - // </dialect> - expectedClasses.add(EndElementCommand.class); - - // </rootModel> - expectedClasses.add(EndElementCommand.class); - expectedClasses.add(CloseCommand.class); - } - - List<JiemamyXmlCommand> actual = asList(stream); - - int index = 0; - for (Class<? extends JiemamyXmlCommand> expectedClass : expectedClasses) { - logger.info("expected" + index + " is " + expectedClass); - logger.info("actual " + index + " is " + actual.get(index).getClass()); - assertThat("error index=" + index, actual.get(index), instanceOf(expectedClass)); - index++; - } - - stream.close(); - } - - /** - * streamの内容を {@link List} として取得する。 - * - * @param stream - * @return XMLコマンドストリームのリスト - * @throws JiemamyXmlCommandException 読み出しに失敗した場合 - */ - private List<JiemamyXmlCommand> asList(JiemamyCommandInputStream stream) throws JiemamyXmlCommandException { - List<JiemamyXmlCommand> result = CollectionsUtil.newArrayList(); - while (stream.hasNext()) { - JiemamyXmlCommand command = stream.nextCommand(); - logger.info(ClassUtils.getShortClassName(command, "null")); - result.add(command); - } - return result; - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/29 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.serializer.stax; + +import static org.hamcrest.CoreMatchers.instanceOf; +import static org.junit.Assert.assertThat; + +import java.io.InputStream; +import java.util.List; + +import javax.xml.stream.EventFilter; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.events.XMLEvent; + +import org.apache.commons.lang.ClassUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.Jiemamy; +import org.jiemamy.command.CloseCommand; +import org.jiemamy.command.DataCommand; +import org.jiemamy.command.EndElementCommand; +import org.jiemamy.command.JiemamyXmlCommand; +import org.jiemamy.command.JiemamyCommandInputStream; +import org.jiemamy.command.JiemamyXmlCommandException; +import org.jiemamy.command.OpenCommand; +import org.jiemamy.command.StartElementCommand; +import org.jiemamy.model.RootModel; +import org.jiemamy.utils.CollectionsUtil; + +/** + * {@link JiemamyCommandInputStreamImpl}のテストクラス。 + * + * @author daisuke + */ +public class JiemamyCommandInputStreamTest { + + private static Logger logger = LoggerFactory.getLogger(JiemamyCommandInputStreamTest.class); + + private Jiemamy jiemamy; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + jiemamy = Jiemamy.newInstance(); + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + jiemamy = null; + } + + /** + * Read command stream from {@link RootModel}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test01_fromRootModel() throws Exception { + RootModel rootModel = jiemamy.getFactory().getRootModel(); + JiemamyCommandInputStream stream = new JiemamyCommandInputStreamImpl(rootModel); + + List<Class<?>> expectedClasses = CollectionsUtil.newArrayList(); + { + expectedClasses.add(OpenCommand.class); + expectedClasses.add(StartElementCommand.class); + expectedClasses.add(StartElementCommand.class); + expectedClasses.add(DataCommand.class); + expectedClasses.add(EndElementCommand.class); + expectedClasses.add(EndElementCommand.class); + expectedClasses.add(CloseCommand.class); + } + + List<JiemamyXmlCommand> actual = asList(stream); + + int index = 0; + for (Class<?> expectedClass : expectedClasses) { + logger.info("expected" + index + " is " + expectedClass); + logger.info("actual " + index + " is " + actual.get(index).getClass()); + assertThat("error index=" + index, actual.get(index), instanceOf(expectedClass)); + index++; + } + + stream.close(); + } + + /** + * Read command stream from XML. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test02_fromXmlModel() throws Exception { + InputStream in = JiemamyCommandInputStreamTest.class.getResourceAsStream("/minimal.jiemamy-core.xml"); + + XMLInputFactory factory = XMLInputFactory.newInstance(); + factory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); + XMLEventReader xmlEventReader = + factory.createFilteredReader(factory.createXMLEventReader(in), new EventFilter() { + + public boolean accept(XMLEvent event) { + if (event.isCharacters() && event.asCharacters().isWhiteSpace()) { + return false; + } + return true; + } + + }); + JiemamyCommandInputStream stream = new XmlEventReaderAdapter(xmlEventReader); + + List<Class<? extends JiemamyXmlCommand>> expectedClasses = CollectionsUtil.newArrayList(); + { + // <?xml version='1.0' encoding='UTF-8'?> + expectedClasses.add(OpenCommand.class); + + // <rootModel xmlns="http://jiemamy.org/xml/ns/core" id="ffffffff-ffff-ffff-ffff-ffffffffffff"> + expectedClasses.add(StartElementCommand.class); + + // <dialect> + expectedClasses.add(StartElementCommand.class); + + // com.example.HogeDialect + expectedClasses.add(DataCommand.class); + + // </dialect> + expectedClasses.add(EndElementCommand.class); + + // </rootModel> + expectedClasses.add(EndElementCommand.class); + expectedClasses.add(CloseCommand.class); + } + + List<JiemamyXmlCommand> actual = asList(stream); + + int index = 0; + for (Class<? extends JiemamyXmlCommand> expectedClass : expectedClasses) { + logger.info("expected" + index + " is " + expectedClass); + logger.info("actual " + index + " is " + actual.get(index).getClass()); + assertThat("error index=" + index, actual.get(index), instanceOf(expectedClass)); + index++; + } + + stream.close(); + } + + /** + * streamの内容を {@link List} として取得する。 + * + * @param stream + * @return XMLコマンドストリームのリスト + * @throws JiemamyXmlCommandException 読み出しに失敗した場合 + */ + private List<JiemamyXmlCommand> asList(JiemamyCommandInputStream stream) throws JiemamyXmlCommandException { + List<JiemamyXmlCommand> result = CollectionsUtil.newArrayList(); + while (stream.hasNext()) { + JiemamyXmlCommand command = stream.nextCommand(); + logger.info(ClassUtils.getShortClassName(command, "null")); + result.add(command); + } + return result; + } +} Property changes on: sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandInputStreamTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java =================================================================== --- sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,149 +1,149 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/17 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.serializer.stax; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.notNullValue; -import static org.junit.Assert.assertThat; - -import java.io.ByteArrayOutputStream; -import java.util.HashMap; -import java.util.Map; - -import javanet.staxutils.IndentingXMLEventWriter; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLOutputFactory; - -import org.apache.commons.lang.CharEncoding; -import org.apache.commons.lang.CharUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.Jiemamy; -import org.jiemamy.command.CloseCommandImpl; -import org.jiemamy.command.DataCommandImpl; -import org.jiemamy.command.EndElementCommandImpl; -import org.jiemamy.command.JiemamyXmlCommandException; -import org.jiemamy.command.JiemamyCommandOutputStream; -import org.jiemamy.command.OpenCommandImpl; -import org.jiemamy.command.StartElementCommandImpl; -import org.jiemamy.model.RootModel; -import org.jiemamy.xml.CoreQName; - -/** - * {@link JiemamyCommandInputStreamImpl}のテストクラス。 - * - * @author daisuke - */ -public class JiemamyCommandOutputStreamTest { - - private static final String DIALECT_ID = "com.example.FooDialect"; - - private static Logger logger = LoggerFactory.getLogger(JiemamyCommandOutputStreamTest.class); - - private Jiemamy jiemamy; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - jiemamy = Jiemamy.newInstance(); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - jiemamy = null; - } - - /** - * Write command stream to {@link RootModel}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_toRootModel() throws Exception { - JiemamyCommandOutputStream stream = new JiemamyCommandOutputStreamImpl(jiemamy); - - writeTestDataTo(stream); - - stream.close(); - - RootModel rootModel = ((JiemamyCommandOutputStreamImpl) stream).getRootModel(); - assertThat(rootModel, is(notNullValue())); - logger.info(rootModel.toString()); - assertThat(rootModel.getDialectClassName(), is(DIALECT_ID)); - } - - /** - * Write command stream to XML. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test02_toXmlModel() throws Exception { - ByteArrayOutputStream out = new ByteArrayOutputStream(); - - XMLOutputFactory factory = XMLOutputFactory.newInstance(); - factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); - XMLEventWriter writer = factory.createXMLEventWriter(out); - IndentingXMLEventWriter indentingWriter = new IndentingXMLEventWriter(writer); - indentingWriter.setNewLine(String.valueOf(CharUtils.LF)); - JiemamyCommandOutputStream stream = new XmlEventWriterAdapter(indentingWriter); - - writeTestDataTo(stream); - - stream.close(); - String result = out.toString(CharEncoding.UTF_8); - - logger.info(result); - } - - /** - * テスト用 command stream を書き込む。 - * - * @param stream 書き込み先 - * @throws JiemamyXmlCommandException 書き込みに失敗した場合 - */ - private void writeTestDataTo(JiemamyCommandOutputStream stream) throws JiemamyXmlCommandException { - Map<QName, String> attributes = new HashMap<QName, String>(); - attributes.put(new QName("id"), "ffffffff-ffff-ffff-ffff-ffffffffffff"); - - stream.write(new OpenCommandImpl()); - stream.write(new StartElementCommandImpl(CoreQName.JIEMAMY, attributes)); - stream.write(new StartElementCommandImpl(CoreQName.DIALECT)); - stream.write(new DataCommandImpl(DIALECT_ID)); - stream.write(new EndElementCommandImpl(CoreQName.DIALECT)); - stream.write(new EndElementCommandImpl(CoreQName.JIEMAMY)); - stream.write(new CloseCommandImpl()); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/17 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.serializer.stax; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.notNullValue; +import static org.junit.Assert.assertThat; + +import java.io.ByteArrayOutputStream; +import java.util.HashMap; +import java.util.Map; + +import javanet.staxutils.IndentingXMLEventWriter; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLOutputFactory; + +import org.apache.commons.lang.CharEncoding; +import org.apache.commons.lang.CharUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.Jiemamy; +import org.jiemamy.command.CloseCommandImpl; +import org.jiemamy.command.DataCommandImpl; +import org.jiemamy.command.EndElementCommandImpl; +import org.jiemamy.command.JiemamyXmlCommandException; +import org.jiemamy.command.JiemamyCommandOutputStream; +import org.jiemamy.command.OpenCommandImpl; +import org.jiemamy.command.StartElementCommandImpl; +import org.jiemamy.model.RootModel; +import org.jiemamy.xml.CoreQName; + +/** + * {@link JiemamyCommandInputStreamImpl}のテストクラス。 + * + * @author daisuke + */ +public class JiemamyCommandOutputStreamTest { + + private static final String DIALECT_ID = "com.example.FooDialect"; + + private static Logger logger = LoggerFactory.getLogger(JiemamyCommandOutputStreamTest.class); + + private Jiemamy jiemamy; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + jiemamy = Jiemamy.newInstance(); + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + jiemamy = null; + } + + /** + * Write command stream to {@link RootModel}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test01_toRootModel() throws Exception { + JiemamyCommandOutputStream stream = new JiemamyCommandOutputStreamImpl(jiemamy); + + writeTestDataTo(stream); + + stream.close(); + + RootModel rootModel = ((JiemamyCommandOutputStreamImpl) stream).getRootModel(); + assertThat(rootModel, is(notNullValue())); + logger.info(rootModel.toString()); + assertThat(rootModel.getDialectClassName(), is(DIALECT_ID)); + } + + /** + * Write command stream to XML. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test02_toXmlModel() throws Exception { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + XMLOutputFactory factory = XMLOutputFactory.newInstance(); + factory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); + XMLEventWriter writer = factory.createXMLEventWriter(out); + IndentingXMLEventWriter indentingWriter = new IndentingXMLEventWriter(writer); + indentingWriter.setNewLine(String.valueOf(CharUtils.LF)); + JiemamyCommandOutputStream stream = new XmlEventWriterAdapter(indentingWriter); + + writeTestDataTo(stream); + + stream.close(); + String result = out.toString(CharEncoding.UTF_8); + + logger.info(result); + } + + /** + * テスト用 command stream を書き込む。 + * + * @param stream 書き込み先 + * @throws JiemamyXmlCommandException 書き込みに失敗した場合 + */ + private void writeTestDataTo(JiemamyCommandOutputStream stream) throws JiemamyXmlCommandException { + Map<QName, String> attributes = new HashMap<QName, String>(); + attributes.put(new QName("id"), "ffffffff-ffff-ffff-ffff-ffffffffffff"); + + stream.write(new OpenCommandImpl()); + stream.write(new StartElementCommandImpl(CoreQName.JIEMAMY, attributes)); + stream.write(new StartElementCommandImpl(CoreQName.DIALECT)); + stream.write(new DataCommandImpl(DIALECT_ID)); + stream.write(new EndElementCommandImpl(CoreQName.DIALECT)); + stream.write(new EndElementCommandImpl(CoreQName.JIEMAMY)); + stream.write(new CloseCommandImpl()); + } +} Property changes on: sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/JiemamyCommandOutputStreamTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java =================================================================== --- sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,116 +1,116 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/16 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.internal.serializer.stax; - -import java.io.InputStream; -import java.io.StringWriter; - -import javanet.staxutils.IndentingXMLEventWriter; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLEventFactory; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLEventWriter; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -import com.bea.xml.stream.EventFactory; - -import org.codehaus.stax2.XMLInputFactory2; -import org.codehaus.stax2.XMLOutputFactory2; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.jiemamy.utils.StaxUtil; - -/** - * StAXの動作確認用テストクラス。assertionは特に行っていない。 - * - * @author daisuke - */ -public class StaxTest { - - private static Logger logger = LoggerFactory.getLogger(StaxTest.class); - - - /** - * Write by StAX. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_writeByStAX() throws Exception { - StringWriter stringWriter = new StringWriter(); - XMLOutputFactory outFactory = XMLOutputFactory2.newInstance(); - XMLEventWriter writer = outFactory.createXMLEventWriter(stringWriter); - IndentingXMLEventWriter indentingWriter = new IndentingXMLEventWriter(writer); - indentingWriter.setNewLine("\n"); - writer = indentingWriter; - - XMLEventFactory eventFactory = EventFactory.newInstance(); - - writer.add(eventFactory.createStartDocument()); - writer.add(eventFactory.createStartElement("", "", "foo")); - writer.add(eventFactory.createStartElement("", "", "bar")); - writer.add(eventFactory.createAttribute("prefix", "uri", "localName", "piyo")); - writer.add(eventFactory.createCharacters("value")); - writer.add(eventFactory.createEndElement("", "", "bar")); - writer.add(eventFactory.createStartElement("", "", "bar")); - writer.add(eventFactory.createEndElement("", "", "bar")); - writer.add(eventFactory.createEndElement("", "", "foo")); - writer.add(eventFactory.createEndDocument()); - writer.close(); - - logger.info(stringWriter.toString()); - } - - /** - * Read by StAX. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test02_readByStAX() throws Exception { - InputStream in = StaxTest.class.getResourceAsStream("/minimal.xml"); - XMLInputFactory inFactory = XMLInputFactory2.newInstance(); - inFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); - XMLEventReader reader = inFactory.createXMLEventReader(in); - - while (reader.hasNext()) { - XMLEvent event = reader.nextEvent(); - if (event.isStartElement()) { - StartElement startElement = event.asStartElement(); - logger.info(StaxUtil.toEventTypeEnum(event.getEventType()) + ": " + startElement.getName().toString()); - Attribute id = startElement.getAttributeByName(new QName("id")); - if (id != null) { - logger.info("id=" + id.getValue()); - } - } else if (event.isEndElement()) { - EndElement endElement = event.asEndElement(); - logger.info(StaxUtil.toEventTypeEnum(event.getEventType()) + ": " + endElement.getName().toString()); - } - } - reader.close(); - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/16 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.internal.serializer.stax; + +import java.io.InputStream; +import java.io.StringWriter; + +import javanet.staxutils.IndentingXMLEventWriter; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLEventFactory; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLEventWriter; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.events.Attribute; +import javax.xml.stream.events.EndElement; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +import com.bea.xml.stream.EventFactory; + +import org.codehaus.stax2.XMLInputFactory2; +import org.codehaus.stax2.XMLOutputFactory2; +import org.junit.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.jiemamy.utils.StaxUtil; + +/** + * StAXの動作確認用テストクラス。assertionは特に行っていない。 + * + * @author daisuke + */ +public class StaxTest { + + private static Logger logger = LoggerFactory.getLogger(StaxTest.class); + + + /** + * Write by StAX. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test01_writeByStAX() throws Exception { + StringWriter stringWriter = new StringWriter(); + XMLOutputFactory outFactory = XMLOutputFactory2.newInstance(); + XMLEventWriter writer = outFactory.createXMLEventWriter(stringWriter); + IndentingXMLEventWriter indentingWriter = new IndentingXMLEventWriter(writer); + indentingWriter.setNewLine("\n"); + writer = indentingWriter; + + XMLEventFactory eventFactory = EventFactory.newInstance(); + + writer.add(eventFactory.createStartDocument()); + writer.add(eventFactory.createStartElement("", "", "foo")); + writer.add(eventFactory.createStartElement("", "", "bar")); + writer.add(eventFactory.createAttribute("prefix", "uri", "localName", "piyo")); + writer.add(eventFactory.createCharacters("value")); + writer.add(eventFactory.createEndElement("", "", "bar")); + writer.add(eventFactory.createStartElement("", "", "bar")); + writer.add(eventFactory.createEndElement("", "", "bar")); + writer.add(eventFactory.createEndElement("", "", "foo")); + writer.add(eventFactory.createEndDocument()); + writer.close(); + + logger.info(stringWriter.toString()); + } + + /** + * Read by StAX. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test02_readByStAX() throws Exception { + InputStream in = StaxTest.class.getResourceAsStream("/minimal.xml"); + XMLInputFactory inFactory = XMLInputFactory2.newInstance(); + inFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true); + XMLEventReader reader = inFactory.createXMLEventReader(in); + + while (reader.hasNext()) { + XMLEvent event = reader.nextEvent(); + if (event.isStartElement()) { + StartElement startElement = event.asStartElement(); + logger.info(StaxUtil.toEventTypeEnum(event.getEventType()) + ": " + startElement.getName().toString()); + Attribute id = startElement.getAttributeByName(new QName("id")); + if (id != null) { + logger.info("id=" + id.getValue()); + } + } else if (event.isEndElement()) { + EndElement endElement = event.asEndElement(); + logger.info(StaxUtil.toEventTypeEnum(event.getEventType()) + ": " + endElement.getName().toString()); + } + } + reader.close(); + } +} Property changes on: sandbox/jiemamy-stax/src/test/java/org/jiemamy/internal/serializer/stax/StaxTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java =================================================================== --- sandbox/jiemamy-stax/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,403 +1,403 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/18 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import java.util.Iterator; -import java.util.NoSuchElementException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link ResolvableQueue}のテストクラス。 - * - * @author daisuke - */ -public class ResolvableQueueTest { - - private static int resolveCount; - - - private static void assertThatResolveCountIs(int count) { - assertThat(resolveCount, is(count)); - } - - - private ResolvableQueue<Element> queue; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - queue = new ResolvableQueue<Element>(); - resolveCount = 0; - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - queue = null; - } - - /** - * キューとして普通に機能する。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test01_キューとして普通に機能する() throws Exception { - queue.enqueue(new Element('a')); - queue.enqueue(new Element('b')); - queue.enqueue(new Element('c')); - - assertThatResolveCountIs(0); - - assertThat(queue.dequeue().ch, is('a')); - assertThat(queue.dequeue().ch, is('b')); - assertThat(queue.dequeue().ch, is('c')); - - assertThatResolveCountIs(0); - } - - /** - * 可分割キューとして機能する。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test02_可分割キューとして機能する() throws Exception { - queue.enqueue(new Element('a')); - queue.enqueue(new ResolvableElement("xyz")); - queue.enqueue(new Element('c')); - - assertThatResolveCountIs(0); - - assertThat(queue.dequeue().ch, is('a')); - assertThatResolveCountIs(0); - assertThat(queue.dequeue().ch, is('x')); // resolve - assertThatResolveCountIs(1); - assertThat(queue.dequeue().ch, is('y')); - assertThat(queue.dequeue().ch, is('z')); - assertThat(queue.dequeue().ch, is('c')); - assertThatResolveCountIs(1); - } - - /** - * 多段可分割キューとして機能する。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test03_多段可分割キューとして機能する() throws Exception { - queue.enqueue(new Element('a')); - queue.enqueue(new MultiResolvableElement("opq", "xyz")); - queue.enqueue(new Element('c')); - - assertThatResolveCountIs(0); - - assertThat(queue.dequeue().ch, is('a')); - assertThatResolveCountIs(0); - - assertThat(queue.dequeue().ch, is('o')); // resolve×2回(Multiとopq) - assertThatResolveCountIs(2); - assertThat(queue.dequeue().ch, is('p')); - assertThat(queue.dequeue().ch, is('q')); - assertThatResolveCountIs(2); - - assertThat(queue.dequeue().ch, is('x')); // resolve - assertThatResolveCountIs(3); - assertThat(queue.dequeue().ch, is('y')); - assertThat(queue.dequeue().ch, is('z')); - - assertThat(queue.dequeue().ch, is('c')); - assertThatResolveCountIs(3); - } - - /** - * キューをまとめてキューに追加できる。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test04_キューをまとめてキューに追加できる() throws Exception { - queue.enqueue(new Element('a')); - queue.enqueue(new MultiResolvableElement("opq", "xyz")); - queue.enqueue(new Element('c')); - - ResolvableQueue<Element> queue2 = new ResolvableQueue<Element>(); - queue.enqueue(new ResolvableElement("XYZ")); - queue2.enqueue(new Element('C')); - - queue.enqueue(queue2); - - assertThatResolveCountIs(0); - - assertThat(queue.dequeue().ch, is('a')); - assertThatResolveCountIs(0); - - assertThat(queue.dequeue().ch, is('o')); // resolve×2回(Multiとopq) - assertThatResolveCountIs(2); - assertThat(queue.dequeue().ch, is('p')); - assertThat(queue.dequeue().ch, is('q')); - assertThatResolveCountIs(2); - - assertThat(queue.dequeue().ch, is('x')); // resolve - assertThatResolveCountIs(3); - assertThat(queue.dequeue().ch, is('y')); - assertThat(queue.dequeue().ch, is('z')); - - assertThat(queue.dequeue().ch, is('c')); - assertThatResolveCountIs(3); - - // 以下、queue2としてまとめてenqueueしたもの - - assertThat(queue.dequeue().ch, is('X')); // resolve - assertThatResolveCountIs(4); - assertThat(queue.dequeue().ch, is('Y')); - assertThat(queue.dequeue().ch, is('Z')); - - assertThat(queue.dequeue().ch, is('C')); - assertThatResolveCountIs(4); - } - - /** - * キューから取り出せるサイズとisEmptyの整合性。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test05_キューから取り出せるサイズとisEmptyの整合性() throws Exception { - // これは・・・実装難しいかな? - // resolveしないままサイズをはかれないから…。 - // Resolvableに size() メソッドを定義しても良い。 - // とにかくdequeueまではresolveしないことが重要。 - - assertThatResolveCountIs(0); - - assertThat(queue.isEmpty(), is(true)); - assertThat(queue.size(), is(0)); - - queue.enqueue(new Element('a')); - - assertThat(queue.isEmpty(), is(false)); - assertThat(queue.size(), is(1)); - - queue.enqueue(new MultiResolvableElement("opq", "xyz")); - - assertThat(queue.isEmpty(), is(false)); - assertThat(queue.size(), is(7)); - - queue.enqueue(new Element('c')); - - assertThat(queue.isEmpty(), is(false)); - assertThat(queue.size(), is(8)); - - queue.clear(); - - assertThat(queue.isEmpty(), is(true)); - assertThat(queue.size(), is(0)); - -// assertThatResolveCountIs(0); - } - - /** - * peekではキューからの削除が行われない。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test06_peekではキューからの削除が行われない() throws Exception { - queue.enqueue(new Element('a')); - queue.enqueue(new MultiResolvableElement("opq", "xyz")); - queue.enqueue(new Element('c')); - - assertThatResolveCountIs(0); - - assertThat(queue.peek().ch, is('a')); - assertThat(queue.peek().ch, is('a')); - queue.dequeue(); - assertThatResolveCountIs(0); - assertThat(queue.peek().ch, is('o')); // resolve×2回(Multiとopq) - assertThatResolveCountIs(2); - assertThat(queue.peek().ch, is('o')); - queue.dequeue(); - assertThat(queue.peek().ch, is('p')); - assertThat(queue.peek().ch, is('p')); - queue.dequeue(); - assertThat(queue.peek().ch, is('q')); - assertThat(queue.peek().ch, is('q')); - queue.dequeue(); - assertThatResolveCountIs(2); - assertThat(queue.peek().ch, is('x')); // resolve - assertThatResolveCountIs(3); - assertThat(queue.peek().ch, is('x')); - queue.dequeue(); - assertThat(queue.peek().ch, is('y')); - assertThat(queue.peek().ch, is('y')); - queue.dequeue(); - assertThat(queue.peek().ch, is('z')); - assertThat(queue.peek().ch, is('z')); - queue.dequeue(); - assertThat(queue.peek().ch, is('c')); - assertThat(queue.peek().ch, is('c')); - assertThatResolveCountIs(3); - } - - /** - * Iteratorテスト。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test07_Iteratorテスト() throws Exception { - queue.enqueue(new Element('a')); - queue.enqueue(new MultiResolvableElement("opq", "xyz")); - queue.enqueue(new Element('c')); - String ref = "aopqxyzc"; - - assertThatResolveCountIs(0); - - int index = 0; - int simulatedResolveCount = 0; - Iterator<Element> iterator = queue.iterator(); - assertThatResolveCountIs(0); - while (iterator.hasNext()) { - assertThat(iterator.next().ch, is(ref.charAt(index))); - - if (ref.charAt(index) == 'o') { - simulatedResolveCount += 2; - } else if (ref.charAt(index) == 'x') { - simulatedResolveCount++; - } - assertThatResolveCountIs(simulatedResolveCount); - index++; - } - // 8回回ったハズ - assertThat(index, is(8)); - - // Iteratorの為にresolveが行われている - assertThatResolveCountIs(3); - - // イテレータを回しても、キューは崩されていないこと - assertThat(queue.peek().ch, is('a')); - queue.dequeue(); // a - assertThatResolveCountIs(3); - queue.dequeue(); // o resolve×2回(Multiとopq) - assertThatResolveCountIs(5); - queue.dequeue(); // p - queue.dequeue(); // q - assertThatResolveCountIs(5); - queue.dequeue(); // x resolve - assertThatResolveCountIs(6); - queue.dequeue(); // y - queue.dequeue(); // z - queue.dequeue(); // c - - // dequeueのために更にresolveが行われる - assertThatResolveCountIs(6); - } - - /** - * 要素がない時に取得を行うとNoSuchElementException。 - * - * @throws Exception 例外が発生した場合 - */ - @Test(expected = NoSuchElementException.class) - public void test07_要素がない時に取得を行うとNoSuchElementException() throws Exception { - queue.dequeue(); - queue.peek(); - } - - - /** - * テスト用要素クラス。 - * - * @author daisuke - */ - private static class Element { - - char ch; - - - Element(char c) { - ch = c; - } - } - - /** - * テスト用多段可分割要素クラス。 - * - * @author daisuke - */ - private static class MultiResolvableElement implements Resolvable<Element> { - - String[] str; - - - MultiResolvableElement(String... str) { - this.str = str; - } - - public EssentialQueue<Element> resolve() { - resolveCount++; - ResolvableQueue<Element> queue = new ResolvableQueue<Element>(); - for (String s : str) { - queue.enqueue(new ResolvableElement(s)); - } - return queue; - } - } - - /** - * テスト用可分割要素クラス。 - * - * @author daisuke - */ - private static class ResolvableElement implements Resolvable<Element> { - - String str; - - - ResolvableElement(String str) { - this.str = str; - } - - public EssentialQueue<Element> resolve() { - resolveCount++; - EssentialQueue<Element> queue = new LinkedEssentialQueue<Element>(); - char[] array = str.toCharArray(); - for (char c : array) { - queue.enqueue(new Element(c)); - } - return queue; - } - } -} +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/18 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import java.util.Iterator; +import java.util.NoSuchElementException; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * {@link ResolvableQueue}のテストクラス。 + * + * @author daisuke + */ +public class ResolvableQueueTest { + + private static int resolveCount; + + + private static void assertThatResolveCountIs(int count) { + assertThat(resolveCount, is(count)); + } + + + private ResolvableQueue<Element> queue; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + queue = new ResolvableQueue<Element>(); + resolveCount = 0; + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + queue = null; + } + + /** + * キューとして普通に機能する。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test01_キューとして普通に機能する() throws Exception { + queue.enqueue(new Element('a')); + queue.enqueue(new Element('b')); + queue.enqueue(new Element('c')); + + assertThatResolveCountIs(0); + + assertThat(queue.dequeue().ch, is('a')); + assertThat(queue.dequeue().ch, is('b')); + assertThat(queue.dequeue().ch, is('c')); + + assertThatResolveCountIs(0); + } + + /** + * 可分割キューとして機能する。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test02_可分割キューとして機能する() throws Exception { + queue.enqueue(new Element('a')); + queue.enqueue(new ResolvableElement("xyz")); + queue.enqueue(new Element('c')); + + assertThatResolveCountIs(0); + + assertThat(queue.dequeue().ch, is('a')); + assertThatResolveCountIs(0); + assertThat(queue.dequeue().ch, is('x')); // resolve + assertThatResolveCountIs(1); + assertThat(queue.dequeue().ch, is('y')); + assertThat(queue.dequeue().ch, is('z')); + assertThat(queue.dequeue().ch, is('c')); + assertThatResolveCountIs(1); + } + + /** + * 多段可分割キューとして機能する。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test03_多段可分割キューとして機能する() throws Exception { + queue.enqueue(new Element('a')); + queue.enqueue(new MultiResolvableElement("opq", "xyz")); + queue.enqueue(new Element('c')); + + assertThatResolveCountIs(0); + + assertThat(queue.dequeue().ch, is('a')); + assertThatResolveCountIs(0); + + assertThat(queue.dequeue().ch, is('o')); // resolve×2回(Multiとopq) + assertThatResolveCountIs(2); + assertThat(queue.dequeue().ch, is('p')); + assertThat(queue.dequeue().ch, is('q')); + assertThatResolveCountIs(2); + + assertThat(queue.dequeue().ch, is('x')); // resolve + assertThatResolveCountIs(3); + assertThat(queue.dequeue().ch, is('y')); + assertThat(queue.dequeue().ch, is('z')); + + assertThat(queue.dequeue().ch, is('c')); + assertThatResolveCountIs(3); + } + + /** + * キューをまとめてキューに追加できる。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test04_キューをまとめてキューに追加できる() throws Exception { + queue.enqueue(new Element('a')); + queue.enqueue(new MultiResolvableElement("opq", "xyz")); + queue.enqueue(new Element('c')); + + ResolvableQueue<Element> queue2 = new ResolvableQueue<Element>(); + queue.enqueue(new ResolvableElement("XYZ")); + queue2.enqueue(new Element('C')); + + queue.enqueue(queue2); + + assertThatResolveCountIs(0); + + assertThat(queue.dequeue().ch, is('a')); + assertThatResolveCountIs(0); + + assertThat(queue.dequeue().ch, is('o')); // resolve×2回(Multiとopq) + assertThatResolveCountIs(2); + assertThat(queue.dequeue().ch, is('p')); + assertThat(queue.dequeue().ch, is('q')); + assertThatResolveCountIs(2); + + assertThat(queue.dequeue().ch, is('x')); // resolve + assertThatResolveCountIs(3); + assertThat(queue.dequeue().ch, is('y')); + assertThat(queue.dequeue().ch, is('z')); + + assertThat(queue.dequeue().ch, is('c')); + assertThatResolveCountIs(3); + + // 以下、queue2としてまとめてenqueueしたもの + + assertThat(queue.dequeue().ch, is('X')); // resolve + assertThatResolveCountIs(4); + assertThat(queue.dequeue().ch, is('Y')); + assertThat(queue.dequeue().ch, is('Z')); + + assertThat(queue.dequeue().ch, is('C')); + assertThatResolveCountIs(4); + } + + /** + * キューから取り出せるサイズとisEmptyの整合性。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test05_キューから取り出せるサイズとisEmptyの整合性() throws Exception { + // これは・・・実装難しいかな? + // resolveしないままサイズをはかれないから…。 + // Resolvableに size() メソッドを定義しても良い。 + // とにかくdequeueまではresolveしないことが重要。 + + assertThatResolveCountIs(0); + + assertThat(queue.isEmpty(), is(true)); + assertThat(queue.size(), is(0)); + + queue.enqueue(new Element('a')); + + assertThat(queue.isEmpty(), is(false)); + assertThat(queue.size(), is(1)); + + queue.enqueue(new MultiResolvableElement("opq", "xyz")); + + assertThat(queue.isEmpty(), is(false)); + assertThat(queue.size(), is(7)); + + queue.enqueue(new Element('c')); + + assertThat(queue.isEmpty(), is(false)); + assertThat(queue.size(), is(8)); + + queue.clear(); + + assertThat(queue.isEmpty(), is(true)); + assertThat(queue.size(), is(0)); + +// assertThatResolveCountIs(0); + } + + /** + * peekではキューからの削除が行われない。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test06_peekではキューからの削除が行われない() throws Exception { + queue.enqueue(new Element('a')); + queue.enqueue(new MultiResolvableElement("opq", "xyz")); + queue.enqueue(new Element('c')); + + assertThatResolveCountIs(0); + + assertThat(queue.peek().ch, is('a')); + assertThat(queue.peek().ch, is('a')); + queue.dequeue(); + assertThatResolveCountIs(0); + assertThat(queue.peek().ch, is('o')); // resolve×2回(Multiとopq) + assertThatResolveCountIs(2); + assertThat(queue.peek().ch, is('o')); + queue.dequeue(); + assertThat(queue.peek().ch, is('p')); + assertThat(queue.peek().ch, is('p')); + queue.dequeue(); + assertThat(queue.peek().ch, is('q')); + assertThat(queue.peek().ch, is('q')); + queue.dequeue(); + assertThatResolveCountIs(2); + assertThat(queue.peek().ch, is('x')); // resolve + assertThatResolveCountIs(3); + assertThat(queue.peek().ch, is('x')); + queue.dequeue(); + assertThat(queue.peek().ch, is('y')); + assertThat(queue.peek().ch, is('y')); + queue.dequeue(); + assertThat(queue.peek().ch, is('z')); + assertThat(queue.peek().ch, is('z')); + queue.dequeue(); + assertThat(queue.peek().ch, is('c')); + assertThat(queue.peek().ch, is('c')); + assertThatResolveCountIs(3); + } + + /** + * Iteratorテスト。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test07_Iteratorテスト() throws Exception { + queue.enqueue(new Element('a')); + queue.enqueue(new MultiResolvableElement("opq", "xyz")); + queue.enqueue(new Element('c')); + String ref = "aopqxyzc"; + + assertThatResolveCountIs(0); + + int index = 0; + int simulatedResolveCount = 0; + Iterator<Element> iterator = queue.iterator(); + assertThatResolveCountIs(0); + while (iterator.hasNext()) { + assertThat(iterator.next().ch, is(ref.charAt(index))); + + if (ref.charAt(index) == 'o') { + simulatedResolveCount += 2; + } else if (ref.charAt(index) == 'x') { + simulatedResolveCount++; + } + assertThatResolveCountIs(simulatedResolveCount); + index++; + } + // 8回回ったハズ + assertThat(index, is(8)); + + // Iteratorの為にresolveが行われている + assertThatResolveCountIs(3); + + // イテレータを回しても、キューは崩されていないこと + assertThat(queue.peek().ch, is('a')); + queue.dequeue(); // a + assertThatResolveCountIs(3); + queue.dequeue(); // o resolve×2回(Multiとopq) + assertThatResolveCountIs(5); + queue.dequeue(); // p + queue.dequeue(); // q + assertThatResolveCountIs(5); + queue.dequeue(); // x resolve + assertThatResolveCountIs(6); + queue.dequeue(); // y + queue.dequeue(); // z + queue.dequeue(); // c + + // dequeueのために更にresolveが行われる + assertThatResolveCountIs(6); + } + + /** + * 要素がない時に取得を行うとNoSuchElementException。 + * + * @throws Exception 例外が発生した場合 + */ + @Test(expected = NoSuchElementException.class) + public void test07_要素がない時に取得を行うとNoSuchElementException() throws Exception { + queue.dequeue(); + queue.peek(); + } + + + /** + * テスト用要素クラス。 + * + * @author daisuke + */ + private static class Element { + + char ch; + + + Element(char c) { + ch = c; + } + } + + /** + * テスト用多段可分割要素クラス。 + * + * @author daisuke + */ + private static class MultiResolvableElement implements Resolvable<Element> { + + String[] str; + + + MultiResolvableElement(String... str) { + this.str = str; + } + + public EssentialQueue<Element> resolve() { + resolveCount++; + ResolvableQueue<Element> queue = new ResolvableQueue<Element>(); + for (String s : str) { + queue.enqueue(new ResolvableElement(s)); + } + return queue; + } + } + + /** + * テスト用可分割要素クラス。 + * + * @author daisuke + */ + private static class ResolvableElement implements Resolvable<Element> { + + String str; + + + ResolvableElement(String str) { + this.str = str; + } + + public EssentialQueue<Element> resolve() { + resolveCount++; + EssentialQueue<Element> queue = new LinkedEssentialQueue<Element>(); + char[] array = str.toCharArray(); + for (char c : array) { + queue.enqueue(new Element(c)); + } + return queue; + } + } +} Property changes on: sandbox/jiemamy-stax/src/test/java/org/jiemamy/utils/ResolvableQueueTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/test/resources/logback.xml =================================================================== --- sandbox/jiemamy-stax/src/test/resources/logback.xml 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/test/resources/logback.xml 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,30 +1,30 @@ -<configuration> - <appender name="STDOUT" - class="ch.qos.logback.core.ConsoleAppender"> - <Target>System.out</Target> - <layout class="ch.qos.logback.classic.PatternLayout"> - <Pattern>%d{HH:mm:ss,SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> - </layout> - </appender> - - <root> - <level value="WARN" /> - <appender-ref ref="STDOUT" /> - </root> - - <logger name="org.jiemamy"> - <level value="INFO" /> - </logger> - - <logger name="org.jiemamy.utils.enhancer"> - <level value="WARN" /> - </logger> - - <logger name="org.jiemamy.dialect"> - <level value="DEBUG" /> - </logger> - - <logger name="org.jiemamy.dialect.mysql"> - <level value="TRACE" /> - </logger> -</configuration> +<configuration> + <appender name="STDOUT" + class="ch.qos.logback.core.ConsoleAppender"> + <Target>System.out</Target> + <layout class="ch.qos.logback.classic.PatternLayout"> + <Pattern>%d{HH:mm:ss,SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern> + </layout> + </appender> + + <root> + <level value="WARN" /> + <appender-ref ref="STDOUT" /> + </root> + + <logger name="org.jiemamy"> + <level value="INFO" /> + </logger> + + <logger name="org.jiemamy.utils.enhancer"> + <level value="WARN" /> + </logger> + + <logger name="org.jiemamy.dialect"> + <level value="DEBUG" /> + </logger> + + <logger name="org.jiemamy.dialect.mysql"> + <level value="TRACE" /> + </logger> +</configuration> Property changes on: sandbox/jiemamy-stax/src/test/resources/logback.xml ___________________________________________________________________ Modified: svn:mime-type - text/plain + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/test/resources/minimal.jiemamy-core.xml =================================================================== --- sandbox/jiemamy-stax/src/test/resources/minimal.jiemamy-core.xml 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/test/resources/minimal.jiemamy-core.xml 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,4 +1,4 @@ -<?xml version='1.0' encoding='UTF-8'?> -<rootModel xmlns="http://jiemamy.org/xml/ns/core" id="ffffffff-ffff-ffff-ffff-ffffffffffff"> - <dialect>com.example.HogeDialect</dialect> -</rootModel> +<?xml version='1.0' encoding='UTF-8'?> +<rootModel xmlns="http://jiemamy.org/xml/ns/core" id="ffffffff-ffff-ffff-ffff-ffffffffffff"> + <dialect>com.example.HogeDialect</dialect> +</rootModel> Property changes on: sandbox/jiemamy-stax/src/test/resources/minimal.jiemamy-core.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Modified: sandbox/jiemamy-stax/src/test/resources/minimal.xml =================================================================== --- sandbox/jiemamy-stax/src/test/resources/minimal.xml 2009-10-07 17:37:58 UTC (rev 3725) +++ sandbox/jiemamy-stax/src/test/resources/minimal.xml 2009-10-07 17:46:12 UTC (rev 3726) @@ -1,5 +1,5 @@ -<?xml version="1.0" encoding="utf-8" ?> -<foo xmlns:prefix="uri_prifix" xmlns="uri_anon"> - <bar prefix:localName="piyo">value</bar> - <bar /> +<?xml version="1.0" encoding="utf-8" ?> +<foo xmlns:prefix="uri_prifix" xmlns="uri_anon"> + <bar prefix:localName="piyo">value</bar> + <bar /> </foo> \ No newline at end of file Property changes on: sandbox/jiemamy-stax/src/test/resources/minimal.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/nb-configuration.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/nbactions.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/pom.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/NekotterAction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/NekotterTopComponent.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/config/ConfigOptionsPanelController.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/java/org/jiemamy/nekotter/window/config/ConfigPanel.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/nbm/module.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/Bundle.properties ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/NekotterTopComponentSettings.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/NekotterTopComponentWstcref.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/layer.xml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/window/Bundle.properties ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native Property changes on: sandbox/nekotter/src/main/resources/org/jiemamy/nekotter/window/config/Bundle.properties ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Revision Author HeadURL Id Added: svn:eol-style + native