Use EolExtension to force LF as line separator for all operating systems
diff --git a/.hgeol b/.hgeol
new file mode 100644
index 0000000..629cb36
--- /dev/null
+++ b/.hgeol
@@ -0,0 +1,6 @@
+[patterns]
+**.java = LF
+**.txt = LF
+**.xml = LF
+**.yaml = LF
+**.yml = LF
diff --git a/LICENSE.txt b/LICENSE.txt
index 7cd40e5..d9a10c0 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,176 +1,176 @@
- 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
+ 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
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index a64cdb8..30de10b 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -1,1086 +1,1090 @@
-<document xmlns="http://maven.apache.org/changes/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
- <properties>
- <title>YAML 1.1 parser and emitter</title>
- <author email="py4fun@gmail.com">Andrey Somov</author>
- </properties>
- <body>
- <release version="1.10-SNAPSHOT" date="in Mercurial" description="Development">
- <action dev="py4fun" type="add">
- Add a test for issue 136 (2011-12-14)
- </action>
- <action dev="py4fun" type="remove">
- Deprecate the DumperOptions.calculateScalarStyle() method because it was introduced as a quick
- fix for issue 29. Now it should not be required at all (because of the fix for issue 66),
- or it should be implemented in the Representer (in RepresentString) (2011-10-10)
- </action>
- <action dev="py4fun" type="fix">
- Fix issue 66: literal scalar style is used by default for multiline scalars (2011-10-10)
- </action>
- <action dev="py4fun" type="add">
- An example added: how to dump multiline literal scalars (2011-10-04)
- </action>
- <action dev="py4fun" type="add">
- An example added: how to dump recursive object for issue 133 (2011-09-14)
- </action>
- <action dev="py4fun" type="add">
- A test added for issue 132 (2011-09-13)
- </action>
- <action dev="py4fun" type="update">
- Finish 1.9 release (2011-08-15)
- </action>
- </release>
- <release version="1.9" date="2011-08-15" description="Introduce Yaml.loadAs() and Yaml.dumpAs() methods">
- <action dev="py4fun" type="update">
- Add a test to prove that SnakeYAML is not affected by the problem reported for libyaml
- at http://pyyaml.org/ticket/196 (2011-07-28)
- </action>
- <action dev="py4fun" type="fix" issue="128">
- Since timestamp contains ':' characters it is dumped with single quoted scalar style
- in the flow context. The single quoted scalar style causes to dump the explicit tag.
- In the block context the plain scalar can be used and the tag is not required. It may cause
- unpredictable behaviour if the tag is required. See the comments in JodaTimeExampleTest (2011-07-25)
- </action>
- <action dev="py4fun" type="fix" issue="130">
- Fix scientific notation inconsistency in the YAML 1.1 specification:
- scalar '8e-06' should be parsed as a Double (2011-07-24)
- </action>
- <action dev="py4fun" type="remove" issue="127">
- Do not allow to override BaseRepresenter.representData(Object data) because
- users should instead implement Represent interface (2011-07-21)
- </action>
- <action dev="py4fun" type="remove" issue="124">
- Deprecate DumperOptions.explicitRoot (2011-07-20)
- </action>
- <action dev="py4fun" type="add" issue="124">
- Add Yaml.dumpAs(Object, Tag.MAP, FlowStyle) and Yaml.dumpAsMap(Object) methods. JavaBeanDumper is marked as deprecated (2011-07-16)
- </action>
- <action dev="py4fun" type="add" issue="127">
- Add example to show how to dump a custom class (2011-07-12)
- </action>
- <action dev="py4fun" type="add" issue="129">
- Add Yaml.serialize(Node) low level method to the public API (2011-07-14)
- </action>
- <action dev="py4fun" type="add" issue="129">
- Add Yaml.represent(Object) low level method to the public API (2011-07-14)
- </action>
- <action dev="py4fun" type="add" issue="125">
- Add support for Maven 3 via 'm3' profile (2011-07-10)
- </action>
- <action dev="py4fun" type="remove" issue="124">
- Remove deprecated JavaBeanParser (2011-07-05)
- </action>
- <action dev="py4fun" type="remove" issue="124">
- Remove redundant JavaBeanDumper.classTags set (2011-07-03)
- </action>
- <action dev="py4fun" type="add" issue="124">
- Add Yaml.loadAs() methods. JavaBeanLoader is marked as deprecated (2011-07-03)
- </action>
- <action dev="py4fun" type="remove" issue="124">
- Remove TypeDescription.root property to prepare issue 124. This is a minor backwards incompatible change.
- Now instead of setting as root, the TypeDescription must be passed to the Contructor's constructor
- to be taken as the root definition (2011-07-03)
- </action>
- <action dev="py4fun" type="fix" issue="121" due-to="Jaromir">
- Fix: close files in tests to avoid a possible file handle limit (2011-06-09)
- </action>
- <action dev="py4fun" type="fix" issue="116" due-to="Jim Peterson">
- Fix: Improved support for empty JavaBeans (2011-06-09)
- </action>
- <action dev="py4fun" type="fix" issue="112" due-to="Lethargish">
- Fix: Improved support for parameterised types in collections (2011-05-25)
- </action>
- <action dev="py4fun" type="fix" issue="115" due-to="elkniwt">
- Fix: parameterised JavaBeans fail to load and dump because they are treated as Maps (2011-05-16)
- </action>
- <action dev="py4fun" type="fix" issue="114" due-to="gileadis">
- Fix: Do not remove root tags of JavaBeans when it is not explicitly requested (2011-04-20)
- </action>
- <action dev="py4fun" type="fix" issue="111" due-to="JordanAngold">
- Fix: Long escaped tag URI sequences throw BufferOverflowException (2011-03-03)
- </action>
- <action dev="py4fun" type="fix" issue="110" due-to="dmitry.s.mamonov">
- Fix: introduce a package for external libraries and move there the 64Coder
- and the Google's URL encoder (2011-02-24)
- </action>
- <action dev="py4fun" type="fix" issue="109" due-to="cjalmeida">
- Fix: ancient years must be dumped with leading zeros (2011-02-19)
- </action>
- <action dev="py4fun" type="remove" due-to="JordanAngold">
- Remove unused code in Constructor: Modifier.isAbstract() is not needed any more (2011-02-18)
- </action>
- <action dev="JordanAngold" type="fix" issue="108">
- Enum's name property shall be dumped instead of the 'toString()' output (2011-02-16)
- </action>
- </release>
- <release version="1.8" date="2011-02-15" description="Performance improvement">
- <action dev="py4fun" type="add">
- Add example to howto Wiki:
- How_to_substitute_object_in_YAML_document_with_a_custom_object (2011-01-27)
- </action>
- <action dev="py4fun" type="update">
- When the YAML document to be loaded is provided as String parse it directly
- without making a Reader first (2011-01-23)
- </action>
- <action dev="py4fun" type="fix" issue="106">
- Immutable data structures in StreamReader allow to share the same buffer for all
- the Mark instances. It makes 'withMarkContext' setting redundant (2011-01-19)
- </action>
- <action dev="maslovalex" type="update" issue="100">
- Merge JavaBean properties when an explicit tag is provided (2011-01-11)
- </action>
- <action dev="py4fun" type="update" issue="99">
- Add an example for escaping line breaks in binary content (2011-01-03)
- </action>
- <action dev="py4fun" type="update" issue="97">
- Propose a solution for JavaBeans to support SortedSet property when it is encoded
- as a sequence (2010-11-24)
- </action>
- <action dev="py4fun" type="update" issue="59">
- Simplify the way how the order of JavaBean properties is specified. Introduce
- PropertyUtils.createPropertySet() method to be overridden when a specific order
- is expected (2010-11-23)
- </action>
- <action dev="maslovalex" type="fix" issue="95">
- Fix: Loading of generic collections with Array parameter(s). (2010-11-16)
- </action>
- <action dev="py4fun" type="update" issue="94">
- Add ChangeRuntimeClassTest as an example how to change a class for a global tag (2010-11-05)
- </action>
- <action dev="py4fun" type="update">
- Inner objects in Constructor become protected to be more flexible when Constructor
- is expended (2010-10-03)
- </action>
- <action dev="py4fun" type="update" issue="91">
- Apply www.snakeyaml.org domain name (2010-09-20)
- </action>
- <action dev="py4fun" type="fix" issue="90">
- Move Base64Coder into another package to keep a separate copyright statement.
- Base64Coder is left unchanged (2010-09-19)
- </action>
- <action dev="py4fun" type="fix" issue="69">
- Iterable should not be serialised as sequence (2010-09-16)
- </action>
- <action dev="py4fun" type="update">
- Introduce 'fast' Maven profile to quickly build cobertura reports (2010-09-16)
- </action>
- <action dev="py4fun" type="update" issue="89">
- Fix: Specify plugin versions in POM (2010-09-15)
- </action>
- <action dev="maslovalex" type="fix" issue="88">
- Fix: Custom tag erased when referenced from generic collection (2010-09-15)
- </action>
- <action dev="py4fun" type="update">
- Minor refactoring in Emitter to improve performance: save calls to Constant.has() (2010-09-13)
- </action>
- <action dev="maslovalex" type="update">
- Minor refactorings in Emitter to improve performance: create less Strings [r9185e0b3] (2010-09-10)
- </action>
- <action dev="py4fun" type="update" issue="79">
- Introduce LoaderOptions to be able to specify configuration while loading (2010-09-03)
- </action>
- <action dev="py4fun" type="fix" issue="81">
- Representer.representJavaBeanProperty() is given the wrong tag. Instead of the property tag,
- the tag for the JavaBean itself is provided. (2010-09-01)
- </action>
- <action dev="py4fun" type="update">
- Rename JvmDetector into GenericsBugDetector (2010-08-31)
- </action>
- <action dev="py4fun" type="fix" issue="80" due-to="SebastienRainville">
- Fix: Timestamp is not parsed properly when milliseconds start with 0 (2010-08-24)
- </action>
- <action dev="maslovalex" type="update" issue="79">
- Context for error reporting consumes a lot of resources (2010-08-21)
- </action>
- <action dev="py4fun" type="remove">
- Cleanup unused code in deprecated Loader and Dumper (2010-08-13)
- </action>
- </release>
- <release version="1.7" date="2010-08-12" description="Simplify public API (drop Loader and Dumper)">
- <action dev="py4fun" type="update">
- Eclipse does not run JUnit 4 tests when they are launched for the whole project (2010-08-11)
- </action>
- <action dev="maslovalex" type="update" issue="55">
- Share PropertyUtils if not explicitly set in Constructor or Representer
- (BeanAccess.FIELD works properly when JavaBean is identified by a root tag) (2010-08-11)
- </action>
- <action dev="py4fun" type="update">
- Create 1.7 Release Candidate 1 (2010-08-11)
- </action>
- <action dev="py4fun" type="update" issue="77">
- Simplify public API: Drop Dumper (2010-08-06)
- </action>
- <action dev="py4fun" type="update" issue="77">
- Simplify public API: Drop Loader (2010-08-05)
- </action>
- <action dev="py4fun" type="update" issue="75" due-to="jon.p.hermes">
- Add examples to create scalars that match custom regular expression:
- CustomImplicitResolverTest, CustomBeanResolverTest (2010-08-03)
- </action>
- <action dev="py4fun" type="fix" issue="74" due-to="Kevin Menard">
- Do not use redundant tags for arrays which are JavaBean properties. (2010-07-21)
- </action>
- <action dev="py4fun" type="update">
- RecursiveSetTest proves that it is possible to construct a recursive set (2010-07-20)
- </action>
- <action dev="py4fun" type="add" issue="73" due-to="birnbuazn">
- Provide sequence support for loading java.util.Set. Also provide an example
- to serialise a java.util.Set as a sequence. (2010-07-19)
- </action>
- <action dev="py4fun" type="add" issue="72" due-to="birnbuazn">
- Support java.util.Collection as a parent for List and Set (2010-07-09)
- </action>
- <action dev="maslovalex" type="add" issue="55" due-to="birnbuazn">
- Allow direct field access bypassing setters and getters. Empty constructor
- is required to support 2-step construction (2010-07-02)
- </action>
- <action dev="py4fun" type="update" issue="69">
- Serialise Iterator and Iterable as sequences (2010-06-25)
- </action>
- <action dev="py4fun" type="update" due-to="maslovalex">
- Change error message when 'No suitable constructor with N arguments found for class' (2010-06-23)
- </action>
- <action dev="py4fun" type="add" due-to="Antony Stubbs">
- Add JodaTime example (2010-06-04)
- </action>
- <action dev="py4fun" type="add" issue="67" due-to="Manuel Sugawara">
- Add possibility to create a Tag out of an URI (2010-05-31)
- </action>
- <action dev="py4fun" type="update">
- URLDecoder.decode() does not fail when UTF-8 is invalid. Use
- CodingErrorAction.REPORT to implement the failure (2010-05-21)
- </action>
- <action dev="maslovalex" type="update">
- Fix generic collections which contain other collections (2010-05-18)
- </action>
- <action dev="py4fun" type="fix" issue="67" due-to="Manuel Sugawara">
- Fix: java classes containing non-ASCII characters in names are
- incorrectly encoded (2010-05-14)
- </action>
- <action dev="py4fun" type="fix" issue="65" due-to="lerch.johannes">
- Fix: add checks for null arguments for JavaBeanDumper (2010-04-27)
- </action>
- <action dev="py4fun" type="add">
- Add a test to see how stack trace is serialised (2010-04-27)
- </action>
- <action dev="py4fun" type="fix" issue="64" due-to="maxim.moschko">
- ClassCastException in Representer when working with ParameterizedType (2010-04-25)
- </action>
- <action dev="py4fun" type="update">
- Improve toString() method for Node. Since scalars cannot be recursive
- they can be printed (2010-04-15)
- </action>
- <action dev="maslovalex" type="fix" issue="63" due-to="Udo">
- Refactor the way arrays are constructed (2010-04-15)
- </action>
- <action dev="py4fun" type="fix" issue="62">
- Add examples for dumping custom values for !!bool and !!null (2010-04-13)
- </action>
- <action dev="py4fun" type="fix" issue="61">
- Fix: ClassCastException when dumping generic bean (2010-04-11)
- </action>
- <action dev="py4fun" type="fix" issue="59">
- Provide an example for changing JavaBean properties order (2010-04-01)
- </action>
- <action dev="py4fun" type="fix" issue="60">
- Provide example for skipping null and empty collections (2010-03-29)
- </action>
- <action dev="py4fun" type="fix" issue="58" due-to="jeff.caulfield">
- JavaBeanDumper.dump throws NullPointerException on list property
- with null element (2010-03-23)
- </action>
- <action dev="py4fun" type="fix" issue="56" due-to="DZeiss">
- Make constructors in SafeConstructor public (2010-03-16)
- </action>
- <action dev="py4fun" type="update" due-to="David Bernard">
- Releases and snapshots are available in the Sonatype Maven repository.
- https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
- </action>
- <action dev="obastard" type="fix" issue="53" due-to="obastard">
- Enhancement for a pretty format that combines BLOCK and FLOW (2010-03-03)
- </action>
- <action dev="py4fun" type="fix" issue="50" due-to="sualeh.fatehi">
- Unable to dump JavaBean that inherits from a protected base class (2010-03-02)
- </action>
- <action dev="py4fun" type="update">
- Format source (2010-03-01)
- </action>
- <action dev="py4fun" type="update">
- Use Token.ID and Event.ID instead of just ID (2010-03-01)
- </action>
- <action dev="py4fun" type="update">
- Issue 50 fails in Eclipse but works with Maven (2010-03-01)
- </action>
- </release>
- <release version="1.6" date="2010-02-26" description="introduce Tag class">
- <action dev="py4fun" type="update">
- Release Candidate 2 is available (2010-02-24)
- </action>
- <action dev="py4fun" type="fix" issue="47" due-to="obastard">
- Don't dump read-only properties by default. DumperOptions gets a setting to
- include read-only JavaBean properties.
- This is no backwards compatible change (2010-02-19)
- </action>
- <action dev="py4fun" type="fix" issue="49" due-to="obastard">
- Support GregorianCalendar. Due to Daylight Saving Time parsing the timestamp with
- a TimeZone cannot determine the exact time (2010-02-19)
- </action>
- <action dev="py4fun" type="fix" issue="51" due-to="johann.Werner">
- Some Unicode characters are wrongly replaced by \x{fffd} during
- double quoted style dump (2010-02-15)
- </action>
- <action dev="py4fun" type="fix" issue="48" due-to="obastard">
- Introduce representJavaBeanProperty() method in Representer. The method
- can be overridden to simplify custom JavaBean representation (2010-02-12)
- </action>
- <action dev="py4fun" type="update">
- Release Candidate 1 is available (2010-02-01)
- </action>
- <action dev="py4fun" type="add">
- Representer.representJavaBean() returns MappingNode (2010-01-26)
- </action>
- <action dev="py4fun" type="add">
- Add example of serialising static fields (2010-01-26)
- </action>
- <action dev="py4fun" type="add">
- Add example of serialising java.io.File as scalar node for issue 46 (2010-01-25)
- </action>
- <action dev="py4fun" type="update">
- Refactor: introduce Chomping to avoid using null as value for Boolean.
- Stay in line with Scala port where null is not allowed (2010-01-19)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use Event.ID enum instead of classes (2010-01-15)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use Token.ID enum instead of classes (2010-01-15)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use generic classes for DirectiveToken (2010-01-14)
- </action>
- <action dev="py4fun" type="update">
- Refactor: rename Reader to StreamReader to avoid name conflict with java.io.Reader (2010-01-13)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use StringBuilder instead of StringBuffer (2010-01-12)
- </action>
- <action dev="py4fun" type="update">
- Refactor: introduce Constant class to share String constants (2010-01-12)
- </action>
- <action dev="py4fun" type="update">
- Keep Tag.equals(String) to simplify transition to Tag class (2010-01-08)
- </action>
- <action dev="py4fun" type="update">
- Refactor: introduce Tag instead of Tags. Nodes use Tag class instead of String (2010-01-05)
- </action>
- <action dev="py4fun" type="fix" issue="42" due-to="Artem">
- BaseConstructor shall give more flexibility to choose a constructor at runtime (2010-01-08)
- </action>
- <action dev="py4fun" type="update">
- Refactor: introduce TagTuple instead of String[] (2010-01-04)
- </action>
- <action dev="py4fun" type="fix" issue="40" due-to="sitrious">
- Ignore tags when they are compatible with the runtime class (2010-01-04)
- </action>
- <action dev="py4fun" type="add">
- Add example to ignore unknown tags (2009-12-08)
- </action>
- <action dev="py4fun" type="add">
- Add Ruby example (2009-12-08)
- </action>
- <action dev="py4fun" type="update">
- Do not omit the tag for JavaBean properties when the tag is explicitly defined (2009-12-08)
- </action>
- <action dev="py4fun" type="fix" issue="38" due-to="gchpaco">
- Fix ID format for numbers over 999 (2009-12-05)
- </action>
- <action dev="py4fun" type="fix" issue="29" due-to="grignaak">
- Allow separate option in DumperOptions for long strings (2009-11-16)
- </action>
- <action dev="py4fun" type="add">
- JavaBeanDumper: add possibility to define a custom Representer (2009-11-25)
- </action>
- <action dev="py4fun" type="fix" issue="36">
- Introduce multi contructors (tag prefix). A family of tags may be processed
- by a single constructor (2009-11-25)
- </action>
- <action dev="py4fun" type="update">
- Refactor BaseConstructor: simplify second step for recursive structures (2009-11-25)
- </action>
- <action dev="py4fun" type="add">
- Add FilterPropertyToDumpTest to show how to filter JavaBean properties (2009-11-24)
- </action>
- <action dev="py4fun" type="add">
- Add FilterClassesConstructorTest to show how to filter created classes (2009-11-16)
- </action>
- <action dev="py4fun" type="update" due-to="Stefan">
- Improve JavaDoc (2009-11-12)
- </action>
- <action dev="py4fun" type="add">
- Add Velocity example (2009-11-03)
- </action>
- <action dev="py4fun" type="update">
- Refactor: rename Tuple to RecursiveTuple and hide it inside BaseConstructor (2009-11-03)
- </action>
- </release>
- <release version="1.5" date="2009-10-30" description="Improve usage of generic collections in JavaBeans">
- <action dev="py4fun" type="fix" issue="27" due-to="Polyglot Maven team">
- Extend Resolver to support custom implicit types (2009-10-27)
- </action>
- <action dev="py4fun" type="update">
- Performance improvement: use ArrayStack instead of Stack which extends Vector (2009-10-20)
- </action>
- <action dev="py4fun" type="fix" issue="25" due-to="Benjamin Bentmann">
- Improve usage of generic collections: while type erase makes no difference between
- Class< Foo> and Class< Bar> at runtime, the information about generics is still
- accessible via reflection from Method/Field. (2009-10-19)
- </action>
- <action dev="py4fun" type="update">
- Fix ConstructYamlObject: support recursive objects. Introduce 'resolved'
- property for Nodes. This property supposed to help to distinguish explicit tag
- from the resolved tag (2009-10-19)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use rootTag instead of rootType (for Class) in BaseConstructor. This is done to
- solve the priority problem: normally explicit tag has more priority then runtime class but
- for the root tag it is the other way around (2009-10-19)
- </action>
- <action dev="py4fun" type="fix" issue="24" due-to="shrode">
- Line numbers reported in Exceptions are Zero based, should be 1 based (2009-10-12)
- </action>
- <action dev="py4fun" type="fix" issue="21" due-to="ashwin.jayaprakash">
- Support arrays of reference types as JavaBean properties (2009-09-22)
- </action>
- <action dev="py4fun" type="fix" issue="17" due-to="jcucurull">
- Respect root tag for sequences (2009-09-04)
- </action>
- <action dev="py4fun" type="fix" issue="18" due-to="creiniger">
- SafeRepresenter respects custom tags for standard Java classes where standard tag has
- more then one Java implementation available (Long, List, Map, Date etc) (2009-09-03)
- </action>
- <action dev="py4fun" type="add">
- Add possibility to define a custom Class Loader. (2009-09-01)
- </action>
- <action dev="py4fun" type="fix">
- Fixed an obscure scanner error not reported when there is no line break at the end
- of the stream. The fix is imported from PyYAML 3.09 {ticket 118} (2009-08-31)
- </action>
- <action dev="py4fun" type="fix" issue="16" due-to="infinity0x">
- Cache JavaBean class properties. Tests show that the loading has become a few percents faster (2009-08-31)
- </action>
- <action dev="py4fun" type="add">
- Introduce ArrayStack to use push() and pop() instead of standard (and too verbose)
- 'remove(size()-1)' (2009-08-27)
- </action>
- <action dev="py4fun" type="fix" issue="14" due-to="infinity0x">
- Fix: ArrayList is more efficient than LinkedList (2009-08-26)
- </action>
- </release>
- <release version="1.4" date="2009-08-26" description="better support for loading immutable objects">
- <action dev="py4fun" type="update">
- Apply Apache License Version 2.0 (2009-08-14)
- </action>
- <action dev="py4fun" type="fix" issue="13" due-to="infinity0x">
- Provide javadocs link to Sun Java API (2009-08-10)
- </action>
- <action dev="py4fun" type="add">
- Build 1.4 Release Candidate 1 (2009-08-07)
- </action>
- <action dev="py4fun" type="add">
- Introduce Tags.getGlobalTagForClass() to simplify tag generation in custom constructors (2009-08-06)
- </action>
- <action dev="py4fun" type="update">
- Refactor: introduce ImplicitTuple (2009-08-06)
- </action>
- <action dev="py4fun" type="fix" issue="11" due-to="infinity0x">
- Fix: create a Java instance with the following priority to choose the class:
- Explicit tag -> Runtime class (defined in JavaBean) -> implicit tag (2009-08-06)
- </action>
- <action dev="py4fun" type="fix" issue="9" due-to="wwagner4">
- Fix: Bean with no property cannot be instantiated. This is implemented via better
- support for immutable objects. Custom Constructor may be used when there are more
- then 1 way to create an instance (2009-08-04)
- </action>
- <action dev="py4fun" type="add">
- Deliver possibility to load immutable instances with no global tags. Reflection for
- constructor arguments is used to get the runtime classes (2009-08-04)
- </action>
- <action dev="py4fun" type="update">
- Use more informative error message when a JavaBean property cannot
- be created (2009-08-02)
- </action>
- <action dev="py4fun" type="update">
- Refactor: Constructor is rewritten. Do not overwrite methods from BaseConstructor.
- Instead introduce ConstructScalar, ConstructSequence, ConstructMapping (2009-07-31)
- </action>
- <action dev="py4fun" type="update">
- Change Maven repository path: groupId='org.yaml', artifactId='snakeyaml' (2009-07-31)
- </action>
- <action dev="py4fun" type="fix" issue="10" due-to="derrick.rice">
- Fix: dump omits JavaBean class name when used with an alias (2009-07-28)
- </action>
- <action dev="py4fun" type="add">
- Generate sources and Javadoc (2009-07-27)
- </action>
- <action dev="py4fun" type="update">
- Node does not have the value. It is delegated to the non-abstract classes (2009-07-27)
- </action>
- <action dev="py4fun" type="add">
- Extends JavaBeanDumper to allow skipping global tags inside type-safe collections.
- Introduce method setMapTagForBean() (2009-07-22)
- </action>
- <action dev="py4fun" type="add">
- Add ConstructEmptyBeanTest to test JavaBean construction with no
- properties in the YAML document(2009-07-22)
- </action>
- <action dev="py4fun" type="remove">
- Refactor: redesign tag management for JavaBeans in Representer.
- Drop dynamic root tag concept (2009-07-22)
- </action>
- <action dev="py4fun" type="remove">
- Remove unused TypeDescription in Representer (2009-07-21)
- </action>
- <action dev="py4fun" type="update">
- Use NodeTuple instead of Node[] for mappings (2009-07-21)
- </action>
- <action dev="py4fun" type="add">
- Introduce JavaBeanLoader and JavaBeanDumper. Deprecate JavaBeanParser (2009-07-21)
- </action>
- <action dev="py4fun" type="fix" issue="8" due-to="Alan Gutierrez">
- Fix: Representer was keeping state between invocations (2009-07-21)
- </action>
- </release>
- <release version="1.3" date="2009-07-20" description="complete support for recursive objects">
- <action dev="py4fun" type="fix" issue="6" due-to="infinity0x">
- Fix: values returned by System.identityHashCode() are not guaranteed to be unique (2009-07-14)
- </action>
- <action dev="py4fun" type="add">
- Add a simple test for Java Generics (BirdTest). Unfortunately it shows that some JVM
- implementations do not recognise classes for JavaBean properties at runtime.
- It leads to unnecessary global tags. See http://code.google.com/p/snakeyaml/wiki/Documentation#Generics
- for details (2009-07-13)
- </action>
- <action dev="py4fun" type="fix" issue="5" due-to="infinity0x">
- Fix: set the "cause" field for MarkedYAMLException (2009-07-10)
- </action>
- <action dev="maslovalex" type="fix" issue="1">
- Fix: Recursive objects are now fully supported (2009-07-09)
- </action>
- <action dev="py4fun" type="add">
- Add support for BigDecimal as a JavaBean property (2009-07-07)
- </action>
- <action dev="py4fun" type="update">
- Improve test coverage for Constructor. Allow construction of JavaBeans
- with only setter without the corresponding getter (2009-07-07)
- </action>
- <action dev="py4fun" type="add">
- Add a test to check the proper report for IOException (2009-07-03)
- </action>
- <action dev="py4fun" type="fix" issue="3" due-to="infinity0x">
- Fix: represent proper tags for JavaBeans when they are not the root of the YAML
- document but a member of a collection (2009-07-03)
- </action>
- <action dev="py4fun" type="update">
- Refactor: run PMD and apply some of the recommendations (2009-06-18)
- </action>
- <action dev="py4fun" type="add" issue="1">
- Create an issue for Recursive objects to be remembered (2009-06-08)
- </action>
- <action dev="py4fun" type="update">
- Migrate project hosting from Assembla to Google code (2009-06-08)
- </action>
- <action dev="py4fun" type="fix" due-to="Magne">
- Fix: null as a JavaBean property was not handled properly (2009-06-04)
- </action>
- <action dev="py4fun" type="update">
- Validate changes.xml file (2009-05-25)
- </action>
- <action dev="py4fun" type="fix" due-to="Magne">
- Fix ticket 40 in Assembla: getting an error when javabean contains java.sql.Timestamp fields (2009-05-25)
- </action>
- </release>
- <release version="1.2" date="2009-04-27" description="expose low-level API">
- <action dev="py4fun" type="add">
- Add 'Yaml.parse()' method which return Events to support low level YAML processing (2009-04-20)
- </action>
- <action dev="py4fun" type="add" due-to="Bob Jalex">
- Introduce LineBreak.getPlatformLineBreak (ticket 5 in Assembla) (2009-04-18)
- </action>
- <action dev="py4fun" type="update" due-to="Bob Jalex">
- Rename LineBreak.LINUX to LineBreak.UNIX (ticket 5 in Assembla) (2009-04-18)
- </action>
- <action dev="py4fun" type="add">
- Add 'Yaml.compose()' methods which return Nodes to support YEdit (2009-04-17)
- </action>
- <action dev="py4fun" type="update">
- Refactor: rename enums in DumperOptions to make the names consistent (2009-04-07)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use Character instead of char primitive for style in Emitter (2009-04-07)
- </action>
- <action dev="py4fun" type="add">
- Add possibility to parse all scalars as Strings (2009-03-30)
- </action>
- <action dev="py4fun" type="update">
- Merge changeset 347 from PyYAML (2009-03-30)
- </action>
- <action dev="py4fun" type="fix">
- Respect DumperOptions with a custom Representer (2009-03-18)
- </action>
- <action dev="py4fun" type="fix">
- Represent TAB as '\t' instead of '(9' in the error message (2009-03-17)
- </action>
- </release>
- <release version="1.1" date="2009-03-14" description="improve performance and test coverage">
- <action dev="py4fun" type="add">
- Introduce JavaBeanParser (2009-03-14)
- </action>
- <action dev="py4fun" type="add">
- Introduce DumperOptions.Version enum (2009-03-13)
- </action>
- <action dev="py4fun" type="add">
- Introduce DumperOptions.LineBreak enum (2009-03-10)
- </action>
- <action dev="py4fun" type="update">
- Use byte[] for binary type. (2009-03-09)
- </action>
- <action dev="py4fun" type="update">
- Restore Regular Expressions in Resolver. Ragel gives only 5% performance increase.
- Fix a bug in Resolver with expanded regular expressions which caused the
- performance problem. (2009-03-06)
- </action>
- <action dev="py4fun" type="add">
- Better Spring support: it is now possible to create a constructor with a String
- as the class name. (2009-03-05)
- </action>
- <action dev="py4fun" type="update">
- Throw an exception when the same Loader or Dumper instance is shared between
- different Yaml instances. Because they are statefull it is not Thread-safe. (2009-03-05)
- </action>
- <action dev="py4fun" type="add">
- Add possibility to set a meaningful name for Yaml instance to be shown in toString(). (2009-03-05)
- </action>
- <action dev="py4fun" type="update">
- Refactor: declare classes which are not expected to be extended as final. (2009-03-04)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use 'final' keyword to identify immutable fields. (2009-03-04)
- </action>
- <action dev="py4fun" type="update">
- Refactor: do not use 'final' keyword for local variables. (2009-03-04)
- </action>
- <action dev="py4fun" type="fix">
- Fix: respect implicit resolvers with 'null' as a first character. (2009-03-02)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use Character instead of String as a key for implicit resolvers. (2009-03-02)
- </action>
- <action dev="py4fun" type="add">
- Use Ragel instead of Regular Expressions for implicit types. (2009-03-02)
- </action>
- <action dev="py4fun" type="fix" due-to="Christophe Desguez">
- Fix ticket #4 (in Assembla): java.sql.Date not handled. (2009-02-28)
- </action>
- <action dev="py4fun" type="add">
- Introduce DumperOptions.DefaultFlowStyle enum (2009-02-24)
- </action>
- <action dev="py4fun" type="add">
- Introduce DumperOptions.DefaultScalarStyle enum (2009-02-24)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use 'switch' with Enum instead of multiple 'if' statements to distinguish nodes (2009-02-19)
- </action>
- <action dev="py4fun" type="update">
- Refactor: use Enum instead of String as NodeId (2009-02-19)
- </action>
- </release>
- <release version="1.0.1" date="2009-02-18" description="implement Enum support">
- <action dev="py4fun" type="fix">
- Do not emit anchors for Enum (2009-02-18)
- </action>
- <action dev="py4fun" type="fix">
- Enum as a JavaBean property (when the Enum class is implicitly defined) does
- not need tags for both loading and dumping (2009-02-17)
- </action>
- <action dev="py4fun" type="fix">
- Enum is emitted as a scalar node (2009-02-17)
- </action>
- <action dev="py4fun" type="fix" due-to="James Nissel">
- Enum is parsed as a scalar node or as a JavaBean property (2009-02-17)
- </action>
- <action dev="py4fun" type="update">
- Refactor: for performance ScannerImpl.stalePossibleSimpleKeys() does not copy key Set (2009-02-10)
- </action>
- <action dev="py4fun" type="update">
- By default allowUnicode=true. If it is necessary to escape Unicode use
- DumperOptions.setAllowUnicode(false) (2009-02-09)
- </action>
- <action dev="py4fun" type="add">
- Implement allowUnicode setting (to escape Unicode characters on non UTF-8 terminals) (2009-02-09)
- </action>
- <action dev="py4fun" type="add">
- Add possibility to specify tags for dumping (2009-02-09)
- </action>
- <action dev="py4fun" type="update">
- Rename getExpRoot to getExplicitRoot to conform with
- standard JavaBean naming convention (2009-02-09)
- </action>
- <action dev="py4fun" type="update">
- Rename explictStart and explicitEnd to standard setters to conform with
- standard JavaBean naming convention (2009-02-09)
- </action>
- <action dev="py4fun" type="fix">
- Add possibility to specify a line break (2009-02-09)
- </action>
- </release>
- <release version="1.0" date="2009-02-06" description="final 1.0 release">
- <action dev="py4fun" type="fix">
- Use LinkedHashMap for Emitter.tagPrefixes to respect the order (2009-02-06)
- </action>
- <action dev="py4fun" type="fix">
- Use LinkedHashMap for ScannerImpl.possibleSimpleKeys to respect the key order (2009-02-05)
- </action>
- <action dev="py4fun" type="add">
- Add a test to prove that Yaml instances are independent and can safely be used in
- multithreaded environment like for instance a Servlet container (2009-02-05)
- </action>
- <action dev="py4fun" type="update">
- The mailing list is renamed to snakeyaml-core to avoid a
- name conflict in Google AppEngine (2009-02-03)
- </action>
- </release>
- <release version="1.0rc2" date="2008-01-22" description="Improve JavaBeans support">
- <action dev="py4fun" type="add">
- Provide possibility to define/eliminate the root tag for JavaBeans. Avoiding global tags
- helps to exchange YAML documents with other programming languages (2009-01-21)
- </action>
- <action dev="py4fun" type="fix">
- Arrays as JavaBens properties are properly supported (2009-01-21)
- </action>
- <action dev="py4fun" type="update">
- Do not emit redundant tags for JavaBeans (2009-01-20)
- </action>
- <action dev="py4fun" type="add">
- Respect public fields in JavaBeans (2009-01-20)
- </action>
- </release>
- <release version="1.0rc1" date="2009-01-16" description="Construct type safe collections">
- <action dev="py4fun" type="update">
- Replace String.getBytes(Charset charset) with String.getBytes(String charsetName) because
- String.getBytes(Charset charset) was introduced only in Java 6 (2009-01-16)
- </action>
- <action dev="py4fun" type="update">
- Replace LinkedList.pop() with removeFirst() because pop() was
- introduced only in Java 6 (2009-01-16)
- </action>
- <action dev="py4fun" type="update">
- Replace LinkedList.push() with addFirst() because push() was
- introduced only in Java 6 (2009-01-16)
- </action>
- <action dev="py4fun" type="add">
- Implement type safe Map as a property of custom Java class (2009-01-16)
- </action>
- <action dev="py4fun" type="add">
- Implement type safe List as a property of custom Java class (2009-01-15)
- </action>
- <action dev="py4fun" type="update">
- Construct interface does not use generics. The type information is set
- to the Node (2009-01-15)
- </action>
- <action dev="py4fun" type="add">
- Introduce TypeDescription as a single configuration option for a custom class (2009-01-15)
- </action>
- </release>
- <release version="0.91" date="2008-01-14" description="Support shortcut tags for custom classes">
- <action dev="py4fun" type="add">
- Add possibility to define shortcut tags for custom classes while loading (2009-01-13)
- </action>
- <action dev="py4fun" type="add">
- Add possibility to define shortcut tags for custom classes while dumping (2009-01-13)
- </action>
- <action dev="py4fun" type="add">
- Construct List as a JavaBean property. But due to erasure only standard Java
- classes created (2009-01-13)
- </action>
- <action dev="py4fun" type="add">
- Import PyStructureTest from PyYAML (2009-01-13)
- </action>
- <action dev="py4fun" type="add">
- Import canonical scanner and parser from PyYAML (2009-01-12)
- </action>
- </release>
- <release version="0.9" date="2008-01-12" description="Add possibility to define a root class for Loader">
- <action dev="py4fun" type="add">
- Finish 2.27 example from the specification (2009-01-12)
- </action>
- <action dev="py4fun" type="add">
- Add possibility to define a root class for Loader (2009-01-11)
- </action>
- <action dev="py4fun" type="update">
- Use Java Generics in the Construct interface (2009-01-11)
- </action>
- <action dev="py4fun" type="update">
- Use Java Generics in the Scanner interface (2009-01-08)
- </action>
- <action dev="py4fun" type="update">
- Create ScannerIml only in ParserImpl (2009-01-08)
- </action>
- <action dev="py4fun" type="fix">
- Import changeset 312 from PyYAML. Fix a bug in Emitter when writing folded scalars (2009-01-07)
- </action>
- </release>
- <release version="0.8" date="2009-01-07" description="Import changes from PyYAML 3.08">
- <action dev="py4fun" type="add">
- Add possibility to use java.io.Reader as input. BOM must be respected. (2009-01-06)
- </action>
- <action dev="py4fun" type="update">
- Import Changeset 308 from PyYAML: Refactored whitespace combination
- detector in the scalar analyser. (2009-01-06)
- </action>
- <action dev="py4fun" type="update">
- Import Changeset 313 from PyYAML: Emit an explicit document end indicator
- when there is a possibility of ambiguous parsing. (2009-01-06)
- </action>
- <action dev="py4fun" type="update">
- Use global tags (with !!) to dump Java custom instances. (2009-01-05)
- </action>
- <action dev="py4fun" type="update">
- Use global tags (with !!) to load Java custom instances. (2009-01-05)
- </action>
- <action dev="py4fun" type="add">
- Add example of defining a custom List and Map implementations. (2009-01-04)
- </action>
- <action dev="py4fun" type="fix">
- Fix parsing Long.MIN_VALUE: respect the sign when parsing integers. (2009-01-04)
- </action>
- <action dev="py4fun" type="update">
- when constructing integers try to create the first in the following order:
- Integer -> Long -> BigInteger. (2009-01-02)
- </action>
- </release>
- <release version="0.7" date="2008-12-20" description="Improve test coverage">
- <action dev="py4fun" type="update">
- Improve test coverage for constructor package (2008-12-20)
- </action>
- <action dev="py4fun" type="remove">
- Remove support for "value" type because it is not used (2008-12-20)
- </action>
- <action dev="py4fun" type="update">
- Require test coverage 95% (2008-12-19)
- </action>
- <action dev="py4fun" type="update">
- Improve test coverage for Nodes (2008-12-19)
- </action>
- <action dev="py4fun" type="fix">
- Fix dumping Date and better coverage for Representer (2008-12-19)
- </action>
- <action dev="py4fun" type="remove">
- Remove unused code based on coverage report (2008-12-19)
- </action>
- <action dev="py4fun" type="remove">
- Tokens are 100% covered by tests (2008-12-19)
- </action>
- <action dev="py4fun" type="remove">
- Remove old tests (2008-12-18)
- </action>
- <action dev="py4fun" type="update">
- Synchronized with PyYAML revision 307
- </action>
- </release>
- <release version="0.6" date="2008-12-17" description="Documentation added">
- <action dev="py4fun" type="add">
- Many examples added to the Wiki page (2008-12-17)
- </action>
- <action dev="py4fun" type="update">
- Public interface is using Iterator instead of Iterable (2008-12-17)
- </action>
- <action dev="py4fun" type="update">
- Sort names when JavaBeans are represented (2008-12-15)
- </action>
- <action dev="py4fun" type="fix">
- defaultFlowStyle for Dumper is configurable in DumperOptions (2008-12-12)
- </action>
- </release>
- <release version="0.5" date="2008-12-12" description="Import PyYAML 3.06">
- <action dev="py4fun" type="add">
- Add possibility to define an implicit resolver. {359:63190d5bcd10} (2008-12-11)
- </action>
- <action dev="py4fun" type="add">
- Add possibility to define an explicit constructor. {356:ccaa0df9ca98} (2008-12-11)
- </action>
- <action dev="py4fun" type="update">
- Java objects can be constructed from mapping (JavaBeans), from sequence (constructor)
- from scalar (constructor). (2008-12-10)
- </action>
- <action dev="py4fun" type="fix">
- pairs tag works properly. (2008-12-08)
- </action>
- <action dev="py4fun" type="fix">
- omap tag works properly. (2008-12-08)
- </action>
- <action dev="py4fun" type="add">
- Implement possibility to define a custom Map implementation {332}. (2008-12-06)
- </action>
- <action dev="py4fun" type="add">
- Implement possibility to define a custom List implementation {331:72c03254c184}. (2008-12-06)
- </action>
- <action dev="py4fun" type="add">
- Path resolver is removed because it is not imported properly {330}. (2008-12-06)
- </action>
- <action dev="py4fun" type="add">
- Constructor is overwritten completely. (2008-12-06)
- </action>
- <action dev="py4fun" type="add">
- Implement possibility to define a custom Representer. (2008-12-01)
- </action>
- <action dev="py4fun" type="update">
- Support arrays of reference types. Arrays of primitives are not supported
- because Arrays.asList() does not work. (2008-12-01)
- </action>
- <action dev="py4fun" type="update">
- Import change 300 for Emitter from PyYAML. (2008-12-01)
- </action>
- <action dev="py4fun" type="fix">
- Fix Node identity to avoid aliases for simple types - [1, 1]. (2008-11-28)
- </action>
- <action dev="py4fun" type="update">
- Recursive objects can be represented (but not yet constructed) (2008-11-28)
- </action>
- <action dev="py4fun" type="update">
- Binary is represented back as String (2008-11-28)
- </action>
- <action dev="py4fun" type="update">
- Re-write Representer classes from scratch (2008-11-28)
- </action>
- <action dev="py4fun" type="fix">
- 'null' can be a key in a map (2008-11-21)
- </action>
- <action dev="py4fun" type="fix">
- !!set tag is parsed properly (2008-11-21)
- </action>
- <action dev="py4fun" type="update">
- Single characters 'Y', 'N', 'y' and 'n' are parsed as String opposed to boolean
- as it is defined in the specification. This is how it is done in PyYAML (2008-11-21)
- </action>
- <action dev="py4fun" type="remove">
- Constructor: because Java does not have generators 'deep' is not
- imported from PyYAML (2008-11-19)
- </action>
- <action dev="py4fun" type="update">
- Composer imported from PyYAML (2008-11-17)
- </action>
- <action dev="py4fun" type="update">
- Resolver.resolve() is using simple boolean argument instead of array of booleans
- as in PyYAML. (2008-11-18)
- </action>
- <action dev="py4fun" type="fix">
- Fix: 'set' type works. (2008-11-18)
- </action>
- <action dev="py4fun" type="update">
- Rewrite Parser from scratch. (2008-11-17)
- </action>
- </release>
- <release version="0.4" date="2008-11-11" description="Fix issues in Scanner">
- <action dev="py4fun" type="update">
- Move constants from Yaml interface to appropriate classes (2008-11-10)
- </action>
- <action dev="py4fun" type="update">
- Interface change: Yaml dumpAll() methods accept Iterable (2008-11-10)
- </action>
- <action dev="py4fun" type="update">
- Interface change: Yaml loadAll() methods return Iterable (2008-11-10)
- </action>
- <action dev="py4fun" type="fix">
- Scanner: copy keys to avoid java.util.ConcurrentModificationException when removing
- possible simple key (2008-11-10)
- </action>
- <action dev="py4fun" type="update">
- Tag v0.3.1 (2008-11-08)
- </action>
- <action dev="py4fun" type="update">
- MappingNode requires Map as a value and SequenceNode requires
- List as a value (2008-11-08)
- </action>
- <action dev="py4fun" type="update">
- Marks in a Token are required (2008-11-08)
- </action>
- <action dev="py4fun" type="remove">
- Remove prefixForward() method from Reader because it is not present
- in PyYAML (2008-11-08)
- </action>
- <action dev="py4fun" type="fix">
- Fix a deviation with PyYAML in method scanBlockScalar().
- 'chomping' can be null. Fix a bug in JvYaml that the trailing '\n' in a
- block scalar was removed.(2008-11-07)
- </action>
- <action dev="py4fun" type="fix">
- Fix a deviation with PyYAML in method scanDirectiveIgnoredLine().
- Put '#' instead of '"'. (2008-11-07)
- </action>
- <action dev="py4fun" type="add">
- Restore from PyYAML the way the keys are parsed. (Restored methods are
- stalePossibleSimpleKeys() and removePossibleSimpleKey().)
- Fix issue http://code.google.com/p/jvyamlb/issues/detail?id=6. (2008-11-07)
- </action>
- <action dev="py4fun" type="update">
- Refactor: put changed classes to 'org.yaml.snakeyaml' package. (2008-11-05)
- </action>
- <action dev="py4fun" type="update">
- Move all the main() methods to the corresponding test classes. (2008-11-05)
- </action>
- <action dev="py4fun" type="update">
- Change public interface. Rename YAML to Yaml. Remove all static methods from Yaml.
- Factory and configuration must be injected at the constructor. This way is closer
- to PyYAML API. (2008-11-05)
- </action>
- <action dev="py4fun" type="add">
- Reader as in PyYAML is implemented. BOM is properly supported (2008-11-05)
- </action>
- <action dev="py4fun" type="add">
- Restore Mark in Token as it is in PyYAML. Mark is not defined yet (2008-10-30)
- </action>
- <action dev="py4fun" type="fix">
- Off-by-one in EmitterImpl.writeDoubleQuoted().
- Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=11 (2008-10-28)
- </action>
- <action dev="py4fun" type="fix">
- Respect Unicode characters.
- Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=10 (2008-10-28)
- </action>
- <action dev="py4fun" type="fix">
- Respect sign for float.
- Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=13 (2008-10-28)
- </action>
- <action dev="py4fun" type="add">
- Binary data is represented as ByteBuffer (2008-10-27)
- </action>
- <action dev="py4fun" type="fix">
- When parsed, a timestamp in the canonical form (i.e, 2001-12-15T02:59:43.1Z) is
- interpreted as if it is in the default time zone.
- Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=7 (2008-10-27)
- </action>
- <action dev="py4fun" type="add">
- Add Mark from PyYAML. It is not used yet. The JUnit test is migrated from PyYAML (2008-10-23)
- </action>
- <action dev="py4fun" type="update">
- Apply SnakeYAML as the name of the library (2008-10-22)
- </action>
- <action dev="py4fun" type="update">
- Reformat the source files (2008-10-22)
- </action>
- <action dev="py4fun" type="update">
- Apply LICENSE info to source files (2008-10-22)
- </action>
- <action dev="py4fun" type="update">
- Mavenize project. Apply standard Maven folder structure (2008-10-20)
- </action>
- </release>
- <release version="0.2.1" date="2008-10-20" description="Import JvYaml from CVS">
- <action dev="py4fun" type="add">
- Import project from https://jvyaml.dev.java.net/ (2008-10-20)
- </action>
- </release>
- </body>
-</document>
-
+<document xmlns="http://maven.apache.org/changes/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+ <properties>
+ <title>YAML 1.1 parser and emitter</title>
+ <author email="py4fun@gmail.com">Andrey Somov</author>
+ </properties>
+ <body>
+ <release version="1.10-SNAPSHOT" date="in Mercurial" description="Development">
+ <action dev="py4fun" type="add">
+ Use http://mercurial.selenic.com/wiki/EolExtension to force LF as line separator
+ for all operating systems (2011-12-20)
+ </action>
+ <action dev="py4fun" type="add">
+ Add a test for issue 136 (2011-12-14)
+ </action>
+ <action dev="py4fun" type="remove">
+ Deprecate the DumperOptions.calculateScalarStyle() method because it was introduced as a quick
+ fix for issue 29. Now it should not be required at all (because of the fix for issue 66),
+ or it should be implemented in the Representer (in RepresentString) (2011-10-10)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix issue 66: literal scalar style is used by default for multiline scalars (2011-10-10)
+ </action>
+ <action dev="py4fun" type="add">
+ An example added: how to dump multiline literal scalars (2011-10-04)
+ </action>
+ <action dev="py4fun" type="add">
+ An example added: how to dump recursive object for issue 133 (2011-09-14)
+ </action>
+ <action dev="py4fun" type="add">
+ A test added for issue 132 (2011-09-13)
+ </action>
+ <action dev="py4fun" type="update">
+ Finish 1.9 release (2011-08-15)
+ </action>
+ </release>
+ <release version="1.9" date="2011-08-15" description="Introduce Yaml.loadAs() and Yaml.dumpAs() methods">
+ <action dev="py4fun" type="update">
+ Add a test to prove that SnakeYAML is not affected by the problem reported for libyaml
+ at http://pyyaml.org/ticket/196 (2011-07-28)
+ </action>
+ <action dev="py4fun" type="fix" issue="128">
+ Since timestamp contains ':' characters it is dumped with single quoted scalar style
+ in the flow context. The single quoted scalar style causes to dump the explicit tag.
+ In the block context the plain scalar can be used and the tag is not required. It may cause
+ unpredictable behaviour if the tag is required. See the comments in JodaTimeExampleTest (2011-07-25)
+ </action>
+ <action dev="py4fun" type="fix" issue="130">
+ Fix scientific notation inconsistency in the YAML 1.1 specification:
+ scalar '8e-06' should be parsed as a Double (2011-07-24)
+ </action>
+ <action dev="py4fun" type="remove" issue="127">
+ Do not allow to override BaseRepresenter.representData(Object data) because
+ users should instead implement Represent interface (2011-07-21)
+ </action>
+ <action dev="py4fun" type="remove" issue="124">
+ Deprecate DumperOptions.explicitRoot (2011-07-20)
+ </action>
+ <action dev="py4fun" type="add" issue="124">
+ Add Yaml.dumpAs(Object, Tag.MAP, FlowStyle) and Yaml.dumpAsMap(Object) methods. JavaBeanDumper is marked as deprecated (2011-07-16)
+ </action>
+ <action dev="py4fun" type="add" issue="127">
+ Add example to show how to dump a custom class (2011-07-12)
+ </action>
+ <action dev="py4fun" type="add" issue="129">
+ Add Yaml.serialize(Node) low level method to the public API (2011-07-14)
+ </action>
+ <action dev="py4fun" type="add" issue="129">
+ Add Yaml.represent(Object) low level method to the public API (2011-07-14)
+ </action>
+ <action dev="py4fun" type="add" issue="125">
+ Add support for Maven 3 via 'm3' profile (2011-07-10)
+ </action>
+ <action dev="py4fun" type="remove" issue="124">
+ Remove deprecated JavaBeanParser (2011-07-05)
+ </action>
+ <action dev="py4fun" type="remove" issue="124">
+ Remove redundant JavaBeanDumper.classTags set (2011-07-03)
+ </action>
+ <action dev="py4fun" type="add" issue="124">
+ Add Yaml.loadAs() methods. JavaBeanLoader is marked as deprecated (2011-07-03)
+ </action>
+ <action dev="py4fun" type="remove" issue="124">
+ Remove TypeDescription.root property to prepare issue 124. This is a minor backwards incompatible change.
+ Now instead of setting as root, the TypeDescription must be passed to the Contructor's constructor
+ to be taken as the root definition (2011-07-03)
+ </action>
+ <action dev="py4fun" type="fix" issue="121" due-to="Jaromir">
+ Fix: close files in tests to avoid a possible file handle limit (2011-06-09)
+ </action>
+ <action dev="py4fun" type="fix" issue="116" due-to="Jim Peterson">
+ Fix: Improved support for empty JavaBeans (2011-06-09)
+ </action>
+ <action dev="py4fun" type="fix" issue="112" due-to="Lethargish">
+ Fix: Improved support for parameterised types in collections (2011-05-25)
+ </action>
+ <action dev="py4fun" type="fix" issue="115" due-to="elkniwt">
+ Fix: parameterised JavaBeans fail to load and dump because they are treated as Maps (2011-05-16)
+ </action>
+ <action dev="py4fun" type="fix" issue="114" due-to="gileadis">
+ Fix: Do not remove root tags of JavaBeans when it is not explicitly requested (2011-04-20)
+ </action>
+ <action dev="py4fun" type="fix" issue="111" due-to="JordanAngold">
+ Fix: Long escaped tag URI sequences throw BufferOverflowException (2011-03-03)
+ </action>
+ <action dev="py4fun" type="fix" issue="110" due-to="dmitry.s.mamonov">
+ Fix: introduce a package for external libraries and move there the 64Coder
+ and the Google's URL encoder (2011-02-24)
+ </action>
+ <action dev="py4fun" type="fix" issue="109" due-to="cjalmeida">
+ Fix: ancient years must be dumped with leading zeros (2011-02-19)
+ </action>
+ <action dev="py4fun" type="remove" due-to="JordanAngold">
+ Remove unused code in Constructor: Modifier.isAbstract() is not needed any more (2011-02-18)
+ </action>
+ <action dev="JordanAngold" type="fix" issue="108">
+ Enum's name property shall be dumped instead of the 'toString()' output (2011-02-16)
+ </action>
+ </release>
+ <release version="1.8" date="2011-02-15" description="Performance improvement">
+ <action dev="py4fun" type="add">
+ Add example to howto Wiki:
+ How_to_substitute_object_in_YAML_document_with_a_custom_object (2011-01-27)
+ </action>
+ <action dev="py4fun" type="update">
+ When the YAML document to be loaded is provided as String parse it directly
+ without making a Reader first (2011-01-23)
+ </action>
+ <action dev="py4fun" type="fix" issue="106">
+ Immutable data structures in StreamReader allow to share the same buffer for all
+ the Mark instances. It makes 'withMarkContext' setting redundant (2011-01-19)
+ </action>
+ <action dev="maslovalex" type="update" issue="100">
+ Merge JavaBean properties when an explicit tag is provided (2011-01-11)
+ </action>
+ <action dev="py4fun" type="update" issue="99">
+ Add an example for escaping line breaks in binary content (2011-01-03)
+ </action>
+ <action dev="py4fun" type="update" issue="97">
+ Propose a solution for JavaBeans to support SortedSet property when it is encoded
+ as a sequence (2010-11-24)
+ </action>
+ <action dev="py4fun" type="update" issue="59">
+ Simplify the way how the order of JavaBean properties is specified. Introduce
+ PropertyUtils.createPropertySet() method to be overridden when a specific order
+ is expected (2010-11-23)
+ </action>
+ <action dev="maslovalex" type="fix" issue="95">
+ Fix: Loading of generic collections with Array parameter(s). (2010-11-16)
+ </action>
+ <action dev="py4fun" type="update" issue="94">
+ Add ChangeRuntimeClassTest as an example how to change a class for a global tag (2010-11-05)
+ </action>
+ <action dev="py4fun" type="update">
+ Inner objects in Constructor become protected to be more flexible when Constructor
+ is expended (2010-10-03)
+ </action>
+ <action dev="py4fun" type="update" issue="91">
+ Apply www.snakeyaml.org domain name (2010-09-20)
+ </action>
+ <action dev="py4fun" type="fix" issue="90">
+ Move Base64Coder into another package to keep a separate copyright statement.
+ Base64Coder is left unchanged (2010-09-19)
+ </action>
+ <action dev="py4fun" type="fix" issue="69">
+ Iterable should not be serialised as sequence (2010-09-16)
+ </action>
+ <action dev="py4fun" type="update">
+ Introduce 'fast' Maven profile to quickly build cobertura reports (2010-09-16)
+ </action>
+ <action dev="py4fun" type="update" issue="89">
+ Fix: Specify plugin versions in POM (2010-09-15)
+ </action>
+ <action dev="maslovalex" type="fix" issue="88">
+ Fix: Custom tag erased when referenced from generic collection (2010-09-15)
+ </action>
+ <action dev="py4fun" type="update">
+ Minor refactoring in Emitter to improve performance: save calls to Constant.has() (2010-09-13)
+ </action>
+ <action dev="maslovalex" type="update">
+ Minor refactorings in Emitter to improve performance: create less Strings [r9185e0b3] (2010-09-10)
+ </action>
+ <action dev="py4fun" type="update" issue="79">
+ Introduce LoaderOptions to be able to specify configuration while loading (2010-09-03)
+ </action>
+ <action dev="py4fun" type="fix" issue="81">
+ Representer.representJavaBeanProperty() is given the wrong tag. Instead of the property tag,
+ the tag for the JavaBean itself is provided. (2010-09-01)
+ </action>
+ <action dev="py4fun" type="update">
+ Rename JvmDetector into GenericsBugDetector (2010-08-31)
+ </action>
+ <action dev="py4fun" type="fix" issue="80" due-to="SebastienRainville">
+ Fix: Timestamp is not parsed properly when milliseconds start with 0 (2010-08-24)
+ </action>
+ <action dev="maslovalex" type="update" issue="79">
+ Context for error reporting consumes a lot of resources (2010-08-21)
+ </action>
+ <action dev="py4fun" type="remove">
+ Cleanup unused code in deprecated Loader and Dumper (2010-08-13)
+ </action>
+ </release>
+ <release version="1.7" date="2010-08-12" description="Simplify public API (drop Loader and Dumper)">
+ <action dev="py4fun" type="update">
+ Eclipse does not run JUnit 4 tests when they are launched for the whole project (2010-08-11)
+ </action>
+ <action dev="maslovalex" type="update" issue="55">
+ Share PropertyUtils if not explicitly set in Constructor or Representer
+ (BeanAccess.FIELD works properly when JavaBean is identified by a root tag) (2010-08-11)
+ </action>
+ <action dev="py4fun" type="update">
+ Create 1.7 Release Candidate 1 (2010-08-11)
+ </action>
+ <action dev="py4fun" type="update" issue="77">
+ Simplify public API: Drop Dumper (2010-08-06)
+ </action>
+ <action dev="py4fun" type="update" issue="77">
+ Simplify public API: Drop Loader (2010-08-05)
+ </action>
+ <action dev="py4fun" type="update" issue="75" due-to="jon.p.hermes">
+ Add examples to create scalars that match custom regular expression:
+ CustomImplicitResolverTest, CustomBeanResolverTest (2010-08-03)
+ </action>
+ <action dev="py4fun" type="fix" issue="74" due-to="Kevin Menard">
+ Do not use redundant tags for arrays which are JavaBean properties. (2010-07-21)
+ </action>
+ <action dev="py4fun" type="update">
+ RecursiveSetTest proves that it is possible to construct a recursive set (2010-07-20)
+ </action>
+ <action dev="py4fun" type="add" issue="73" due-to="birnbuazn">
+ Provide sequence support for loading java.util.Set. Also provide an example
+ to serialise a java.util.Set as a sequence. (2010-07-19)
+ </action>
+ <action dev="py4fun" type="add" issue="72" due-to="birnbuazn">
+ Support java.util.Collection as a parent for List and Set (2010-07-09)
+ </action>
+ <action dev="maslovalex" type="add" issue="55" due-to="birnbuazn">
+ Allow direct field access bypassing setters and getters. Empty constructor
+ is required to support 2-step construction (2010-07-02)
+ </action>
+ <action dev="py4fun" type="update" issue="69">
+ Serialise Iterator and Iterable as sequences (2010-06-25)
+ </action>
+ <action dev="py4fun" type="update" due-to="maslovalex">
+ Change error message when 'No suitable constructor with N arguments found for class' (2010-06-23)
+ </action>
+ <action dev="py4fun" type="add" due-to="Antony Stubbs">
+ Add JodaTime example (2010-06-04)
+ </action>
+ <action dev="py4fun" type="add" issue="67" due-to="Manuel Sugawara">
+ Add possibility to create a Tag out of an URI (2010-05-31)
+ </action>
+ <action dev="py4fun" type="update">
+ URLDecoder.decode() does not fail when UTF-8 is invalid. Use
+ CodingErrorAction.REPORT to implement the failure (2010-05-21)
+ </action>
+ <action dev="maslovalex" type="update">
+ Fix generic collections which contain other collections (2010-05-18)
+ </action>
+ <action dev="py4fun" type="fix" issue="67" due-to="Manuel Sugawara">
+ Fix: java classes containing non-ASCII characters in names are
+ incorrectly encoded (2010-05-14)
+ </action>
+ <action dev="py4fun" type="fix" issue="65" due-to="lerch.johannes">
+ Fix: add checks for null arguments for JavaBeanDumper (2010-04-27)
+ </action>
+ <action dev="py4fun" type="add">
+ Add a test to see how stack trace is serialised (2010-04-27)
+ </action>
+ <action dev="py4fun" type="fix" issue="64" due-to="maxim.moschko">
+ ClassCastException in Representer when working with ParameterizedType (2010-04-25)
+ </action>
+ <action dev="py4fun" type="update">
+ Improve toString() method for Node. Since scalars cannot be recursive
+ they can be printed (2010-04-15)
+ </action>
+ <action dev="maslovalex" type="fix" issue="63" due-to="Udo">
+ Refactor the way arrays are constructed (2010-04-15)
+ </action>
+ <action dev="py4fun" type="fix" issue="62">
+ Add examples for dumping custom values for !!bool and !!null (2010-04-13)
+ </action>
+ <action dev="py4fun" type="fix" issue="61">
+ Fix: ClassCastException when dumping generic bean (2010-04-11)
+ </action>
+ <action dev="py4fun" type="fix" issue="59">
+ Provide an example for changing JavaBean properties order (2010-04-01)
+ </action>
+ <action dev="py4fun" type="fix" issue="60">
+ Provide example for skipping null and empty collections (2010-03-29)
+ </action>
+ <action dev="py4fun" type="fix" issue="58" due-to="jeff.caulfield">
+ JavaBeanDumper.dump throws NullPointerException on list property
+ with null element (2010-03-23)
+ </action>
+ <action dev="py4fun" type="fix" issue="56" due-to="DZeiss">
+ Make constructors in SafeConstructor public (2010-03-16)
+ </action>
+ <action dev="py4fun" type="update" due-to="David Bernard">
+ Releases and snapshots are available in the Sonatype Maven repository.
+ https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide
+ </action>
+ <action dev="obastard" type="fix" issue="53" due-to="obastard">
+ Enhancement for a pretty format that combines BLOCK and FLOW (2010-03-03)
+ </action>
+ <action dev="py4fun" type="fix" issue="50" due-to="sualeh.fatehi">
+ Unable to dump JavaBean that inherits from a protected base class (2010-03-02)
+ </action>
+ <action dev="py4fun" type="update">
+ Format source (2010-03-01)
+ </action>
+ <action dev="py4fun" type="update">
+ Use Token.ID and Event.ID instead of just ID (2010-03-01)
+ </action>
+ <action dev="py4fun" type="update">
+ Issue 50 fails in Eclipse but works with Maven (2010-03-01)
+ </action>
+ </release>
+ <release version="1.6" date="2010-02-26" description="introduce Tag class">
+ <action dev="py4fun" type="update">
+ Release Candidate 2 is available (2010-02-24)
+ </action>
+ <action dev="py4fun" type="fix" issue="47" due-to="obastard">
+ Don't dump read-only properties by default. DumperOptions gets a setting to
+ include read-only JavaBean properties.
+ This is no backwards compatible change (2010-02-19)
+ </action>
+ <action dev="py4fun" type="fix" issue="49" due-to="obastard">
+ Support GregorianCalendar. Due to Daylight Saving Time parsing the timestamp with
+ a TimeZone cannot determine the exact time (2010-02-19)
+ </action>
+ <action dev="py4fun" type="fix" issue="51" due-to="johann.Werner">
+ Some Unicode characters are wrongly replaced by \x{fffd} during
+ double quoted style dump (2010-02-15)
+ </action>
+ <action dev="py4fun" type="fix" issue="48" due-to="obastard">
+ Introduce representJavaBeanProperty() method in Representer. The method
+ can be overridden to simplify custom JavaBean representation (2010-02-12)
+ </action>
+ <action dev="py4fun" type="update">
+ Release Candidate 1 is available (2010-02-01)
+ </action>
+ <action dev="py4fun" type="add">
+ Representer.representJavaBean() returns MappingNode (2010-01-26)
+ </action>
+ <action dev="py4fun" type="add">
+ Add example of serialising static fields (2010-01-26)
+ </action>
+ <action dev="py4fun" type="add">
+ Add example of serialising java.io.File as scalar node for issue 46 (2010-01-25)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: introduce Chomping to avoid using null as value for Boolean.
+ Stay in line with Scala port where null is not allowed (2010-01-19)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use Event.ID enum instead of classes (2010-01-15)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use Token.ID enum instead of classes (2010-01-15)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use generic classes for DirectiveToken (2010-01-14)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: rename Reader to StreamReader to avoid name conflict with java.io.Reader (2010-01-13)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use StringBuilder instead of StringBuffer (2010-01-12)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: introduce Constant class to share String constants (2010-01-12)
+ </action>
+ <action dev="py4fun" type="update">
+ Keep Tag.equals(String) to simplify transition to Tag class (2010-01-08)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: introduce Tag instead of Tags. Nodes use Tag class instead of String (2010-01-05)
+ </action>
+ <action dev="py4fun" type="fix" issue="42" due-to="Artem">
+ BaseConstructor shall give more flexibility to choose a constructor at runtime (2010-01-08)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: introduce TagTuple instead of String[] (2010-01-04)
+ </action>
+ <action dev="py4fun" type="fix" issue="40" due-to="sitrious">
+ Ignore tags when they are compatible with the runtime class (2010-01-04)
+ </action>
+ <action dev="py4fun" type="add">
+ Add example to ignore unknown tags (2009-12-08)
+ </action>
+ <action dev="py4fun" type="add">
+ Add Ruby example (2009-12-08)
+ </action>
+ <action dev="py4fun" type="update">
+ Do not omit the tag for JavaBean properties when the tag is explicitly defined (2009-12-08)
+ </action>
+ <action dev="py4fun" type="fix" issue="38" due-to="gchpaco">
+ Fix ID format for numbers over 999 (2009-12-05)
+ </action>
+ <action dev="py4fun" type="fix" issue="29" due-to="grignaak">
+ Allow separate option in DumperOptions for long strings (2009-11-16)
+ </action>
+ <action dev="py4fun" type="add">
+ JavaBeanDumper: add possibility to define a custom Representer (2009-11-25)
+ </action>
+ <action dev="py4fun" type="fix" issue="36">
+ Introduce multi contructors (tag prefix). A family of tags may be processed
+ by a single constructor (2009-11-25)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor BaseConstructor: simplify second step for recursive structures (2009-11-25)
+ </action>
+ <action dev="py4fun" type="add">
+ Add FilterPropertyToDumpTest to show how to filter JavaBean properties (2009-11-24)
+ </action>
+ <action dev="py4fun" type="add">
+ Add FilterClassesConstructorTest to show how to filter created classes (2009-11-16)
+ </action>
+ <action dev="py4fun" type="update" due-to="Stefan">
+ Improve JavaDoc (2009-11-12)
+ </action>
+ <action dev="py4fun" type="add">
+ Add Velocity example (2009-11-03)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: rename Tuple to RecursiveTuple and hide it inside BaseConstructor (2009-11-03)
+ </action>
+ </release>
+ <release version="1.5" date="2009-10-30" description="Improve usage of generic collections in JavaBeans">
+ <action dev="py4fun" type="fix" issue="27" due-to="Polyglot Maven team">
+ Extend Resolver to support custom implicit types (2009-10-27)
+ </action>
+ <action dev="py4fun" type="update">
+ Performance improvement: use ArrayStack instead of Stack which extends Vector (2009-10-20)
+ </action>
+ <action dev="py4fun" type="fix" issue="25" due-to="Benjamin Bentmann">
+ Improve usage of generic collections: while type erase makes no difference between
+ Class< Foo> and Class< Bar> at runtime, the information about generics is still
+ accessible via reflection from Method/Field. (2009-10-19)
+ </action>
+ <action dev="py4fun" type="update">
+ Fix ConstructYamlObject: support recursive objects. Introduce 'resolved'
+ property for Nodes. This property supposed to help to distinguish explicit tag
+ from the resolved tag (2009-10-19)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use rootTag instead of rootType (for Class) in BaseConstructor. This is done to
+ solve the priority problem: normally explicit tag has more priority then runtime class but
+ for the root tag it is the other way around (2009-10-19)
+ </action>
+ <action dev="py4fun" type="fix" issue="24" due-to="shrode">
+ Line numbers reported in Exceptions are Zero based, should be 1 based (2009-10-12)
+ </action>
+ <action dev="py4fun" type="fix" issue="21" due-to="ashwin.jayaprakash">
+ Support arrays of reference types as JavaBean properties (2009-09-22)
+ </action>
+ <action dev="py4fun" type="fix" issue="17" due-to="jcucurull">
+ Respect root tag for sequences (2009-09-04)
+ </action>
+ <action dev="py4fun" type="fix" issue="18" due-to="creiniger">
+ SafeRepresenter respects custom tags for standard Java classes where standard tag has
+ more then one Java implementation available (Long, List, Map, Date etc) (2009-09-03)
+ </action>
+ <action dev="py4fun" type="add">
+ Add possibility to define a custom Class Loader. (2009-09-01)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fixed an obscure scanner error not reported when there is no line break at the end
+ of the stream. The fix is imported from PyYAML 3.09 {ticket 118} (2009-08-31)
+ </action>
+ <action dev="py4fun" type="fix" issue="16" due-to="infinity0x">
+ Cache JavaBean class properties. Tests show that the loading has become a few percents faster (2009-08-31)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce ArrayStack to use push() and pop() instead of standard (and too verbose)
+ 'remove(size()-1)' (2009-08-27)
+ </action>
+ <action dev="py4fun" type="fix" issue="14" due-to="infinity0x">
+ Fix: ArrayList is more efficient than LinkedList (2009-08-26)
+ </action>
+ </release>
+ <release version="1.4" date="2009-08-26" description="better support for loading immutable objects">
+ <action dev="py4fun" type="update">
+ Apply Apache License Version 2.0 (2009-08-14)
+ </action>
+ <action dev="py4fun" type="fix" issue="13" due-to="infinity0x">
+ Provide javadocs link to Sun Java API (2009-08-10)
+ </action>
+ <action dev="py4fun" type="add">
+ Build 1.4 Release Candidate 1 (2009-08-07)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce Tags.getGlobalTagForClass() to simplify tag generation in custom constructors (2009-08-06)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: introduce ImplicitTuple (2009-08-06)
+ </action>
+ <action dev="py4fun" type="fix" issue="11" due-to="infinity0x">
+ Fix: create a Java instance with the following priority to choose the class:
+ Explicit tag -> Runtime class (defined in JavaBean) -> implicit tag (2009-08-06)
+ </action>
+ <action dev="py4fun" type="fix" issue="9" due-to="wwagner4">
+ Fix: Bean with no property cannot be instantiated. This is implemented via better
+ support for immutable objects. Custom Constructor may be used when there are more
+ then 1 way to create an instance (2009-08-04)
+ </action>
+ <action dev="py4fun" type="add">
+ Deliver possibility to load immutable instances with no global tags. Reflection for
+ constructor arguments is used to get the runtime classes (2009-08-04)
+ </action>
+ <action dev="py4fun" type="update">
+ Use more informative error message when a JavaBean property cannot
+ be created (2009-08-02)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: Constructor is rewritten. Do not overwrite methods from BaseConstructor.
+ Instead introduce ConstructScalar, ConstructSequence, ConstructMapping (2009-07-31)
+ </action>
+ <action dev="py4fun" type="update">
+ Change Maven repository path: groupId='org.yaml', artifactId='snakeyaml' (2009-07-31)
+ </action>
+ <action dev="py4fun" type="fix" issue="10" due-to="derrick.rice">
+ Fix: dump omits JavaBean class name when used with an alias (2009-07-28)
+ </action>
+ <action dev="py4fun" type="add">
+ Generate sources and Javadoc (2009-07-27)
+ </action>
+ <action dev="py4fun" type="update">
+ Node does not have the value. It is delegated to the non-abstract classes (2009-07-27)
+ </action>
+ <action dev="py4fun" type="add">
+ Extends JavaBeanDumper to allow skipping global tags inside type-safe collections.
+ Introduce method setMapTagForBean() (2009-07-22)
+ </action>
+ <action dev="py4fun" type="add">
+ Add ConstructEmptyBeanTest to test JavaBean construction with no
+ properties in the YAML document(2009-07-22)
+ </action>
+ <action dev="py4fun" type="remove">
+ Refactor: redesign tag management for JavaBeans in Representer.
+ Drop dynamic root tag concept (2009-07-22)
+ </action>
+ <action dev="py4fun" type="remove">
+ Remove unused TypeDescription in Representer (2009-07-21)
+ </action>
+ <action dev="py4fun" type="update">
+ Use NodeTuple instead of Node[] for mappings (2009-07-21)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce JavaBeanLoader and JavaBeanDumper. Deprecate JavaBeanParser (2009-07-21)
+ </action>
+ <action dev="py4fun" type="fix" issue="8" due-to="Alan Gutierrez">
+ Fix: Representer was keeping state between invocations (2009-07-21)
+ </action>
+ </release>
+ <release version="1.3" date="2009-07-20" description="complete support for recursive objects">
+ <action dev="py4fun" type="fix" issue="6" due-to="infinity0x">
+ Fix: values returned by System.identityHashCode() are not guaranteed to be unique (2009-07-14)
+ </action>
+ <action dev="py4fun" type="add">
+ Add a simple test for Java Generics (BirdTest). Unfortunately it shows that some JVM
+ implementations do not recognise classes for JavaBean properties at runtime.
+ It leads to unnecessary global tags. See http://code.google.com/p/snakeyaml/wiki/Documentation#Generics
+ for details (2009-07-13)
+ </action>
+ <action dev="py4fun" type="fix" issue="5" due-to="infinity0x">
+ Fix: set the "cause" field for MarkedYAMLException (2009-07-10)
+ </action>
+ <action dev="maslovalex" type="fix" issue="1">
+ Fix: Recursive objects are now fully supported (2009-07-09)
+ </action>
+ <action dev="py4fun" type="add">
+ Add support for BigDecimal as a JavaBean property (2009-07-07)
+ </action>
+ <action dev="py4fun" type="update">
+ Improve test coverage for Constructor. Allow construction of JavaBeans
+ with only setter without the corresponding getter (2009-07-07)
+ </action>
+ <action dev="py4fun" type="add">
+ Add a test to check the proper report for IOException (2009-07-03)
+ </action>
+ <action dev="py4fun" type="fix" issue="3" due-to="infinity0x">
+ Fix: represent proper tags for JavaBeans when they are not the root of the YAML
+ document but a member of a collection (2009-07-03)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: run PMD and apply some of the recommendations (2009-06-18)
+ </action>
+ <action dev="py4fun" type="add" issue="1">
+ Create an issue for Recursive objects to be remembered (2009-06-08)
+ </action>
+ <action dev="py4fun" type="update">
+ Migrate project hosting from Assembla to Google code (2009-06-08)
+ </action>
+ <action dev="py4fun" type="fix" due-to="Magne">
+ Fix: null as a JavaBean property was not handled properly (2009-06-04)
+ </action>
+ <action dev="py4fun" type="update">
+ Validate changes.xml file (2009-05-25)
+ </action>
+ <action dev="py4fun" type="fix" due-to="Magne">
+ Fix ticket 40 in Assembla: getting an error when javabean contains java.sql.Timestamp fields (2009-05-25)
+ </action>
+ </release>
+ <release version="1.2" date="2009-04-27" description="expose low-level API">
+ <action dev="py4fun" type="add">
+ Add 'Yaml.parse()' method which return Events to support low level YAML processing (2009-04-20)
+ </action>
+ <action dev="py4fun" type="add" due-to="Bob Jalex">
+ Introduce LineBreak.getPlatformLineBreak (ticket 5 in Assembla) (2009-04-18)
+ </action>
+ <action dev="py4fun" type="update" due-to="Bob Jalex">
+ Rename LineBreak.LINUX to LineBreak.UNIX (ticket 5 in Assembla) (2009-04-18)
+ </action>
+ <action dev="py4fun" type="add">
+ Add 'Yaml.compose()' methods which return Nodes to support YEdit (2009-04-17)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: rename enums in DumperOptions to make the names consistent (2009-04-07)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use Character instead of char primitive for style in Emitter (2009-04-07)
+ </action>
+ <action dev="py4fun" type="add">
+ Add possibility to parse all scalars as Strings (2009-03-30)
+ </action>
+ <action dev="py4fun" type="update">
+ Merge changeset 347 from PyYAML (2009-03-30)
+ </action>
+ <action dev="py4fun" type="fix">
+ Respect DumperOptions with a custom Representer (2009-03-18)
+ </action>
+ <action dev="py4fun" type="fix">
+ Represent TAB as '\t' instead of '(9' in the error message (2009-03-17)
+ </action>
+ </release>
+ <release version="1.1" date="2009-03-14" description="improve performance and test coverage">
+ <action dev="py4fun" type="add">
+ Introduce JavaBeanParser (2009-03-14)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce DumperOptions.Version enum (2009-03-13)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce DumperOptions.LineBreak enum (2009-03-10)
+ </action>
+ <action dev="py4fun" type="update">
+ Use byte[] for binary type. (2009-03-09)
+ </action>
+ <action dev="py4fun" type="update">
+ Restore Regular Expressions in Resolver. Ragel gives only 5% performance increase.
+ Fix a bug in Resolver with expanded regular expressions which caused the
+ performance problem. (2009-03-06)
+ </action>
+ <action dev="py4fun" type="add">
+ Better Spring support: it is now possible to create a constructor with a String
+ as the class name. (2009-03-05)
+ </action>
+ <action dev="py4fun" type="update">
+ Throw an exception when the same Loader or Dumper instance is shared between
+ different Yaml instances. Because they are statefull it is not Thread-safe. (2009-03-05)
+ </action>
+ <action dev="py4fun" type="add">
+ Add possibility to set a meaningful name for Yaml instance to be shown in toString(). (2009-03-05)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: declare classes which are not expected to be extended as final. (2009-03-04)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use 'final' keyword to identify immutable fields. (2009-03-04)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: do not use 'final' keyword for local variables. (2009-03-04)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix: respect implicit resolvers with 'null' as a first character. (2009-03-02)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use Character instead of String as a key for implicit resolvers. (2009-03-02)
+ </action>
+ <action dev="py4fun" type="add">
+ Use Ragel instead of Regular Expressions for implicit types. (2009-03-02)
+ </action>
+ <action dev="py4fun" type="fix" due-to="Christophe Desguez">
+ Fix ticket #4 (in Assembla): java.sql.Date not handled. (2009-02-28)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce DumperOptions.DefaultFlowStyle enum (2009-02-24)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce DumperOptions.DefaultScalarStyle enum (2009-02-24)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use 'switch' with Enum instead of multiple 'if' statements to distinguish nodes (2009-02-19)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: use Enum instead of String as NodeId (2009-02-19)
+ </action>
+ </release>
+ <release version="1.0.1" date="2009-02-18" description="implement Enum support">
+ <action dev="py4fun" type="fix">
+ Do not emit anchors for Enum (2009-02-18)
+ </action>
+ <action dev="py4fun" type="fix">
+ Enum as a JavaBean property (when the Enum class is implicitly defined) does
+ not need tags for both loading and dumping (2009-02-17)
+ </action>
+ <action dev="py4fun" type="fix">
+ Enum is emitted as a scalar node (2009-02-17)
+ </action>
+ <action dev="py4fun" type="fix" due-to="James Nissel">
+ Enum is parsed as a scalar node or as a JavaBean property (2009-02-17)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: for performance ScannerImpl.stalePossibleSimpleKeys() does not copy key Set (2009-02-10)
+ </action>
+ <action dev="py4fun" type="update">
+ By default allowUnicode=true. If it is necessary to escape Unicode use
+ DumperOptions.setAllowUnicode(false) (2009-02-09)
+ </action>
+ <action dev="py4fun" type="add">
+ Implement allowUnicode setting (to escape Unicode characters on non UTF-8 terminals) (2009-02-09)
+ </action>
+ <action dev="py4fun" type="add">
+ Add possibility to specify tags for dumping (2009-02-09)
+ </action>
+ <action dev="py4fun" type="update">
+ Rename getExpRoot to getExplicitRoot to conform with
+ standard JavaBean naming convention (2009-02-09)
+ </action>
+ <action dev="py4fun" type="update">
+ Rename explictStart and explicitEnd to standard setters to conform with
+ standard JavaBean naming convention (2009-02-09)
+ </action>
+ <action dev="py4fun" type="fix">
+ Add possibility to specify a line break (2009-02-09)
+ </action>
+ </release>
+ <release version="1.0" date="2009-02-06" description="final 1.0 release">
+ <action dev="py4fun" type="fix">
+ Use LinkedHashMap for Emitter.tagPrefixes to respect the order (2009-02-06)
+ </action>
+ <action dev="py4fun" type="fix">
+ Use LinkedHashMap for ScannerImpl.possibleSimpleKeys to respect the key order (2009-02-05)
+ </action>
+ <action dev="py4fun" type="add">
+ Add a test to prove that Yaml instances are independent and can safely be used in
+ multithreaded environment like for instance a Servlet container (2009-02-05)
+ </action>
+ <action dev="py4fun" type="update">
+ The mailing list is renamed to snakeyaml-core to avoid a
+ name conflict in Google AppEngine (2009-02-03)
+ </action>
+ </release>
+ <release version="1.0rc2" date="2008-01-22" description="Improve JavaBeans support">
+ <action dev="py4fun" type="add">
+ Provide possibility to define/eliminate the root tag for JavaBeans. Avoiding global tags
+ helps to exchange YAML documents with other programming languages (2009-01-21)
+ </action>
+ <action dev="py4fun" type="fix">
+ Arrays as JavaBens properties are properly supported (2009-01-21)
+ </action>
+ <action dev="py4fun" type="update">
+ Do not emit redundant tags for JavaBeans (2009-01-20)
+ </action>
+ <action dev="py4fun" type="add">
+ Respect public fields in JavaBeans (2009-01-20)
+ </action>
+ </release>
+ <release version="1.0rc1" date="2009-01-16" description="Construct type safe collections">
+ <action dev="py4fun" type="update">
+ Replace String.getBytes(Charset charset) with String.getBytes(String charsetName) because
+ String.getBytes(Charset charset) was introduced only in Java 6 (2009-01-16)
+ </action>
+ <action dev="py4fun" type="update">
+ Replace LinkedList.pop() with removeFirst() because pop() was
+ introduced only in Java 6 (2009-01-16)
+ </action>
+ <action dev="py4fun" type="update">
+ Replace LinkedList.push() with addFirst() because push() was
+ introduced only in Java 6 (2009-01-16)
+ </action>
+ <action dev="py4fun" type="add">
+ Implement type safe Map as a property of custom Java class (2009-01-16)
+ </action>
+ <action dev="py4fun" type="add">
+ Implement type safe List as a property of custom Java class (2009-01-15)
+ </action>
+ <action dev="py4fun" type="update">
+ Construct interface does not use generics. The type information is set
+ to the Node (2009-01-15)
+ </action>
+ <action dev="py4fun" type="add">
+ Introduce TypeDescription as a single configuration option for a custom class (2009-01-15)
+ </action>
+ </release>
+ <release version="0.91" date="2008-01-14" description="Support shortcut tags for custom classes">
+ <action dev="py4fun" type="add">
+ Add possibility to define shortcut tags for custom classes while loading (2009-01-13)
+ </action>
+ <action dev="py4fun" type="add">
+ Add possibility to define shortcut tags for custom classes while dumping (2009-01-13)
+ </action>
+ <action dev="py4fun" type="add">
+ Construct List as a JavaBean property. But due to erasure only standard Java
+ classes created (2009-01-13)
+ </action>
+ <action dev="py4fun" type="add">
+ Import PyStructureTest from PyYAML (2009-01-13)
+ </action>
+ <action dev="py4fun" type="add">
+ Import canonical scanner and parser from PyYAML (2009-01-12)
+ </action>
+ </release>
+ <release version="0.9" date="2008-01-12" description="Add possibility to define a root class for Loader">
+ <action dev="py4fun" type="add">
+ Finish 2.27 example from the specification (2009-01-12)
+ </action>
+ <action dev="py4fun" type="add">
+ Add possibility to define a root class for Loader (2009-01-11)
+ </action>
+ <action dev="py4fun" type="update">
+ Use Java Generics in the Construct interface (2009-01-11)
+ </action>
+ <action dev="py4fun" type="update">
+ Use Java Generics in the Scanner interface (2009-01-08)
+ </action>
+ <action dev="py4fun" type="update">
+ Create ScannerIml only in ParserImpl (2009-01-08)
+ </action>
+ <action dev="py4fun" type="fix">
+ Import changeset 312 from PyYAML. Fix a bug in Emitter when writing folded scalars (2009-01-07)
+ </action>
+ </release>
+ <release version="0.8" date="2009-01-07" description="Import changes from PyYAML 3.08">
+ <action dev="py4fun" type="add">
+ Add possibility to use java.io.Reader as input. BOM must be respected. (2009-01-06)
+ </action>
+ <action dev="py4fun" type="update">
+ Import Changeset 308 from PyYAML: Refactored whitespace combination
+ detector in the scalar analyser. (2009-01-06)
+ </action>
+ <action dev="py4fun" type="update">
+ Import Changeset 313 from PyYAML: Emit an explicit document end indicator
+ when there is a possibility of ambiguous parsing. (2009-01-06)
+ </action>
+ <action dev="py4fun" type="update">
+ Use global tags (with !!) to dump Java custom instances. (2009-01-05)
+ </action>
+ <action dev="py4fun" type="update">
+ Use global tags (with !!) to load Java custom instances. (2009-01-05)
+ </action>
+ <action dev="py4fun" type="add">
+ Add example of defining a custom List and Map implementations. (2009-01-04)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix parsing Long.MIN_VALUE: respect the sign when parsing integers. (2009-01-04)
+ </action>
+ <action dev="py4fun" type="update">
+ when constructing integers try to create the first in the following order:
+ Integer -> Long -> BigInteger. (2009-01-02)
+ </action>
+ </release>
+ <release version="0.7" date="2008-12-20" description="Improve test coverage">
+ <action dev="py4fun" type="update">
+ Improve test coverage for constructor package (2008-12-20)
+ </action>
+ <action dev="py4fun" type="remove">
+ Remove support for "value" type because it is not used (2008-12-20)
+ </action>
+ <action dev="py4fun" type="update">
+ Require test coverage 95% (2008-12-19)
+ </action>
+ <action dev="py4fun" type="update">
+ Improve test coverage for Nodes (2008-12-19)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix dumping Date and better coverage for Representer (2008-12-19)
+ </action>
+ <action dev="py4fun" type="remove">
+ Remove unused code based on coverage report (2008-12-19)
+ </action>
+ <action dev="py4fun" type="remove">
+ Tokens are 100% covered by tests (2008-12-19)
+ </action>
+ <action dev="py4fun" type="remove">
+ Remove old tests (2008-12-18)
+ </action>
+ <action dev="py4fun" type="update">
+ Synchronized with PyYAML revision 307
+ </action>
+ </release>
+ <release version="0.6" date="2008-12-17" description="Documentation added">
+ <action dev="py4fun" type="add">
+ Many examples added to the Wiki page (2008-12-17)
+ </action>
+ <action dev="py4fun" type="update">
+ Public interface is using Iterator instead of Iterable (2008-12-17)
+ </action>
+ <action dev="py4fun" type="update">
+ Sort names when JavaBeans are represented (2008-12-15)
+ </action>
+ <action dev="py4fun" type="fix">
+ defaultFlowStyle for Dumper is configurable in DumperOptions (2008-12-12)
+ </action>
+ </release>
+ <release version="0.5" date="2008-12-12" description="Import PyYAML 3.06">
+ <action dev="py4fun" type="add">
+ Add possibility to define an implicit resolver. {359:63190d5bcd10} (2008-12-11)
+ </action>
+ <action dev="py4fun" type="add">
+ Add possibility to define an explicit constructor. {356:ccaa0df9ca98} (2008-12-11)
+ </action>
+ <action dev="py4fun" type="update">
+ Java objects can be constructed from mapping (JavaBeans), from sequence (constructor)
+ from scalar (constructor). (2008-12-10)
+ </action>
+ <action dev="py4fun" type="fix">
+ pairs tag works properly. (2008-12-08)
+ </action>
+ <action dev="py4fun" type="fix">
+ omap tag works properly. (2008-12-08)
+ </action>
+ <action dev="py4fun" type="add">
+ Implement possibility to define a custom Map implementation {332}. (2008-12-06)
+ </action>
+ <action dev="py4fun" type="add">
+ Implement possibility to define a custom List implementation {331:72c03254c184}. (2008-12-06)
+ </action>
+ <action dev="py4fun" type="add">
+ Path resolver is removed because it is not imported properly {330}. (2008-12-06)
+ </action>
+ <action dev="py4fun" type="add">
+ Constructor is overwritten completely. (2008-12-06)
+ </action>
+ <action dev="py4fun" type="add">
+ Implement possibility to define a custom Representer. (2008-12-01)
+ </action>
+ <action dev="py4fun" type="update">
+ Support arrays of reference types. Arrays of primitives are not supported
+ because Arrays.asList() does not work. (2008-12-01)
+ </action>
+ <action dev="py4fun" type="update">
+ Import change 300 for Emitter from PyYAML. (2008-12-01)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix Node identity to avoid aliases for simple types - [1, 1]. (2008-11-28)
+ </action>
+ <action dev="py4fun" type="update">
+ Recursive objects can be represented (but not yet constructed) (2008-11-28)
+ </action>
+ <action dev="py4fun" type="update">
+ Binary is represented back as String (2008-11-28)
+ </action>
+ <action dev="py4fun" type="update">
+ Re-write Representer classes from scratch (2008-11-28)
+ </action>
+ <action dev="py4fun" type="fix">
+ 'null' can be a key in a map (2008-11-21)
+ </action>
+ <action dev="py4fun" type="fix">
+ !!set tag is parsed properly (2008-11-21)
+ </action>
+ <action dev="py4fun" type="update">
+ Single characters 'Y', 'N', 'y' and 'n' are parsed as String opposed to boolean
+ as it is defined in the specification. This is how it is done in PyYAML (2008-11-21)
+ </action>
+ <action dev="py4fun" type="remove">
+ Constructor: because Java does not have generators 'deep' is not
+ imported from PyYAML (2008-11-19)
+ </action>
+ <action dev="py4fun" type="update">
+ Composer imported from PyYAML (2008-11-17)
+ </action>
+ <action dev="py4fun" type="update">
+ Resolver.resolve() is using simple boolean argument instead of array of booleans
+ as in PyYAML. (2008-11-18)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix: 'set' type works. (2008-11-18)
+ </action>
+ <action dev="py4fun" type="update">
+ Rewrite Parser from scratch. (2008-11-17)
+ </action>
+ </release>
+ <release version="0.4" date="2008-11-11" description="Fix issues in Scanner">
+ <action dev="py4fun" type="update">
+ Move constants from Yaml interface to appropriate classes (2008-11-10)
+ </action>
+ <action dev="py4fun" type="update">
+ Interface change: Yaml dumpAll() methods accept Iterable (2008-11-10)
+ </action>
+ <action dev="py4fun" type="update">
+ Interface change: Yaml loadAll() methods return Iterable (2008-11-10)
+ </action>
+ <action dev="py4fun" type="fix">
+ Scanner: copy keys to avoid java.util.ConcurrentModificationException when removing
+ possible simple key (2008-11-10)
+ </action>
+ <action dev="py4fun" type="update">
+ Tag v0.3.1 (2008-11-08)
+ </action>
+ <action dev="py4fun" type="update">
+ MappingNode requires Map as a value and SequenceNode requires
+ List as a value (2008-11-08)
+ </action>
+ <action dev="py4fun" type="update">
+ Marks in a Token are required (2008-11-08)
+ </action>
+ <action dev="py4fun" type="remove">
+ Remove prefixForward() method from Reader because it is not present
+ in PyYAML (2008-11-08)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix a deviation with PyYAML in method scanBlockScalar().
+ 'chomping' can be null. Fix a bug in JvYaml that the trailing '\n' in a
+ block scalar was removed.(2008-11-07)
+ </action>
+ <action dev="py4fun" type="fix">
+ Fix a deviation with PyYAML in method scanDirectiveIgnoredLine().
+ Put '#' instead of '"'. (2008-11-07)
+ </action>
+ <action dev="py4fun" type="add">
+ Restore from PyYAML the way the keys are parsed. (Restored methods are
+ stalePossibleSimpleKeys() and removePossibleSimpleKey().)
+ Fix issue http://code.google.com/p/jvyamlb/issues/detail?id=6. (2008-11-07)
+ </action>
+ <action dev="py4fun" type="update">
+ Refactor: put changed classes to 'org.yaml.snakeyaml' package. (2008-11-05)
+ </action>
+ <action dev="py4fun" type="update">
+ Move all the main() methods to the corresponding test classes. (2008-11-05)
+ </action>
+ <action dev="py4fun" type="update">
+ Change public interface. Rename YAML to Yaml. Remove all static methods from Yaml.
+ Factory and configuration must be injected at the constructor. This way is closer
+ to PyYAML API. (2008-11-05)
+ </action>
+ <action dev="py4fun" type="add">
+ Reader as in PyYAML is implemented. BOM is properly supported (2008-11-05)
+ </action>
+ <action dev="py4fun" type="add">
+ Restore Mark in Token as it is in PyYAML. Mark is not defined yet (2008-10-30)
+ </action>
+ <action dev="py4fun" type="fix">
+ Off-by-one in EmitterImpl.writeDoubleQuoted().
+ Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=11 (2008-10-28)
+ </action>
+ <action dev="py4fun" type="fix">
+ Respect Unicode characters.
+ Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=10 (2008-10-28)
+ </action>
+ <action dev="py4fun" type="fix">
+ Respect sign for float.
+ Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=13 (2008-10-28)
+ </action>
+ <action dev="py4fun" type="add">
+ Binary data is represented as ByteBuffer (2008-10-27)
+ </action>
+ <action dev="py4fun" type="fix">
+ When parsed, a timestamp in the canonical form (i.e, 2001-12-15T02:59:43.1Z) is
+ interpreted as if it is in the default time zone.
+ Fix issue: https://jvyaml.dev.java.net/issues/show_bug.cgi?id=7 (2008-10-27)
+ </action>
+ <action dev="py4fun" type="add">
+ Add Mark from PyYAML. It is not used yet. The JUnit test is migrated from PyYAML (2008-10-23)
+ </action>
+ <action dev="py4fun" type="update">
+ Apply SnakeYAML as the name of the library (2008-10-22)
+ </action>
+ <action dev="py4fun" type="update">
+ Reformat the source files (2008-10-22)
+ </action>
+ <action dev="py4fun" type="update">
+ Apply LICENSE info to source files (2008-10-22)
+ </action>
+ <action dev="py4fun" type="update">
+ Mavenize project. Apply standard Maven folder structure (2008-10-20)
+ </action>
+ </release>
+ <release version="0.2.1" date="2008-10-20" description="Import JvYaml from CVS">
+ <action dev="py4fun" type="add">
+ Import project from https://jvyaml.dev.java.net/ (2008-10-20)
+ </action>
+ </release>
+ </body>
+</document>
+
diff --git a/src/etc/Eclipse-format.xml b/src/etc/Eclipse-format.xml
index f65dde4..4dcc5a8 100644
--- a/src/etc/Eclipse-format.xml
+++ b/src/etc/Eclipse-format.xml
@@ -1,264 +1,264 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<profiles version="11">
-<profile kind="CodeFormatterProfile" name="SnakeYAML" version="11">
-<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
-<setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
-<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
-<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
-<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/>
-<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/>
-<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
-<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
-<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
-<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
-</profile>
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<profiles version="11">
+<profile kind="CodeFormatterProfile" name="SnakeYAML" version="11">
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
+<setting id="org.eclipse.jdt.core.compiler.source" value="1.5"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="100"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.assertIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.compiler.problem.enumIdentifier" value="error"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.compiler.compliance" value="1.5"/>
+<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.wrap_before_binary_operator" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.compiler.codegen.targetPlatform" value="1.5"/>
+<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
+<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
+<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
+</profile>
</profiles>
\ No newline at end of file
diff --git a/src/etc/header.txt b/src/etc/header.txt
index 089c879..55fab44 100644
--- a/src/etc/header.txt
+++ b/src/etc/header.txt
@@ -1,13 +1,13 @@
-Copyright (c) 2008-2011, http://www.snakeyaml.org
-
-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
+Copyright (c) 2008-2011, http://www.snakeyaml.org
+
+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.
\ No newline at end of file
diff --git a/src/main/java/org/yaml/snakeyaml/Dumper.java b/src/main/java/org/yaml/snakeyaml/Dumper.java
index 4831d54..5a18432 100644
--- a/src/main/java/org/yaml/snakeyaml/Dumper.java
+++ b/src/main/java/org/yaml/snakeyaml/Dumper.java
@@ -1,44 +1,44 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * @deprecated Dumper's functionality was moved to Yaml
- */
-public final class Dumper {
- protected final Representer representer;
- protected final DumperOptions options;
-
- public Dumper(Representer representer, DumperOptions options) {
- this.representer = representer;
- this.options = options;
- }
-
- public Dumper(DumperOptions options) {
- this(new Representer(), options);
- }
-
- public Dumper(Representer representer) {
- this(representer, new DumperOptions());
- }
-
- public Dumper() {
- this(new Representer(), new DumperOptions());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * @deprecated Dumper's functionality was moved to Yaml
+ */
+public final class Dumper {
+ protected final Representer representer;
+ protected final DumperOptions options;
+
+ public Dumper(Representer representer, DumperOptions options) {
+ this.representer = representer;
+ this.options = options;
+ }
+
+ public Dumper(DumperOptions options) {
+ this(new Representer(), options);
+ }
+
+ public Dumper(Representer representer) {
+ this(representer, new DumperOptions());
+ }
+
+ public Dumper() {
+ this(new Representer(), new DumperOptions());
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/JavaBeanLoader.java b/src/main/java/org/yaml/snakeyaml/JavaBeanLoader.java
index 87587fb..9d51c79 100644
--- a/src/main/java/org/yaml/snakeyaml/JavaBeanLoader.java
+++ b/src/main/java/org/yaml/snakeyaml/JavaBeanLoader.java
@@ -1,108 +1,108 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.introspector.BeanAccess;
-import org.yaml.snakeyaml.reader.UnicodeReader;
-import org.yaml.snakeyaml.representer.Representer;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-/**
- * Convenience utility to parse JavaBeans. When the YAML document contains a
- * global tag with the class definition like '!!com.package.MyBean' it is
- * ignored in favour of the runtime class <code>T</code>.
- *
- * @deprecated use Yaml.loadAs() methods instead
- * @see http://www.artima.com/weblogs/viewpost.jsp?thread=208860
- */
-public class JavaBeanLoader<T> {
- private Yaml loader;
-
- public JavaBeanLoader(TypeDescription typeDescription) {
- this(typeDescription, BeanAccess.DEFAULT);
- }
-
- public JavaBeanLoader(TypeDescription typeDescription, BeanAccess beanAccess) {
- this(new LoaderOptions(typeDescription), beanAccess);
- }
-
- public JavaBeanLoader(LoaderOptions options, BeanAccess beanAccess) {
- if (options == null) {
- throw new NullPointerException("LoaderOptions must be provided.");
- }
- if (options.getRootTypeDescription() == null) {
- throw new NullPointerException("TypeDescription must be provided.");
- }
- Constructor constructor = new Constructor(options.getRootTypeDescription());
- loader = new Yaml(constructor, options, new Representer(), new DumperOptions(),
- new Resolver());
- loader.setBeanAccess(beanAccess);
- }
-
- public <S extends T> JavaBeanLoader(Class<S> clazz, BeanAccess beanAccess) {
- this(new TypeDescription(clazz), beanAccess);
- }
-
- public <S extends T> JavaBeanLoader(Class<S> clazz) {
- this(clazz, BeanAccess.DEFAULT);
- }
-
- /**
- * Parse the first YAML document in a stream and produce the corresponding
- * JavaBean.
- *
- * @param yaml
- * YAML document
- * @return parsed JavaBean
- */
- @SuppressWarnings("unchecked")
- public T load(String yaml) {
- return (T) loader.load(new StringReader(yaml));
- }
-
- /**
- * Parse the first YAML document in a stream and produce the corresponding
- * JavaBean.
- *
- * @param io
- * data to load from (BOM is respected and removed)
- * @return parsed JavaBean
- */
- @SuppressWarnings("unchecked")
- public T load(InputStream io) {
- return (T) loader.load(new UnicodeReader(io));
- }
-
- /**
- * Parse the first YAML document in a stream and produce the corresponding
- * Java object.
- *
- * @param io
- * data to load from (BOM must not be present)
- * @return parsed JavaBean
- */
- @SuppressWarnings("unchecked")
- public T load(Reader io) {
- return (T) loader.load(io);
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.introspector.BeanAccess;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+import org.yaml.snakeyaml.representer.Representer;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+/**
+ * Convenience utility to parse JavaBeans. When the YAML document contains a
+ * global tag with the class definition like '!!com.package.MyBean' it is
+ * ignored in favour of the runtime class <code>T</code>.
+ *
+ * @deprecated use Yaml.loadAs() methods instead
+ * @see http://www.artima.com/weblogs/viewpost.jsp?thread=208860
+ */
+public class JavaBeanLoader<T> {
+ private Yaml loader;
+
+ public JavaBeanLoader(TypeDescription typeDescription) {
+ this(typeDescription, BeanAccess.DEFAULT);
+ }
+
+ public JavaBeanLoader(TypeDescription typeDescription, BeanAccess beanAccess) {
+ this(new LoaderOptions(typeDescription), beanAccess);
+ }
+
+ public JavaBeanLoader(LoaderOptions options, BeanAccess beanAccess) {
+ if (options == null) {
+ throw new NullPointerException("LoaderOptions must be provided.");
+ }
+ if (options.getRootTypeDescription() == null) {
+ throw new NullPointerException("TypeDescription must be provided.");
+ }
+ Constructor constructor = new Constructor(options.getRootTypeDescription());
+ loader = new Yaml(constructor, options, new Representer(), new DumperOptions(),
+ new Resolver());
+ loader.setBeanAccess(beanAccess);
+ }
+
+ public <S extends T> JavaBeanLoader(Class<S> clazz, BeanAccess beanAccess) {
+ this(new TypeDescription(clazz), beanAccess);
+ }
+
+ public <S extends T> JavaBeanLoader(Class<S> clazz) {
+ this(clazz, BeanAccess.DEFAULT);
+ }
+
+ /**
+ * Parse the first YAML document in a stream and produce the corresponding
+ * JavaBean.
+ *
+ * @param yaml
+ * YAML document
+ * @return parsed JavaBean
+ */
+ @SuppressWarnings("unchecked")
+ public T load(String yaml) {
+ return (T) loader.load(new StringReader(yaml));
+ }
+
+ /**
+ * Parse the first YAML document in a stream and produce the corresponding
+ * JavaBean.
+ *
+ * @param io
+ * data to load from (BOM is respected and removed)
+ * @return parsed JavaBean
+ */
+ @SuppressWarnings("unchecked")
+ public T load(InputStream io) {
+ return (T) loader.load(new UnicodeReader(io));
+ }
+
+ /**
+ * Parse the first YAML document in a stream and produce the corresponding
+ * Java object.
+ *
+ * @param io
+ * data to load from (BOM must not be present)
+ * @return parsed JavaBean
+ */
+ @SuppressWarnings("unchecked")
+ public T load(Reader io) {
+ return (T) loader.load(io);
+ }
+
+}
diff --git a/src/main/java/org/yaml/snakeyaml/Loader.java b/src/main/java/org/yaml/snakeyaml/Loader.java
index 20b07f0..4bd3fa2 100644
--- a/src/main/java/org/yaml/snakeyaml/Loader.java
+++ b/src/main/java/org/yaml/snakeyaml/Loader.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import org.yaml.snakeyaml.constructor.BaseConstructor;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-/**
- * @deprecated Loader's functionality was moved to Yaml
- */
-public final class Loader {
- protected final BaseConstructor constructor;
- protected Resolver resolver;
-
- public Loader(BaseConstructor constructor) {
- super();
- this.constructor = constructor;
- }
-
- public Loader() {
- this(new Constructor());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import org.yaml.snakeyaml.constructor.BaseConstructor;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+/**
+ * @deprecated Loader's functionality was moved to Yaml
+ */
+public final class Loader {
+ protected final BaseConstructor constructor;
+ protected Resolver resolver;
+
+ public Loader(BaseConstructor constructor) {
+ super();
+ this.constructor = constructor;
+ }
+
+ public Loader() {
+ this(new Constructor());
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/TypeDescription.java b/src/main/java/org/yaml/snakeyaml/TypeDescription.java
index 7b47200..609adaf 100644
--- a/src/main/java/org/yaml/snakeyaml/TypeDescription.java
+++ b/src/main/java/org/yaml/snakeyaml/TypeDescription.java
@@ -1,149 +1,149 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Provides additional runtime information necessary to create a custom Java
- * instance.
- */
-public final class TypeDescription {
- private final Class<? extends Object> type;
- private Tag tag;
- private Map<String, Class<? extends Object>> listProperties;
- private Map<String, Class<? extends Object>> keyProperties;
- private Map<String, Class<? extends Object>> valueProperties;
-
- public TypeDescription(Class<? extends Object> clazz, Tag tag) {
- this.type = clazz;
- this.tag = tag;
- listProperties = new HashMap<String, Class<? extends Object>>();
- keyProperties = new HashMap<String, Class<? extends Object>>();
- valueProperties = new HashMap<String, Class<? extends Object>>();
- }
-
- public TypeDescription(Class<? extends Object> clazz, String tag) {
- this(clazz, new Tag(tag));
- }
-
- public TypeDescription(Class<? extends Object> clazz) {
- this(clazz, (Tag) null);
- }
-
- /**
- * Get tag which shall be used to load or dump the type (class).
- *
- * @return tag to be used. It may be a tag for Language-Independent Types
- * (http://www.yaml.org/type/)
- */
- public Tag getTag() {
- return tag;
- }
-
- /**
- * Set tag to be used to load or dump the type (class).
- *
- * @param tag
- * local or global tag
- */
- public void setTag(Tag tag) {
- this.tag = tag;
- }
-
- public void setTag(String tag) {
- setTag(new Tag(tag));
- }
-
- /**
- * Get represented type (class)
- *
- * @return type (class) to be described.
- */
- public Class<? extends Object> getType() {
- return type;
- }
-
- /**
- * Specify that the property is a type-safe <code>List</code>.
- *
- * @param property
- * name of the JavaBean property
- * @param type
- * class of List values
- */
- public void putListPropertyType(String property, Class<? extends Object> type) {
- listProperties.put(property, type);
- }
-
- /**
- * Get class of List values for provided JavaBean property.
- *
- * @param property
- * property name
- * @return class of List values
- */
- public Class<? extends Object> getListPropertyType(String property) {
- return listProperties.get(property);
- }
-
- /**
- * Specify that the property is a type-safe <code>Map</code>.
- *
- * @param property
- * property name of this JavaBean
- * @param key
- * class of keys in Map
- * @param value
- * class of values in Map
- */
- public void putMapPropertyType(String property, Class<? extends Object> key,
- Class<? extends Object> value) {
- keyProperties.put(property, key);
- valueProperties.put(property, value);
- }
-
- /**
- * Get keys type info for this JavaBean
- *
- * @param property
- * property name of this JavaBean
- * @return class of keys in the Map
- */
- public Class<? extends Object> getMapKeyType(String property) {
- return keyProperties.get(property);
- }
-
- /**
- * Get values type info for this JavaBean
- *
- * @param property
- * property name of this JavaBean
- * @return class of values in the Map
- */
- public Class<? extends Object> getMapValueType(String property) {
- return valueProperties.get(property);
- }
-
- @Override
- public String toString() {
- return "TypeDescription for " + getType() + " (tag='" + getTag() + "')";
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Provides additional runtime information necessary to create a custom Java
+ * instance.
+ */
+public final class TypeDescription {
+ private final Class<? extends Object> type;
+ private Tag tag;
+ private Map<String, Class<? extends Object>> listProperties;
+ private Map<String, Class<? extends Object>> keyProperties;
+ private Map<String, Class<? extends Object>> valueProperties;
+
+ public TypeDescription(Class<? extends Object> clazz, Tag tag) {
+ this.type = clazz;
+ this.tag = tag;
+ listProperties = new HashMap<String, Class<? extends Object>>();
+ keyProperties = new HashMap<String, Class<? extends Object>>();
+ valueProperties = new HashMap<String, Class<? extends Object>>();
+ }
+
+ public TypeDescription(Class<? extends Object> clazz, String tag) {
+ this(clazz, new Tag(tag));
+ }
+
+ public TypeDescription(Class<? extends Object> clazz) {
+ this(clazz, (Tag) null);
+ }
+
+ /**
+ * Get tag which shall be used to load or dump the type (class).
+ *
+ * @return tag to be used. It may be a tag for Language-Independent Types
+ * (http://www.yaml.org/type/)
+ */
+ public Tag getTag() {
+ return tag;
+ }
+
+ /**
+ * Set tag to be used to load or dump the type (class).
+ *
+ * @param tag
+ * local or global tag
+ */
+ public void setTag(Tag tag) {
+ this.tag = tag;
+ }
+
+ public void setTag(String tag) {
+ setTag(new Tag(tag));
+ }
+
+ /**
+ * Get represented type (class)
+ *
+ * @return type (class) to be described.
+ */
+ public Class<? extends Object> getType() {
+ return type;
+ }
+
+ /**
+ * Specify that the property is a type-safe <code>List</code>.
+ *
+ * @param property
+ * name of the JavaBean property
+ * @param type
+ * class of List values
+ */
+ public void putListPropertyType(String property, Class<? extends Object> type) {
+ listProperties.put(property, type);
+ }
+
+ /**
+ * Get class of List values for provided JavaBean property.
+ *
+ * @param property
+ * property name
+ * @return class of List values
+ */
+ public Class<? extends Object> getListPropertyType(String property) {
+ return listProperties.get(property);
+ }
+
+ /**
+ * Specify that the property is a type-safe <code>Map</code>.
+ *
+ * @param property
+ * property name of this JavaBean
+ * @param key
+ * class of keys in Map
+ * @param value
+ * class of values in Map
+ */
+ public void putMapPropertyType(String property, Class<? extends Object> key,
+ Class<? extends Object> value) {
+ keyProperties.put(property, key);
+ valueProperties.put(property, value);
+ }
+
+ /**
+ * Get keys type info for this JavaBean
+ *
+ * @param property
+ * property name of this JavaBean
+ * @return class of keys in the Map
+ */
+ public Class<? extends Object> getMapKeyType(String property) {
+ return keyProperties.get(property);
+ }
+
+ /**
+ * Get values type info for this JavaBean
+ *
+ * @param property
+ * property name of this JavaBean
+ * @return class of values in the Map
+ */
+ public Class<? extends Object> getMapValueType(String property) {
+ return valueProperties.get(property);
+ }
+
+ @Override
+ public String toString() {
+ return "TypeDescription for " + getType() + " (tag='" + getTag() + "')";
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/Yaml.java b/src/main/java/org/yaml/snakeyaml/Yaml.java
index f277f80..d917fb2 100644
--- a/src/main/java/org/yaml/snakeyaml/Yaml.java
+++ b/src/main/java/org/yaml/snakeyaml/Yaml.java
@@ -1,742 +1,742 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.regex.Pattern;
-
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.composer.Composer;
-import org.yaml.snakeyaml.constructor.BaseConstructor;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.emitter.Emitable;
-import org.yaml.snakeyaml.emitter.Emitter;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.introspector.BeanAccess;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.parser.Parser;
-import org.yaml.snakeyaml.parser.ParserImpl;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.reader.UnicodeReader;
-import org.yaml.snakeyaml.representer.Representer;
-import org.yaml.snakeyaml.resolver.Resolver;
-import org.yaml.snakeyaml.serializer.Serializer;
-
-/**
- * Public YAML interface. Each Thread must have its own instance.
- */
-public class Yaml {
- protected final Resolver resolver;
- private String name;
- protected BaseConstructor constructor;
- protected Representer representer;
- protected DumperOptions dumperOptions;
- protected LoaderOptions loaderOptions;
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- */
- public Yaml() {
- this(new Constructor(), new LoaderOptions(), new Representer(), new DumperOptions(),
- new Resolver());
- }
-
- public Yaml(LoaderOptions loaderOptions) {
- this(new Constructor(), loaderOptions, new Representer(), new DumperOptions(),
- new Resolver());
- }
-
- /**
- * Create Yaml instance.
- *
- * @param dumperOptions
- * DumperOptions to configure outgoing objects
- */
- public Yaml(DumperOptions dumperOptions) {
- this(new Constructor(), new Representer(), dumperOptions);
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param representer
- * Representer to emit outgoing objects
- */
- public Yaml(Representer representer) {
- this(new Constructor(), representer);
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param constructor
- * BaseConstructor to construct incoming documents
- */
- public Yaml(BaseConstructor constructor) {
- this(constructor, new Representer());
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param constructor
- * BaseConstructor to construct incoming documents
- * @param representer
- * Representer to emit outgoing objects
- */
- public Yaml(BaseConstructor constructor, Representer representer) {
- this(constructor, representer, new DumperOptions());
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param representer
- * Representer to emit outgoing objects
- * @param dumperOptions
- * DumperOptions to configure outgoing objects
- */
- public Yaml(Representer representer, DumperOptions dumperOptions) {
- this(new Constructor(), representer, dumperOptions, new Resolver());
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param constructor
- * BaseConstructor to construct incoming documents
- * @param representer
- * Representer to emit outgoing objects
- * @param dumperOptions
- * DumperOptions to configure outgoing objects
- */
- public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions) {
- this(constructor, representer, dumperOptions, new Resolver());
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param constructor
- * BaseConstructor to construct incoming documents
- * @param representer
- * Representer to emit outgoing objects
- * @param dumperOptions
- * DumperOptions to configure outgoing objects
- * @param resolver
- * Resolver to detect implicit type
- */
- public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions,
- Resolver resolver) {
- this(constructor, new LoaderOptions(), representer, dumperOptions, resolver);
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param constructor
- * BaseConstructor to construct incoming documents
- * @param loaderOptions
- * LoaderOptions to control construction process
- * @param representer
- * Representer to emit outgoing objects
- * @param dumperOptions
- * DumperOptions to configure outgoing objects
- * @param resolver
- * Resolver to detect implicit type
- */
- public Yaml(BaseConstructor constructor, LoaderOptions loaderOptions, Representer representer,
- DumperOptions dumperOptions, Resolver resolver) {
- if (!constructor.isExplicitPropertyUtils()) {
- constructor.setPropertyUtils(representer.getPropertyUtils());
- } else if (!representer.isExplicitPropertyUtils()) {
- representer.setPropertyUtils(constructor.getPropertyUtils());
- }
- this.constructor = constructor;
- this.loaderOptions = loaderOptions;
- representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
- representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
- representer.getPropertyUtils().setAllowReadOnlyProperties(
- dumperOptions.isAllowReadOnlyProperties());
- this.representer = representer;
- this.dumperOptions = dumperOptions;
- this.resolver = resolver;
- this.name = "Yaml:" + System.identityHashCode(this);
- }
-
- /**
- * Serialize a Java object into a YAML String.
- *
- * @param data
- * Java object to be Serialized to YAML
- * @return YAML String
- */
- public String dump(Object data) {
- List<Object> list = new ArrayList<Object>(1);
- list.add(data);
- return dumpAll(list.iterator());
- }
-
- /**
- * Produce the corresponding representation tree for a given Object.
- *
- * @see http://yaml.org/spec/1.1/#id859333
- * @param data
- * instance to build the representation tree for
- * @return representation tree
- */
- public Node represent(Object data) {
- return representer.represent(data);
- }
-
- /**
- * Serialize a sequence of Java objects into a YAML String.
- *
- * @param data
- * Iterator with Objects
- * @return YAML String with all the objects in proper sequence
- */
- public String dumpAll(Iterator<? extends Object> data) {
- StringWriter buffer = new StringWriter();
- dumpAll(data, buffer);
- return buffer.toString();
- }
-
- /**
- * Serialize a Java object into a YAML stream.
- *
- * @param data
- * Java object to be serialized to YAML
- * @param output
- * stream to write to
- */
- public void dump(Object data, Writer output) {
- List<Object> list = new ArrayList<Object>(1);
- list.add(data);
- dumpAll(list.iterator(), output);
- }
-
- /**
- * Serialize a sequence of Java objects into a YAML stream.
- *
- * @param data
- * Iterator with Objects
- * @param output
- * stream to write to
- */
- @SuppressWarnings("deprecation")
- public void dumpAll(Iterator<? extends Object> data, Writer output) {
- dumpAll(data, output, dumperOptions.getExplicitRoot());
- }
-
- private void dumpAll(Iterator<? extends Object> data, Writer output, Tag rootTag) {
- Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver,
- dumperOptions, rootTag);
- try {
- serializer.open();
- while (data.hasNext()) {
- Node node = representer.represent(data.next());
- serializer.serialize(node);
- }
- serializer.close();
- } catch (java.io.IOException e) {
- throw new YAMLException(e);
- }
- }
-
- /**
- * <p>
- * Serialize a Java object into a YAML string. Override the default root tag
- * with <code>rootTag</code>.
- * </p>
- *
- * <p>
- * This method is similar to <code>Yaml.dump(data)</code> except that the
- * root tag for the whole document is replaced with the given tag. This has
- * two main uses.
- * </p>
- *
- * <p>
- * First, if the root tag is replaced with a standard YAML tag, such as
- * <code>Tag.MAP</code>, then the object will be dumped as a map. The root
- * tag will appear as <code>!!map</code>, or blank (implicit !!map).
- * </p>
- *
- * <p>
- * Second, if the root tag is replaced by a different custom tag, then the
- * document appears to be a different type when loaded. For example, if an
- * instance of MyClass is dumped with the tag !!YourClass, then it will be
- * handled as an instance of YourClass when loaded.
- * </p>
- *
- * @param data
- * Java object to be serialized to YAML
- * @param rootTag
- * the tag for the whole YAML document. The tag should be Tag.MAP
- * for a JavaBean to make the tag disappear (to use implicit tag
- * !!map). If <code>null</code> is provided then the standard tag
- * with the full class name is used.
- * @param flowStyle
- * flow style for the whole document. See Chapter 10. Collection
- * Styles http://yaml.org/spec/1.1/#id930798. If
- * <code>null</code> is provided then the flow style from
- * DumperOptions is used.
- *
- * @return YAML String
- */
- public String dumpAs(Object data, Tag rootTag, FlowStyle flowStyle) {
- FlowStyle oldStyle = representer.getDefaultFlowStyle();
- if (flowStyle != null) {
- representer.setDefaultFlowStyle(flowStyle);
- }
- List<Object> list = new ArrayList<Object>(1);
- list.add(data);
- StringWriter buffer = new StringWriter();
- dumpAll(list.iterator(), buffer, rootTag);
- representer.setDefaultFlowStyle(oldStyle);
- return buffer.toString();
- }
-
- /**
- * <p>
- * Serialize a Java object into a YAML string. Override the default root tag
- * with <code>Tag.MAP</code>.
- * </p>
- * <p>
- * This method is similar to <code>Yaml.dump(data)</code> except that the
- * root tag for the whole document is replaced with <code>Tag.MAP</code> tag
- * (implicit !!map).
- * </p>
- * <p>
- * Block Mapping is used as the collection style. See 10.2.2. Block Mappings
- * (http://yaml.org/spec/1.1/#id934537)
- * </p>
- *
- * @param data
- * Java object to be serialized to YAML
- * @return YAML String
- */
- public String dumpAsMap(Object data) {
- return dumpAs(data, Tag.MAP, FlowStyle.BLOCK);
- }
-
- /**
- * Serialize the representation tree into Events.
- *
- * @see http://yaml.org/spec/1.1/#id859333
- * @param data
- * representation tree
- * @return Event list
- */
- public List<Event> serialize(Node data) {
- SilentEmitter emitter = new SilentEmitter();
- @SuppressWarnings("deprecation")
- Serializer serializer = new Serializer(emitter, resolver, dumperOptions,
- dumperOptions.getExplicitRoot());
- try {
- serializer.open();
- serializer.serialize(data);
- serializer.close();
- } catch (java.io.IOException e) {
- throw new YAMLException(e);
- }
- return emitter.getEvents();
- }
-
- private class SilentEmitter implements Emitable {
- private List<Event> events = new ArrayList<Event>(100);
-
- public List<Event> getEvents() {
- return events;
- }
-
- public void emit(Event event) throws IOException {
- events.add(event);
- }
- }
-
- /**
- * Parse the only YAML document in a String and produce the corresponding
- * Java object. (Because the encoding in known BOM is not respected.)
- *
- * @param yaml
- * YAML data to load from (BOM must not be present)
- * @return parsed object
- */
- public Object load(String yaml) {
- return loadFromReader(new StreamReader(yaml), Object.class);
- }
-
- /**
- * Parse the only YAML document in a stream and produce the corresponding
- * Java object.
- *
- * @param io
- * data to load from (BOM is respected and removed)
- * @return parsed object
- */
- public Object load(InputStream io) {
- return loadFromReader(new StreamReader(new UnicodeReader(io)), Object.class);
- }
-
- /**
- * Parse the only YAML document in a stream and produce the corresponding
- * Java object.
- *
- * @param io
- * data to load from (BOM must not be present)
- * @return parsed object
- */
- public Object load(Reader io) {
- return loadFromReader(new StreamReader(io), Object.class);
- }
-
- /**
- * Parse the only YAML document in a stream and produce the corresponding
- * Java object.
- *
- * @param <T>
- * Class is defined by the second argument
- * @param io
- * data to load from (BOM must not be present)
- * @param type
- * Class of the object to be created
- * @return parsed object
- */
- @SuppressWarnings("unchecked")
- public <T> T loadAs(Reader io, Class<T> type) {
- return (T) loadFromReader(new StreamReader(io), type);
- }
-
- /**
- * Parse the only YAML document in a String and produce the corresponding
- * Java object. (Because the encoding in known BOM is not respected.)
- *
- * @param <T>
- * Class is defined by the second argument
- * @param yaml
- * YAML data to load from (BOM must not be present)
- * @param type
- * Class of the object to be created
- * @return parsed object
- */
- @SuppressWarnings("unchecked")
- public <T> T loadAs(String yaml, Class<T> type) {
- return (T) loadFromReader(new StreamReader(yaml), type);
- }
-
- /**
- * Parse the only YAML document in a stream and produce the corresponding
- * Java object.
- *
- * @param <T>
- * Class is defined by the second argument
- * @param input
- * data to load from (BOM is respected and removed)
- * @param type
- * Class of the object to be created
- * @return parsed object
- */
- @SuppressWarnings("unchecked")
- public <T> T loadAs(InputStream input, Class<T> type) {
- return (T) loadFromReader(new StreamReader(new UnicodeReader(input)), type);
- }
-
- private Object loadFromReader(StreamReader sreader, Class<?> type) {
- Composer composer = new Composer(new ParserImpl(sreader), resolver);
- constructor.setComposer(composer);
- return constructor.getSingleData(type);
- }
-
- /**
- * Parse all YAML documents in a String and produce corresponding Java
- * objects. The documents are parsed only when the iterator is invoked.
- *
- * @param yaml
- * YAML data to load from (BOM must not be present)
- * @return an iterator over the parsed Java objects in this String in proper
- * sequence
- */
- public Iterable<Object> loadAll(Reader yaml) {
- Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
- constructor.setComposer(composer);
- Iterator<Object> result = new Iterator<Object>() {
- public boolean hasNext() {
- return constructor.checkData();
- }
-
- public Object next() {
- return constructor.getData();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- return new YamlIterable(result);
- }
-
- private class YamlIterable implements Iterable<Object> {
- private Iterator<Object> iterator;
-
- public YamlIterable(Iterator<Object> iterator) {
- this.iterator = iterator;
- }
-
- public Iterator<Object> iterator() {
- return iterator;
- }
-
- }
-
- /**
- * Parse all YAML documents in a String and produce corresponding Java
- * objects. (Because the encoding in known BOM is not respected.) The
- * documents are parsed only when the iterator is invoked.
- *
- * @param yaml
- * YAML data to load from (BOM must not be present)
- * @return an iterator over the parsed Java objects in this String in proper
- * sequence
- */
- public Iterable<Object> loadAll(String yaml) {
- return loadAll(new StringReader(yaml));
- }
-
- /**
- * Parse all YAML documents in a stream and produce corresponding Java
- * objects. The documents are parsed only when the iterator is invoked.
- *
- * @param yaml
- * YAML data to load from (BOM is respected and ignored)
- * @return an iterator over the parsed Java objects in this stream in proper
- * sequence
- */
- public Iterable<Object> loadAll(InputStream yaml) {
- return loadAll(new UnicodeReader(yaml));
- }
-
- /**
- * Parse the first YAML document in a stream and produce the corresponding
- * representation tree. (This is the opposite of the represent() method)
- *
- * @see http://yaml.org/spec/1.1/#id859333
- * @param yaml
- * YAML document
- * @return parsed root Node for the specified YAML document
- */
- public Node compose(Reader yaml) {
- Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
- constructor.setComposer(composer);
- return composer.getSingleNode();
- }
-
- /**
- * Parse all YAML documents in a stream and produce corresponding
- * representation trees.
- *
- * @see http://yaml.org/spec/1.1/#id859333
- * @param yaml
- * stream of YAML documents
- * @return parsed root Nodes for all the specified YAML documents
- */
- public Iterable<Node> composeAll(Reader yaml) {
- final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
- constructor.setComposer(composer);
- Iterator<Node> result = new Iterator<Node>() {
- public boolean hasNext() {
- return composer.checkNode();
- }
-
- public Node next() {
- return composer.getNode();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- return new NodeIterable(result);
- }
-
- private class NodeIterable implements Iterable<Node> {
- private Iterator<Node> iterator;
-
- public NodeIterable(Iterator<Node> iterator) {
- this.iterator = iterator;
- }
-
- public Iterator<Node> iterator() {
- return iterator;
- }
- }
-
- /**
- * Add an implicit scalar detector. If an implicit scalar value matches the
- * given regexp, the corresponding tag is assigned to the scalar.
- *
- * @deprecated use Tag instead of String
- * @param tag
- * tag to assign to the node
- * @param regexp
- * regular expression to match against
- * @param first
- * a sequence of possible initial characters or null (which means
- * any).
- *
- */
- public void addImplicitResolver(String tag, Pattern regexp, String first) {
- addImplicitResolver(new Tag(tag), regexp, first);
- }
-
- /**
- * Add an implicit scalar detector. If an implicit scalar value matches the
- * given regexp, the corresponding tag is assigned to the scalar.
- *
- * @param tag
- * tag to assign to the node
- * @param regexp
- * regular expression to match against
- * @param first
- * a sequence of possible initial characters or null (which means
- * any).
- */
- public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
- resolver.addImplicitResolver(tag, regexp, first);
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- /**
- * Get a meaningful name. It simplifies debugging in a multi-threaded
- * environment. If nothing is set explicitly the address of the instance is
- * returned.
- *
- * @return human readable name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Set a meaningful name to be shown in toString()
- *
- * @param name
- * human readable name
- */
- public void setName(String name) {
- this.name = name;
- }
-
- /**
- * Parse a YAML stream and produce parsing events.
- *
- * @see http://yaml.org/spec/1.1/#id859333
- * @param yaml
- * YAML document(s)
- * @return parsed events
- */
- public Iterable<Event> parse(Reader yaml) {
- final Parser parser = new ParserImpl(new StreamReader(yaml));
- Iterator<Event> result = new Iterator<Event>() {
- public boolean hasNext() {
- return parser.peekEvent() != null;
- }
-
- public Event next() {
- return parser.getEvent();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- return new EventIterable(result);
- }
-
- private class EventIterable implements Iterable<Event> {
- private Iterator<Event> iterator;
-
- public EventIterable(Iterator<Event> iterator) {
- this.iterator = iterator;
- }
-
- public Iterator<Event> iterator() {
- return iterator;
- }
- }
-
- public void setBeanAccess(BeanAccess beanAccess) {
- constructor.getPropertyUtils().setBeanAccess(beanAccess);
- representer.getPropertyUtils().setBeanAccess(beanAccess);
- }
-
- // deprecated
- /**
- * @deprecated use with Constructor instead of Loader
- */
- public Yaml(Loader loader) {
- this(loader, new Dumper(new DumperOptions()));
- }
-
- /**
- * @deprecated use with Constructor instead of Loader
- */
- public Yaml(Loader loader, Dumper dumper) {
- this(loader, dumper, new Resolver());
- }
-
- /**
- * @deprecated use with Constructor instead of Loader
- */
- public Yaml(Loader loader, Dumper dumper, Resolver resolver) {
- this(loader.constructor, dumper.representer, dumper.options, resolver);
- }
-
- /**
- * Create Yaml instance. It is safe to create a few instances and use them
- * in different Threads.
- *
- * @param dumper
- * Dumper to emit outgoing objects
- */
- @SuppressWarnings("deprecation")
- public Yaml(Dumper dumper) {
- this(new Constructor(), dumper.representer, dumper.options);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Pattern;
+
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.composer.Composer;
+import org.yaml.snakeyaml.constructor.BaseConstructor;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.emitter.Emitable;
+import org.yaml.snakeyaml.emitter.Emitter;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.introspector.BeanAccess;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.parser.Parser;
+import org.yaml.snakeyaml.parser.ParserImpl;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+import org.yaml.snakeyaml.representer.Representer;
+import org.yaml.snakeyaml.resolver.Resolver;
+import org.yaml.snakeyaml.serializer.Serializer;
+
+/**
+ * Public YAML interface. Each Thread must have its own instance.
+ */
+public class Yaml {
+ protected final Resolver resolver;
+ private String name;
+ protected BaseConstructor constructor;
+ protected Representer representer;
+ protected DumperOptions dumperOptions;
+ protected LoaderOptions loaderOptions;
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ */
+ public Yaml() {
+ this(new Constructor(), new LoaderOptions(), new Representer(), new DumperOptions(),
+ new Resolver());
+ }
+
+ public Yaml(LoaderOptions loaderOptions) {
+ this(new Constructor(), loaderOptions, new Representer(), new DumperOptions(),
+ new Resolver());
+ }
+
+ /**
+ * Create Yaml instance.
+ *
+ * @param dumperOptions
+ * DumperOptions to configure outgoing objects
+ */
+ public Yaml(DumperOptions dumperOptions) {
+ this(new Constructor(), new Representer(), dumperOptions);
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param representer
+ * Representer to emit outgoing objects
+ */
+ public Yaml(Representer representer) {
+ this(new Constructor(), representer);
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param constructor
+ * BaseConstructor to construct incoming documents
+ */
+ public Yaml(BaseConstructor constructor) {
+ this(constructor, new Representer());
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param constructor
+ * BaseConstructor to construct incoming documents
+ * @param representer
+ * Representer to emit outgoing objects
+ */
+ public Yaml(BaseConstructor constructor, Representer representer) {
+ this(constructor, representer, new DumperOptions());
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param representer
+ * Representer to emit outgoing objects
+ * @param dumperOptions
+ * DumperOptions to configure outgoing objects
+ */
+ public Yaml(Representer representer, DumperOptions dumperOptions) {
+ this(new Constructor(), representer, dumperOptions, new Resolver());
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param constructor
+ * BaseConstructor to construct incoming documents
+ * @param representer
+ * Representer to emit outgoing objects
+ * @param dumperOptions
+ * DumperOptions to configure outgoing objects
+ */
+ public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions) {
+ this(constructor, representer, dumperOptions, new Resolver());
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param constructor
+ * BaseConstructor to construct incoming documents
+ * @param representer
+ * Representer to emit outgoing objects
+ * @param dumperOptions
+ * DumperOptions to configure outgoing objects
+ * @param resolver
+ * Resolver to detect implicit type
+ */
+ public Yaml(BaseConstructor constructor, Representer representer, DumperOptions dumperOptions,
+ Resolver resolver) {
+ this(constructor, new LoaderOptions(), representer, dumperOptions, resolver);
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param constructor
+ * BaseConstructor to construct incoming documents
+ * @param loaderOptions
+ * LoaderOptions to control construction process
+ * @param representer
+ * Representer to emit outgoing objects
+ * @param dumperOptions
+ * DumperOptions to configure outgoing objects
+ * @param resolver
+ * Resolver to detect implicit type
+ */
+ public Yaml(BaseConstructor constructor, LoaderOptions loaderOptions, Representer representer,
+ DumperOptions dumperOptions, Resolver resolver) {
+ if (!constructor.isExplicitPropertyUtils()) {
+ constructor.setPropertyUtils(representer.getPropertyUtils());
+ } else if (!representer.isExplicitPropertyUtils()) {
+ representer.setPropertyUtils(constructor.getPropertyUtils());
+ }
+ this.constructor = constructor;
+ this.loaderOptions = loaderOptions;
+ representer.setDefaultFlowStyle(dumperOptions.getDefaultFlowStyle());
+ representer.setDefaultScalarStyle(dumperOptions.getDefaultScalarStyle());
+ representer.getPropertyUtils().setAllowReadOnlyProperties(
+ dumperOptions.isAllowReadOnlyProperties());
+ this.representer = representer;
+ this.dumperOptions = dumperOptions;
+ this.resolver = resolver;
+ this.name = "Yaml:" + System.identityHashCode(this);
+ }
+
+ /**
+ * Serialize a Java object into a YAML String.
+ *
+ * @param data
+ * Java object to be Serialized to YAML
+ * @return YAML String
+ */
+ public String dump(Object data) {
+ List<Object> list = new ArrayList<Object>(1);
+ list.add(data);
+ return dumpAll(list.iterator());
+ }
+
+ /**
+ * Produce the corresponding representation tree for a given Object.
+ *
+ * @see http://yaml.org/spec/1.1/#id859333
+ * @param data
+ * instance to build the representation tree for
+ * @return representation tree
+ */
+ public Node represent(Object data) {
+ return representer.represent(data);
+ }
+
+ /**
+ * Serialize a sequence of Java objects into a YAML String.
+ *
+ * @param data
+ * Iterator with Objects
+ * @return YAML String with all the objects in proper sequence
+ */
+ public String dumpAll(Iterator<? extends Object> data) {
+ StringWriter buffer = new StringWriter();
+ dumpAll(data, buffer);
+ return buffer.toString();
+ }
+
+ /**
+ * Serialize a Java object into a YAML stream.
+ *
+ * @param data
+ * Java object to be serialized to YAML
+ * @param output
+ * stream to write to
+ */
+ public void dump(Object data, Writer output) {
+ List<Object> list = new ArrayList<Object>(1);
+ list.add(data);
+ dumpAll(list.iterator(), output);
+ }
+
+ /**
+ * Serialize a sequence of Java objects into a YAML stream.
+ *
+ * @param data
+ * Iterator with Objects
+ * @param output
+ * stream to write to
+ */
+ @SuppressWarnings("deprecation")
+ public void dumpAll(Iterator<? extends Object> data, Writer output) {
+ dumpAll(data, output, dumperOptions.getExplicitRoot());
+ }
+
+ private void dumpAll(Iterator<? extends Object> data, Writer output, Tag rootTag) {
+ Serializer serializer = new Serializer(new Emitter(output, dumperOptions), resolver,
+ dumperOptions, rootTag);
+ try {
+ serializer.open();
+ while (data.hasNext()) {
+ Node node = representer.represent(data.next());
+ serializer.serialize(node);
+ }
+ serializer.close();
+ } catch (java.io.IOException e) {
+ throw new YAMLException(e);
+ }
+ }
+
+ /**
+ * <p>
+ * Serialize a Java object into a YAML string. Override the default root tag
+ * with <code>rootTag</code>.
+ * </p>
+ *
+ * <p>
+ * This method is similar to <code>Yaml.dump(data)</code> except that the
+ * root tag for the whole document is replaced with the given tag. This has
+ * two main uses.
+ * </p>
+ *
+ * <p>
+ * First, if the root tag is replaced with a standard YAML tag, such as
+ * <code>Tag.MAP</code>, then the object will be dumped as a map. The root
+ * tag will appear as <code>!!map</code>, or blank (implicit !!map).
+ * </p>
+ *
+ * <p>
+ * Second, if the root tag is replaced by a different custom tag, then the
+ * document appears to be a different type when loaded. For example, if an
+ * instance of MyClass is dumped with the tag !!YourClass, then it will be
+ * handled as an instance of YourClass when loaded.
+ * </p>
+ *
+ * @param data
+ * Java object to be serialized to YAML
+ * @param rootTag
+ * the tag for the whole YAML document. The tag should be Tag.MAP
+ * for a JavaBean to make the tag disappear (to use implicit tag
+ * !!map). If <code>null</code> is provided then the standard tag
+ * with the full class name is used.
+ * @param flowStyle
+ * flow style for the whole document. See Chapter 10. Collection
+ * Styles http://yaml.org/spec/1.1/#id930798. If
+ * <code>null</code> is provided then the flow style from
+ * DumperOptions is used.
+ *
+ * @return YAML String
+ */
+ public String dumpAs(Object data, Tag rootTag, FlowStyle flowStyle) {
+ FlowStyle oldStyle = representer.getDefaultFlowStyle();
+ if (flowStyle != null) {
+ representer.setDefaultFlowStyle(flowStyle);
+ }
+ List<Object> list = new ArrayList<Object>(1);
+ list.add(data);
+ StringWriter buffer = new StringWriter();
+ dumpAll(list.iterator(), buffer, rootTag);
+ representer.setDefaultFlowStyle(oldStyle);
+ return buffer.toString();
+ }
+
+ /**
+ * <p>
+ * Serialize a Java object into a YAML string. Override the default root tag
+ * with <code>Tag.MAP</code>.
+ * </p>
+ * <p>
+ * This method is similar to <code>Yaml.dump(data)</code> except that the
+ * root tag for the whole document is replaced with <code>Tag.MAP</code> tag
+ * (implicit !!map).
+ * </p>
+ * <p>
+ * Block Mapping is used as the collection style. See 10.2.2. Block Mappings
+ * (http://yaml.org/spec/1.1/#id934537)
+ * </p>
+ *
+ * @param data
+ * Java object to be serialized to YAML
+ * @return YAML String
+ */
+ public String dumpAsMap(Object data) {
+ return dumpAs(data, Tag.MAP, FlowStyle.BLOCK);
+ }
+
+ /**
+ * Serialize the representation tree into Events.
+ *
+ * @see http://yaml.org/spec/1.1/#id859333
+ * @param data
+ * representation tree
+ * @return Event list
+ */
+ public List<Event> serialize(Node data) {
+ SilentEmitter emitter = new SilentEmitter();
+ @SuppressWarnings("deprecation")
+ Serializer serializer = new Serializer(emitter, resolver, dumperOptions,
+ dumperOptions.getExplicitRoot());
+ try {
+ serializer.open();
+ serializer.serialize(data);
+ serializer.close();
+ } catch (java.io.IOException e) {
+ throw new YAMLException(e);
+ }
+ return emitter.getEvents();
+ }
+
+ private class SilentEmitter implements Emitable {
+ private List<Event> events = new ArrayList<Event>(100);
+
+ public List<Event> getEvents() {
+ return events;
+ }
+
+ public void emit(Event event) throws IOException {
+ events.add(event);
+ }
+ }
+
+ /**
+ * Parse the only YAML document in a String and produce the corresponding
+ * Java object. (Because the encoding in known BOM is not respected.)
+ *
+ * @param yaml
+ * YAML data to load from (BOM must not be present)
+ * @return parsed object
+ */
+ public Object load(String yaml) {
+ return loadFromReader(new StreamReader(yaml), Object.class);
+ }
+
+ /**
+ * Parse the only YAML document in a stream and produce the corresponding
+ * Java object.
+ *
+ * @param io
+ * data to load from (BOM is respected and removed)
+ * @return parsed object
+ */
+ public Object load(InputStream io) {
+ return loadFromReader(new StreamReader(new UnicodeReader(io)), Object.class);
+ }
+
+ /**
+ * Parse the only YAML document in a stream and produce the corresponding
+ * Java object.
+ *
+ * @param io
+ * data to load from (BOM must not be present)
+ * @return parsed object
+ */
+ public Object load(Reader io) {
+ return loadFromReader(new StreamReader(io), Object.class);
+ }
+
+ /**
+ * Parse the only YAML document in a stream and produce the corresponding
+ * Java object.
+ *
+ * @param <T>
+ * Class is defined by the second argument
+ * @param io
+ * data to load from (BOM must not be present)
+ * @param type
+ * Class of the object to be created
+ * @return parsed object
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T loadAs(Reader io, Class<T> type) {
+ return (T) loadFromReader(new StreamReader(io), type);
+ }
+
+ /**
+ * Parse the only YAML document in a String and produce the corresponding
+ * Java object. (Because the encoding in known BOM is not respected.)
+ *
+ * @param <T>
+ * Class is defined by the second argument
+ * @param yaml
+ * YAML data to load from (BOM must not be present)
+ * @param type
+ * Class of the object to be created
+ * @return parsed object
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T loadAs(String yaml, Class<T> type) {
+ return (T) loadFromReader(new StreamReader(yaml), type);
+ }
+
+ /**
+ * Parse the only YAML document in a stream and produce the corresponding
+ * Java object.
+ *
+ * @param <T>
+ * Class is defined by the second argument
+ * @param input
+ * data to load from (BOM is respected and removed)
+ * @param type
+ * Class of the object to be created
+ * @return parsed object
+ */
+ @SuppressWarnings("unchecked")
+ public <T> T loadAs(InputStream input, Class<T> type) {
+ return (T) loadFromReader(new StreamReader(new UnicodeReader(input)), type);
+ }
+
+ private Object loadFromReader(StreamReader sreader, Class<?> type) {
+ Composer composer = new Composer(new ParserImpl(sreader), resolver);
+ constructor.setComposer(composer);
+ return constructor.getSingleData(type);
+ }
+
+ /**
+ * Parse all YAML documents in a String and produce corresponding Java
+ * objects. The documents are parsed only when the iterator is invoked.
+ *
+ * @param yaml
+ * YAML data to load from (BOM must not be present)
+ * @return an iterator over the parsed Java objects in this String in proper
+ * sequence
+ */
+ public Iterable<Object> loadAll(Reader yaml) {
+ Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
+ constructor.setComposer(composer);
+ Iterator<Object> result = new Iterator<Object>() {
+ public boolean hasNext() {
+ return constructor.checkData();
+ }
+
+ public Object next() {
+ return constructor.getData();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ return new YamlIterable(result);
+ }
+
+ private class YamlIterable implements Iterable<Object> {
+ private Iterator<Object> iterator;
+
+ public YamlIterable(Iterator<Object> iterator) {
+ this.iterator = iterator;
+ }
+
+ public Iterator<Object> iterator() {
+ return iterator;
+ }
+
+ }
+
+ /**
+ * Parse all YAML documents in a String and produce corresponding Java
+ * objects. (Because the encoding in known BOM is not respected.) The
+ * documents are parsed only when the iterator is invoked.
+ *
+ * @param yaml
+ * YAML data to load from (BOM must not be present)
+ * @return an iterator over the parsed Java objects in this String in proper
+ * sequence
+ */
+ public Iterable<Object> loadAll(String yaml) {
+ return loadAll(new StringReader(yaml));
+ }
+
+ /**
+ * Parse all YAML documents in a stream and produce corresponding Java
+ * objects. The documents are parsed only when the iterator is invoked.
+ *
+ * @param yaml
+ * YAML data to load from (BOM is respected and ignored)
+ * @return an iterator over the parsed Java objects in this stream in proper
+ * sequence
+ */
+ public Iterable<Object> loadAll(InputStream yaml) {
+ return loadAll(new UnicodeReader(yaml));
+ }
+
+ /**
+ * Parse the first YAML document in a stream and produce the corresponding
+ * representation tree. (This is the opposite of the represent() method)
+ *
+ * @see http://yaml.org/spec/1.1/#id859333
+ * @param yaml
+ * YAML document
+ * @return parsed root Node for the specified YAML document
+ */
+ public Node compose(Reader yaml) {
+ Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
+ constructor.setComposer(composer);
+ return composer.getSingleNode();
+ }
+
+ /**
+ * Parse all YAML documents in a stream and produce corresponding
+ * representation trees.
+ *
+ * @see http://yaml.org/spec/1.1/#id859333
+ * @param yaml
+ * stream of YAML documents
+ * @return parsed root Nodes for all the specified YAML documents
+ */
+ public Iterable<Node> composeAll(Reader yaml) {
+ final Composer composer = new Composer(new ParserImpl(new StreamReader(yaml)), resolver);
+ constructor.setComposer(composer);
+ Iterator<Node> result = new Iterator<Node>() {
+ public boolean hasNext() {
+ return composer.checkNode();
+ }
+
+ public Node next() {
+ return composer.getNode();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ return new NodeIterable(result);
+ }
+
+ private class NodeIterable implements Iterable<Node> {
+ private Iterator<Node> iterator;
+
+ public NodeIterable(Iterator<Node> iterator) {
+ this.iterator = iterator;
+ }
+
+ public Iterator<Node> iterator() {
+ return iterator;
+ }
+ }
+
+ /**
+ * Add an implicit scalar detector. If an implicit scalar value matches the
+ * given regexp, the corresponding tag is assigned to the scalar.
+ *
+ * @deprecated use Tag instead of String
+ * @param tag
+ * tag to assign to the node
+ * @param regexp
+ * regular expression to match against
+ * @param first
+ * a sequence of possible initial characters or null (which means
+ * any).
+ *
+ */
+ public void addImplicitResolver(String tag, Pattern regexp, String first) {
+ addImplicitResolver(new Tag(tag), regexp, first);
+ }
+
+ /**
+ * Add an implicit scalar detector. If an implicit scalar value matches the
+ * given regexp, the corresponding tag is assigned to the scalar.
+ *
+ * @param tag
+ * tag to assign to the node
+ * @param regexp
+ * regular expression to match against
+ * @param first
+ * a sequence of possible initial characters or null (which means
+ * any).
+ */
+ public void addImplicitResolver(Tag tag, Pattern regexp, String first) {
+ resolver.addImplicitResolver(tag, regexp, first);
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+
+ /**
+ * Get a meaningful name. It simplifies debugging in a multi-threaded
+ * environment. If nothing is set explicitly the address of the instance is
+ * returned.
+ *
+ * @return human readable name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Set a meaningful name to be shown in toString()
+ *
+ * @param name
+ * human readable name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Parse a YAML stream and produce parsing events.
+ *
+ * @see http://yaml.org/spec/1.1/#id859333
+ * @param yaml
+ * YAML document(s)
+ * @return parsed events
+ */
+ public Iterable<Event> parse(Reader yaml) {
+ final Parser parser = new ParserImpl(new StreamReader(yaml));
+ Iterator<Event> result = new Iterator<Event>() {
+ public boolean hasNext() {
+ return parser.peekEvent() != null;
+ }
+
+ public Event next() {
+ return parser.getEvent();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ return new EventIterable(result);
+ }
+
+ private class EventIterable implements Iterable<Event> {
+ private Iterator<Event> iterator;
+
+ public EventIterable(Iterator<Event> iterator) {
+ this.iterator = iterator;
+ }
+
+ public Iterator<Event> iterator() {
+ return iterator;
+ }
+ }
+
+ public void setBeanAccess(BeanAccess beanAccess) {
+ constructor.getPropertyUtils().setBeanAccess(beanAccess);
+ representer.getPropertyUtils().setBeanAccess(beanAccess);
+ }
+
+ // deprecated
+ /**
+ * @deprecated use with Constructor instead of Loader
+ */
+ public Yaml(Loader loader) {
+ this(loader, new Dumper(new DumperOptions()));
+ }
+
+ /**
+ * @deprecated use with Constructor instead of Loader
+ */
+ public Yaml(Loader loader, Dumper dumper) {
+ this(loader, dumper, new Resolver());
+ }
+
+ /**
+ * @deprecated use with Constructor instead of Loader
+ */
+ public Yaml(Loader loader, Dumper dumper, Resolver resolver) {
+ this(loader.constructor, dumper.representer, dumper.options, resolver);
+ }
+
+ /**
+ * Create Yaml instance. It is safe to create a few instances and use them
+ * in different Threads.
+ *
+ * @param dumper
+ * Dumper to emit outgoing objects
+ */
+ @SuppressWarnings("deprecation")
+ public Yaml(Dumper dumper) {
+ this(new Constructor(), dumper.representer, dumper.options);
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/constructor/Construct.java b/src/main/java/org/yaml/snakeyaml/constructor/Construct.java
index 3a8aac4..bee8bea 100644
--- a/src/main/java/org/yaml/snakeyaml/constructor/Construct.java
+++ b/src/main/java/org/yaml/snakeyaml/constructor/Construct.java
@@ -1,50 +1,50 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import org.yaml.snakeyaml.nodes.Node;
-
-/**
- * Provide a way to construct a Java instance out of the composed Node. Support
- * recursive objects if it is required. (create Native Data Structure out of
- * Node Graph)
- *
- * @see http://yaml.org/spec/1.1/#id859109
- */
-public interface Construct {
- /**
- * Construct a Java instance with all the properties injected when it is
- * possible.
- *
- * @param node
- * composed Node
- * @return a complete Java instance
- */
- public Object construct(Node node);
-
- /**
- * Apply the second step when constructing recursive structures. Because the
- * instance is already created it can assign a reference to itself.
- *
- * @param node
- * composed Node
- * @param object
- * the instance constructed earlier by
- * <code>construct(Node node)</code> for the provided Node
- */
- public void construct2ndStep(Node node, Object object);
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import org.yaml.snakeyaml.nodes.Node;
+
+/**
+ * Provide a way to construct a Java instance out of the composed Node. Support
+ * recursive objects if it is required. (create Native Data Structure out of
+ * Node Graph)
+ *
+ * @see http://yaml.org/spec/1.1/#id859109
+ */
+public interface Construct {
+ /**
+ * Construct a Java instance with all the properties injected when it is
+ * possible.
+ *
+ * @param node
+ * composed Node
+ * @return a complete Java instance
+ */
+ public Object construct(Node node);
+
+ /**
+ * Apply the second step when constructing recursive structures. Because the
+ * instance is already created it can assign a reference to itself.
+ *
+ * @param node
+ * composed Node
+ * @param object
+ * the instance constructed earlier by
+ * <code>construct(Node node)</code> for the provided Node
+ */
+ public void construct2ndStep(Node node, Object object);
+}
diff --git a/src/main/java/org/yaml/snakeyaml/constructor/SafeConstructor.java b/src/main/java/org/yaml/snakeyaml/constructor/SafeConstructor.java
index fc599fd..64d838f 100644
--- a/src/main/java/org/yaml/snakeyaml/constructor/SafeConstructor.java
+++ b/src/main/java/org/yaml/snakeyaml/constructor/SafeConstructor.java
@@ -1,480 +1,480 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeId;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Construct standard Java classes
- */
-public class SafeConstructor extends BaseConstructor {
-
- public static ConstructUndefined undefinedConstructor = new ConstructUndefined();
-
- public SafeConstructor() {
- this.yamlConstructors.put(Tag.NULL, new ConstructYamlNull());
- this.yamlConstructors.put(Tag.BOOL, new ConstructYamlBool());
- this.yamlConstructors.put(Tag.INT, new ConstructYamlInt());
- this.yamlConstructors.put(Tag.FLOAT, new ConstructYamlFloat());
- this.yamlConstructors.put(Tag.BINARY, new ConstructYamlBinary());
- this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructYamlTimestamp());
- this.yamlConstructors.put(Tag.OMAP, new ConstructYamlOmap());
- this.yamlConstructors.put(Tag.PAIRS, new ConstructYamlPairs());
- this.yamlConstructors.put(Tag.SET, new ConstructYamlSet());
- this.yamlConstructors.put(Tag.STR, new ConstructYamlStr());
- this.yamlConstructors.put(Tag.SEQ, new ConstructYamlSeq());
- this.yamlConstructors.put(Tag.MAP, new ConstructYamlMap());
- this.yamlConstructors.put(null, undefinedConstructor);
- this.yamlClassConstructors.put(NodeId.scalar, undefinedConstructor);
- this.yamlClassConstructors.put(NodeId.sequence, undefinedConstructor);
- this.yamlClassConstructors.put(NodeId.mapping, undefinedConstructor);
- }
-
- protected void flattenMapping(MappingNode node) {
- // perform merging only on nodes containing merge node(s)
- if (node.isMerged()) {
- node.setValue(mergeNode(node, true, new HashMap<Object, Integer>(),
- new ArrayList<NodeTuple>()));
- }
- }
-
- /**
- * Does merge for supplied mapping node.
- *
- * @param node
- * where to merge
- * @param isPreffered
- * true if keys of node should take precedence over others...
- * @param key2index
- * maps already merged keys to index from values
- * @param values
- * collects merged NodeTuple
- * @return list of the merged NodeTuple (to be set as value for the
- * MappingNode)
- */
- private List<NodeTuple> mergeNode(MappingNode node, boolean isPreffered,
- Map<Object, Integer> key2index, List<NodeTuple> values) {
- List<NodeTuple> nodeValue = node.getValue();
- for (Iterator<NodeTuple> iter = nodeValue.iterator(); iter.hasNext();) {
- final NodeTuple nodeTuple = iter.next();
- final Node keyNode = nodeTuple.getKeyNode();
- final Node valueNode = nodeTuple.getValueNode();
- if (keyNode.getTag().equals(Tag.MERGE)) {
- iter.remove();
- switch (valueNode.getNodeId()) {
- case mapping:
- MappingNode mn = (MappingNode) valueNode;
- mergeNode(mn, false, key2index, values);
- break;
- case sequence:
- SequenceNode sn = (SequenceNode) valueNode;
- List<Node> vals = sn.getValue();
- for (Node subnode : vals) {
- if (!(subnode instanceof MappingNode)) {
- throw new ConstructorException("while constructing a mapping",
- node.getStartMark(),
- "expected a mapping for merging, but found "
- + subnode.getNodeId(), subnode.getStartMark());
- }
- MappingNode mnode = (MappingNode) subnode;
- mergeNode(mnode, false, key2index, values);
- }
- break;
- default:
- throw new ConstructorException("while constructing a mapping",
- node.getStartMark(),
- "expected a mapping or list of mappings for merging, but found "
- + valueNode.getNodeId(), valueNode.getStartMark());
- }
- } else {
- // we need to construct keys to avoid duplications
- Object key = constructObject(keyNode);
- if (!key2index.containsKey(key)) { // 1st time merging key
- values.add(nodeTuple);
- // keep track where tuple for the key is
- key2index.put(key, values.size() - 1);
- } else if (isPreffered) { // there is value for the key, but we
- // need to override it
- // change value for the key using saved position
- values.set(key2index.get(key), nodeTuple);
- }
- }
- }
- return values;
- }
-
- protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
- flattenMapping(node);
- super.constructMapping2ndStep(node, mapping);
- }
-
- @Override
- protected void constructSet2ndStep(MappingNode node, java.util.Set<Object> set) {
- flattenMapping(node);
- super.constructSet2ndStep(node, set);
- }
-
- public class ConstructYamlNull extends AbstractConstruct {
- public Object construct(Node node) {
- constructScalar((ScalarNode) node);
- return null;
- }
- }
-
- private final static Map<String, Boolean> BOOL_VALUES = new HashMap<String, Boolean>();
- static {
- BOOL_VALUES.put("yes", Boolean.TRUE);
- BOOL_VALUES.put("no", Boolean.FALSE);
- BOOL_VALUES.put("true", Boolean.TRUE);
- BOOL_VALUES.put("false", Boolean.FALSE);
- BOOL_VALUES.put("on", Boolean.TRUE);
- BOOL_VALUES.put("off", Boolean.FALSE);
- }
-
- public class ConstructYamlBool extends AbstractConstruct {
- public Object construct(Node node) {
- String val = (String) constructScalar((ScalarNode) node);
- return BOOL_VALUES.get(val.toLowerCase());
- }
- }
-
- public class ConstructYamlInt extends AbstractConstruct {
- public Object construct(Node node) {
- String value = constructScalar((ScalarNode) node).toString().replaceAll("_", "");
- int sign = +1;
- char first = value.charAt(0);
- if (first == '-') {
- sign = -1;
- value = value.substring(1);
- } else if (first == '+') {
- value = value.substring(1);
- }
- int base = 10;
- if ("0".equals(value)) {
- return new Integer(0);
- } else if (value.startsWith("0b")) {
- value = value.substring(2);
- base = 2;
- } else if (value.startsWith("0x")) {
- value = value.substring(2);
- base = 16;
- } else if (value.startsWith("0")) {
- value = value.substring(1);
- base = 8;
- } else if (value.indexOf(':') != -1) {
- String[] digits = value.split(":");
- int bes = 1;
- int val = 0;
- for (int i = 0, j = digits.length; i < j; i++) {
- val += (Long.parseLong(digits[(j - i) - 1]) * bes);
- bes *= 60;
- }
- return createNumber(sign, String.valueOf(val), 10);
- } else {
- return createNumber(sign, value, 10);
- }
- return createNumber(sign, value, base);
- }
- }
-
- private Number createNumber(int sign, String number, int radix) {
- Number result;
- if (sign < 0) {
- number = "-" + number;
- }
- try {
- result = Integer.valueOf(number, radix);
- } catch (NumberFormatException e) {
- try {
- result = Long.valueOf(number, radix);
- } catch (NumberFormatException e1) {
- result = new BigInteger(number, radix);
- }
- }
- return result;
- }
-
- public class ConstructYamlFloat extends AbstractConstruct {
- public Object construct(Node node) {
- String value = constructScalar((ScalarNode) node).toString().replaceAll("_", "");
- int sign = +1;
- char first = value.charAt(0);
- if (first == '-') {
- sign = -1;
- value = value.substring(1);
- } else if (first == '+') {
- value = value.substring(1);
- }
- String valLower = value.toLowerCase();
- if (".inf".equals(valLower)) {
- return new Double(sign == -1 ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY);
- } else if (".nan".equals(valLower)) {
- return new Double(Double.NaN);
- } else if (value.indexOf(':') != -1) {
- String[] digits = value.split(":");
- int bes = 1;
- double val = 0.0;
- for (int i = 0, j = digits.length; i < j; i++) {
- val += (Double.parseDouble(digits[(j - i) - 1]) * bes);
- bes *= 60;
- }
- return new Double(sign * val);
- } else {
- Double d = Double.valueOf(value);
- return new Double(d.doubleValue() * sign);
- }
- }
- }
-
- public class ConstructYamlBinary extends AbstractConstruct {
- public Object construct(Node node) {
- byte[] decoded = Base64Coder.decode(constructScalar((ScalarNode) node).toString()
- .toCharArray());
- return decoded;
- }
- }
-
- private final static Pattern TIMESTAMP_REGEXP = Pattern
- .compile("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \t]*(?:Z|([-+][0-9][0-9]?)(?::([0-9][0-9])?)?))?)?$");
- private final static Pattern YMD_REGEXP = Pattern
- .compile("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)$");
-
- public class ConstructYamlTimestamp extends AbstractConstruct {
- private Calendar calendar;
-
- public Calendar getCalendar() {
- return calendar;
- }
-
- public Object construct(Node node) {
- ScalarNode scalar = (ScalarNode) node;
- String nodeValue = scalar.getValue();
- Matcher match = YMD_REGEXP.matcher(nodeValue);
- if (match.matches()) {
- String year_s = match.group(1);
- String month_s = match.group(2);
- String day_s = match.group(3);
- calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- calendar.clear();
- calendar.set(Calendar.YEAR, Integer.parseInt(year_s));
- // Java's months are zero-based...
- calendar.set(Calendar.MONTH, Integer.parseInt(month_s) - 1); // x
- calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day_s));
- return calendar.getTime();
- } else {
- match = TIMESTAMP_REGEXP.matcher(nodeValue);
- if (!match.matches()) {
- throw new YAMLException("Unexpected timestamp: " + nodeValue);
- }
- String year_s = match.group(1);
- String month_s = match.group(2);
- String day_s = match.group(3);
- String hour_s = match.group(4);
- String min_s = match.group(5);
- // seconds and milliseconds
- String seconds = match.group(6);
- String millis = match.group(7);
- if (millis != null) {
- seconds = seconds + "." + millis;
- }
- double fractions = Double.parseDouble(seconds);
- int sec_s = (int) Math.round(Math.floor(fractions));
- int usec = (int) Math.round(((fractions - sec_s) * 1000));
- // timezone
- String timezoneh_s = match.group(8);
- String timezonem_s = match.group(9);
- TimeZone timeZone;
- if (timezoneh_s != null) {
- String time = timezonem_s != null ? ":" + timezonem_s : "00";
- timeZone = TimeZone.getTimeZone("GMT" + timezoneh_s + time);
- } else {
- // no time zone provided
- timeZone = TimeZone.getTimeZone("UTC");
- }
- calendar = Calendar.getInstance(timeZone);
- calendar.set(Calendar.YEAR, Integer.parseInt(year_s));
- // Java's months are zero-based...
- calendar.set(Calendar.MONTH, Integer.parseInt(month_s) - 1);
- calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day_s));
- calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hour_s));
- calendar.set(Calendar.MINUTE, Integer.parseInt(min_s));
- calendar.set(Calendar.SECOND, sec_s);
- calendar.set(Calendar.MILLISECOND, usec);
- return calendar.getTime();
- }
- }
- }
-
- public class ConstructYamlOmap extends AbstractConstruct {
- public Object construct(Node node) {
- // Note: we do not check for duplicate keys, because it's too
- // CPU-expensive.
- Map<Object, Object> omap = new LinkedHashMap<Object, Object>();
- if (!(node instanceof SequenceNode)) {
- throw new ConstructorException("while constructing an ordered map",
- node.getStartMark(), "expected a sequence, but found " + node.getNodeId(),
- node.getStartMark());
- }
- SequenceNode snode = (SequenceNode) node;
- for (Node subnode : snode.getValue()) {
- if (!(subnode instanceof MappingNode)) {
- throw new ConstructorException("while constructing an ordered map",
- node.getStartMark(), "expected a mapping of length 1, but found "
- + subnode.getNodeId(), subnode.getStartMark());
- }
- MappingNode mnode = (MappingNode) subnode;
- if (mnode.getValue().size() != 1) {
- throw new ConstructorException("while constructing an ordered map",
- node.getStartMark(), "expected a single mapping item, but found "
- + mnode.getValue().size() + " items", mnode.getStartMark());
- }
- Node keyNode = mnode.getValue().get(0).getKeyNode();
- Node valueNode = mnode.getValue().get(0).getValueNode();
- Object key = constructObject(keyNode);
- Object value = constructObject(valueNode);
- omap.put(key, value);
- }
- return omap;
- }
- }
-
- // Note: the same code as `construct_yaml_omap`.
- public class ConstructYamlPairs extends AbstractConstruct {
- public Object construct(Node node) {
- // Note: we do not check for duplicate keys, because it's too
- // CPU-expensive.
- if (!(node instanceof SequenceNode)) {
- throw new ConstructorException("while constructing pairs", node.getStartMark(),
- "expected a sequence, but found " + node.getNodeId(), node.getStartMark());
- }
- SequenceNode snode = (SequenceNode) node;
- List<Object[]> pairs = new ArrayList<Object[]>(snode.getValue().size());
- for (Node subnode : snode.getValue()) {
- if (!(subnode instanceof MappingNode)) {
- throw new ConstructorException("while constructingpairs", node.getStartMark(),
- "expected a mapping of length 1, but found " + subnode.getNodeId(),
- subnode.getStartMark());
- }
- MappingNode mnode = (MappingNode) subnode;
- if (mnode.getValue().size() != 1) {
- throw new ConstructorException("while constructing pairs", node.getStartMark(),
- "expected a single mapping item, but found " + mnode.getValue().size()
- + " items", mnode.getStartMark());
- }
- Node keyNode = mnode.getValue().get(0).getKeyNode();
- Node valueNode = mnode.getValue().get(0).getValueNode();
- Object key = constructObject(keyNode);
- Object value = constructObject(valueNode);
- pairs.add(new Object[] { key, value });
- }
- return pairs;
- }
- }
-
- public class ConstructYamlSet implements Construct {
- public Object construct(Node node) {
- if (node.isTwoStepsConstruction()) {
- return createDefaultSet();
- } else {
- return constructSet((MappingNode) node);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void construct2ndStep(Node node, Object object) {
- if (node.isTwoStepsConstruction()) {
- constructSet2ndStep((MappingNode) node, (Set<Object>) object);
- } else {
- throw new YAMLException("Unexpected recursive set structure. Node: " + node);
- }
- }
- }
-
- public class ConstructYamlStr extends AbstractConstruct {
- public Object construct(Node node) {
- return constructScalar((ScalarNode) node);
- }
- }
-
- public class ConstructYamlSeq implements Construct {
- public Object construct(Node node) {
- SequenceNode seqNode = (SequenceNode) node;
- if (node.isTwoStepsConstruction()) {
- return createDefaultList((seqNode.getValue()).size());
- } else {
- return constructSequence(seqNode);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void construct2ndStep(Node node, Object data) {
- if (node.isTwoStepsConstruction()) {
- constructSequenceStep2((SequenceNode) node, (List<Object>) data);
- } else {
- throw new YAMLException("Unexpected recursive sequence structure. Node: " + node);
- }
- }
- }
-
- public class ConstructYamlMap implements Construct {
- public Object construct(Node node) {
- if (node.isTwoStepsConstruction()) {
- return createDefaultMap();
- } else {
- return constructMapping((MappingNode) node);
- }
- }
-
- @SuppressWarnings("unchecked")
- public void construct2ndStep(Node node, Object object) {
- if (node.isTwoStepsConstruction()) {
- constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object);
- } else {
- throw new YAMLException("Unexpected recursive mapping structure. Node: " + node);
- }
- }
- }
-
- public static final class ConstructUndefined extends AbstractConstruct {
- public Object construct(Node node) {
- throw new ConstructorException(null, null,
- "could not determine a constructor for the tag " + node.getTag(),
- node.getStartMark());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeId;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Construct standard Java classes
+ */
+public class SafeConstructor extends BaseConstructor {
+
+ public static ConstructUndefined undefinedConstructor = new ConstructUndefined();
+
+ public SafeConstructor() {
+ this.yamlConstructors.put(Tag.NULL, new ConstructYamlNull());
+ this.yamlConstructors.put(Tag.BOOL, new ConstructYamlBool());
+ this.yamlConstructors.put(Tag.INT, new ConstructYamlInt());
+ this.yamlConstructors.put(Tag.FLOAT, new ConstructYamlFloat());
+ this.yamlConstructors.put(Tag.BINARY, new ConstructYamlBinary());
+ this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructYamlTimestamp());
+ this.yamlConstructors.put(Tag.OMAP, new ConstructYamlOmap());
+ this.yamlConstructors.put(Tag.PAIRS, new ConstructYamlPairs());
+ this.yamlConstructors.put(Tag.SET, new ConstructYamlSet());
+ this.yamlConstructors.put(Tag.STR, new ConstructYamlStr());
+ this.yamlConstructors.put(Tag.SEQ, new ConstructYamlSeq());
+ this.yamlConstructors.put(Tag.MAP, new ConstructYamlMap());
+ this.yamlConstructors.put(null, undefinedConstructor);
+ this.yamlClassConstructors.put(NodeId.scalar, undefinedConstructor);
+ this.yamlClassConstructors.put(NodeId.sequence, undefinedConstructor);
+ this.yamlClassConstructors.put(NodeId.mapping, undefinedConstructor);
+ }
+
+ protected void flattenMapping(MappingNode node) {
+ // perform merging only on nodes containing merge node(s)
+ if (node.isMerged()) {
+ node.setValue(mergeNode(node, true, new HashMap<Object, Integer>(),
+ new ArrayList<NodeTuple>()));
+ }
+ }
+
+ /**
+ * Does merge for supplied mapping node.
+ *
+ * @param node
+ * where to merge
+ * @param isPreffered
+ * true if keys of node should take precedence over others...
+ * @param key2index
+ * maps already merged keys to index from values
+ * @param values
+ * collects merged NodeTuple
+ * @return list of the merged NodeTuple (to be set as value for the
+ * MappingNode)
+ */
+ private List<NodeTuple> mergeNode(MappingNode node, boolean isPreffered,
+ Map<Object, Integer> key2index, List<NodeTuple> values) {
+ List<NodeTuple> nodeValue = node.getValue();
+ for (Iterator<NodeTuple> iter = nodeValue.iterator(); iter.hasNext();) {
+ final NodeTuple nodeTuple = iter.next();
+ final Node keyNode = nodeTuple.getKeyNode();
+ final Node valueNode = nodeTuple.getValueNode();
+ if (keyNode.getTag().equals(Tag.MERGE)) {
+ iter.remove();
+ switch (valueNode.getNodeId()) {
+ case mapping:
+ MappingNode mn = (MappingNode) valueNode;
+ mergeNode(mn, false, key2index, values);
+ break;
+ case sequence:
+ SequenceNode sn = (SequenceNode) valueNode;
+ List<Node> vals = sn.getValue();
+ for (Node subnode : vals) {
+ if (!(subnode instanceof MappingNode)) {
+ throw new ConstructorException("while constructing a mapping",
+ node.getStartMark(),
+ "expected a mapping for merging, but found "
+ + subnode.getNodeId(), subnode.getStartMark());
+ }
+ MappingNode mnode = (MappingNode) subnode;
+ mergeNode(mnode, false, key2index, values);
+ }
+ break;
+ default:
+ throw new ConstructorException("while constructing a mapping",
+ node.getStartMark(),
+ "expected a mapping or list of mappings for merging, but found "
+ + valueNode.getNodeId(), valueNode.getStartMark());
+ }
+ } else {
+ // we need to construct keys to avoid duplications
+ Object key = constructObject(keyNode);
+ if (!key2index.containsKey(key)) { // 1st time merging key
+ values.add(nodeTuple);
+ // keep track where tuple for the key is
+ key2index.put(key, values.size() - 1);
+ } else if (isPreffered) { // there is value for the key, but we
+ // need to override it
+ // change value for the key using saved position
+ values.set(key2index.get(key), nodeTuple);
+ }
+ }
+ }
+ return values;
+ }
+
+ protected void constructMapping2ndStep(MappingNode node, Map<Object, Object> mapping) {
+ flattenMapping(node);
+ super.constructMapping2ndStep(node, mapping);
+ }
+
+ @Override
+ protected void constructSet2ndStep(MappingNode node, java.util.Set<Object> set) {
+ flattenMapping(node);
+ super.constructSet2ndStep(node, set);
+ }
+
+ public class ConstructYamlNull extends AbstractConstruct {
+ public Object construct(Node node) {
+ constructScalar((ScalarNode) node);
+ return null;
+ }
+ }
+
+ private final static Map<String, Boolean> BOOL_VALUES = new HashMap<String, Boolean>();
+ static {
+ BOOL_VALUES.put("yes", Boolean.TRUE);
+ BOOL_VALUES.put("no", Boolean.FALSE);
+ BOOL_VALUES.put("true", Boolean.TRUE);
+ BOOL_VALUES.put("false", Boolean.FALSE);
+ BOOL_VALUES.put("on", Boolean.TRUE);
+ BOOL_VALUES.put("off", Boolean.FALSE);
+ }
+
+ public class ConstructYamlBool extends AbstractConstruct {
+ public Object construct(Node node) {
+ String val = (String) constructScalar((ScalarNode) node);
+ return BOOL_VALUES.get(val.toLowerCase());
+ }
+ }
+
+ public class ConstructYamlInt extends AbstractConstruct {
+ public Object construct(Node node) {
+ String value = constructScalar((ScalarNode) node).toString().replaceAll("_", "");
+ int sign = +1;
+ char first = value.charAt(0);
+ if (first == '-') {
+ sign = -1;
+ value = value.substring(1);
+ } else if (first == '+') {
+ value = value.substring(1);
+ }
+ int base = 10;
+ if ("0".equals(value)) {
+ return new Integer(0);
+ } else if (value.startsWith("0b")) {
+ value = value.substring(2);
+ base = 2;
+ } else if (value.startsWith("0x")) {
+ value = value.substring(2);
+ base = 16;
+ } else if (value.startsWith("0")) {
+ value = value.substring(1);
+ base = 8;
+ } else if (value.indexOf(':') != -1) {
+ String[] digits = value.split(":");
+ int bes = 1;
+ int val = 0;
+ for (int i = 0, j = digits.length; i < j; i++) {
+ val += (Long.parseLong(digits[(j - i) - 1]) * bes);
+ bes *= 60;
+ }
+ return createNumber(sign, String.valueOf(val), 10);
+ } else {
+ return createNumber(sign, value, 10);
+ }
+ return createNumber(sign, value, base);
+ }
+ }
+
+ private Number createNumber(int sign, String number, int radix) {
+ Number result;
+ if (sign < 0) {
+ number = "-" + number;
+ }
+ try {
+ result = Integer.valueOf(number, radix);
+ } catch (NumberFormatException e) {
+ try {
+ result = Long.valueOf(number, radix);
+ } catch (NumberFormatException e1) {
+ result = new BigInteger(number, radix);
+ }
+ }
+ return result;
+ }
+
+ public class ConstructYamlFloat extends AbstractConstruct {
+ public Object construct(Node node) {
+ String value = constructScalar((ScalarNode) node).toString().replaceAll("_", "");
+ int sign = +1;
+ char first = value.charAt(0);
+ if (first == '-') {
+ sign = -1;
+ value = value.substring(1);
+ } else if (first == '+') {
+ value = value.substring(1);
+ }
+ String valLower = value.toLowerCase();
+ if (".inf".equals(valLower)) {
+ return new Double(sign == -1 ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY);
+ } else if (".nan".equals(valLower)) {
+ return new Double(Double.NaN);
+ } else if (value.indexOf(':') != -1) {
+ String[] digits = value.split(":");
+ int bes = 1;
+ double val = 0.0;
+ for (int i = 0, j = digits.length; i < j; i++) {
+ val += (Double.parseDouble(digits[(j - i) - 1]) * bes);
+ bes *= 60;
+ }
+ return new Double(sign * val);
+ } else {
+ Double d = Double.valueOf(value);
+ return new Double(d.doubleValue() * sign);
+ }
+ }
+ }
+
+ public class ConstructYamlBinary extends AbstractConstruct {
+ public Object construct(Node node) {
+ byte[] decoded = Base64Coder.decode(constructScalar((ScalarNode) node).toString()
+ .toCharArray());
+ return decoded;
+ }
+ }
+
+ private final static Pattern TIMESTAMP_REGEXP = Pattern
+ .compile("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:(?:[Tt]|[ \t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \t]*(?:Z|([-+][0-9][0-9]?)(?::([0-9][0-9])?)?))?)?$");
+ private final static Pattern YMD_REGEXP = Pattern
+ .compile("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)$");
+
+ public class ConstructYamlTimestamp extends AbstractConstruct {
+ private Calendar calendar;
+
+ public Calendar getCalendar() {
+ return calendar;
+ }
+
+ public Object construct(Node node) {
+ ScalarNode scalar = (ScalarNode) node;
+ String nodeValue = scalar.getValue();
+ Matcher match = YMD_REGEXP.matcher(nodeValue);
+ if (match.matches()) {
+ String year_s = match.group(1);
+ String month_s = match.group(2);
+ String day_s = match.group(3);
+ calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ calendar.clear();
+ calendar.set(Calendar.YEAR, Integer.parseInt(year_s));
+ // Java's months are zero-based...
+ calendar.set(Calendar.MONTH, Integer.parseInt(month_s) - 1); // x
+ calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day_s));
+ return calendar.getTime();
+ } else {
+ match = TIMESTAMP_REGEXP.matcher(nodeValue);
+ if (!match.matches()) {
+ throw new YAMLException("Unexpected timestamp: " + nodeValue);
+ }
+ String year_s = match.group(1);
+ String month_s = match.group(2);
+ String day_s = match.group(3);
+ String hour_s = match.group(4);
+ String min_s = match.group(5);
+ // seconds and milliseconds
+ String seconds = match.group(6);
+ String millis = match.group(7);
+ if (millis != null) {
+ seconds = seconds + "." + millis;
+ }
+ double fractions = Double.parseDouble(seconds);
+ int sec_s = (int) Math.round(Math.floor(fractions));
+ int usec = (int) Math.round(((fractions - sec_s) * 1000));
+ // timezone
+ String timezoneh_s = match.group(8);
+ String timezonem_s = match.group(9);
+ TimeZone timeZone;
+ if (timezoneh_s != null) {
+ String time = timezonem_s != null ? ":" + timezonem_s : "00";
+ timeZone = TimeZone.getTimeZone("GMT" + timezoneh_s + time);
+ } else {
+ // no time zone provided
+ timeZone = TimeZone.getTimeZone("UTC");
+ }
+ calendar = Calendar.getInstance(timeZone);
+ calendar.set(Calendar.YEAR, Integer.parseInt(year_s));
+ // Java's months are zero-based...
+ calendar.set(Calendar.MONTH, Integer.parseInt(month_s) - 1);
+ calendar.set(Calendar.DAY_OF_MONTH, Integer.parseInt(day_s));
+ calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(hour_s));
+ calendar.set(Calendar.MINUTE, Integer.parseInt(min_s));
+ calendar.set(Calendar.SECOND, sec_s);
+ calendar.set(Calendar.MILLISECOND, usec);
+ return calendar.getTime();
+ }
+ }
+ }
+
+ public class ConstructYamlOmap extends AbstractConstruct {
+ public Object construct(Node node) {
+ // Note: we do not check for duplicate keys, because it's too
+ // CPU-expensive.
+ Map<Object, Object> omap = new LinkedHashMap<Object, Object>();
+ if (!(node instanceof SequenceNode)) {
+ throw new ConstructorException("while constructing an ordered map",
+ node.getStartMark(), "expected a sequence, but found " + node.getNodeId(),
+ node.getStartMark());
+ }
+ SequenceNode snode = (SequenceNode) node;
+ for (Node subnode : snode.getValue()) {
+ if (!(subnode instanceof MappingNode)) {
+ throw new ConstructorException("while constructing an ordered map",
+ node.getStartMark(), "expected a mapping of length 1, but found "
+ + subnode.getNodeId(), subnode.getStartMark());
+ }
+ MappingNode mnode = (MappingNode) subnode;
+ if (mnode.getValue().size() != 1) {
+ throw new ConstructorException("while constructing an ordered map",
+ node.getStartMark(), "expected a single mapping item, but found "
+ + mnode.getValue().size() + " items", mnode.getStartMark());
+ }
+ Node keyNode = mnode.getValue().get(0).getKeyNode();
+ Node valueNode = mnode.getValue().get(0).getValueNode();
+ Object key = constructObject(keyNode);
+ Object value = constructObject(valueNode);
+ omap.put(key, value);
+ }
+ return omap;
+ }
+ }
+
+ // Note: the same code as `construct_yaml_omap`.
+ public class ConstructYamlPairs extends AbstractConstruct {
+ public Object construct(Node node) {
+ // Note: we do not check for duplicate keys, because it's too
+ // CPU-expensive.
+ if (!(node instanceof SequenceNode)) {
+ throw new ConstructorException("while constructing pairs", node.getStartMark(),
+ "expected a sequence, but found " + node.getNodeId(), node.getStartMark());
+ }
+ SequenceNode snode = (SequenceNode) node;
+ List<Object[]> pairs = new ArrayList<Object[]>(snode.getValue().size());
+ for (Node subnode : snode.getValue()) {
+ if (!(subnode instanceof MappingNode)) {
+ throw new ConstructorException("while constructingpairs", node.getStartMark(),
+ "expected a mapping of length 1, but found " + subnode.getNodeId(),
+ subnode.getStartMark());
+ }
+ MappingNode mnode = (MappingNode) subnode;
+ if (mnode.getValue().size() != 1) {
+ throw new ConstructorException("while constructing pairs", node.getStartMark(),
+ "expected a single mapping item, but found " + mnode.getValue().size()
+ + " items", mnode.getStartMark());
+ }
+ Node keyNode = mnode.getValue().get(0).getKeyNode();
+ Node valueNode = mnode.getValue().get(0).getValueNode();
+ Object key = constructObject(keyNode);
+ Object value = constructObject(valueNode);
+ pairs.add(new Object[] { key, value });
+ }
+ return pairs;
+ }
+ }
+
+ public class ConstructYamlSet implements Construct {
+ public Object construct(Node node) {
+ if (node.isTwoStepsConstruction()) {
+ return createDefaultSet();
+ } else {
+ return constructSet((MappingNode) node);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void construct2ndStep(Node node, Object object) {
+ if (node.isTwoStepsConstruction()) {
+ constructSet2ndStep((MappingNode) node, (Set<Object>) object);
+ } else {
+ throw new YAMLException("Unexpected recursive set structure. Node: " + node);
+ }
+ }
+ }
+
+ public class ConstructYamlStr extends AbstractConstruct {
+ public Object construct(Node node) {
+ return constructScalar((ScalarNode) node);
+ }
+ }
+
+ public class ConstructYamlSeq implements Construct {
+ public Object construct(Node node) {
+ SequenceNode seqNode = (SequenceNode) node;
+ if (node.isTwoStepsConstruction()) {
+ return createDefaultList((seqNode.getValue()).size());
+ } else {
+ return constructSequence(seqNode);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void construct2ndStep(Node node, Object data) {
+ if (node.isTwoStepsConstruction()) {
+ constructSequenceStep2((SequenceNode) node, (List<Object>) data);
+ } else {
+ throw new YAMLException("Unexpected recursive sequence structure. Node: " + node);
+ }
+ }
+ }
+
+ public class ConstructYamlMap implements Construct {
+ public Object construct(Node node) {
+ if (node.isTwoStepsConstruction()) {
+ return createDefaultMap();
+ } else {
+ return constructMapping((MappingNode) node);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void construct2ndStep(Node node, Object object) {
+ if (node.isTwoStepsConstruction()) {
+ constructMapping2ndStep((MappingNode) node, (Map<Object, Object>) object);
+ } else {
+ throw new YAMLException("Unexpected recursive mapping structure. Node: " + node);
+ }
+ }
+ }
+
+ public static final class ConstructUndefined extends AbstractConstruct {
+ public Object construct(Node node) {
+ throw new ConstructorException(null, null,
+ "could not determine a constructor for the tag " + node.getTag(),
+ node.getStartMark());
+ }
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/emitter/Emitable.java b/src/main/java/org/yaml/snakeyaml/emitter/Emitable.java
index 198582f..ae99e2d 100644
--- a/src/main/java/org/yaml/snakeyaml/emitter/Emitable.java
+++ b/src/main/java/org/yaml/snakeyaml/emitter/Emitable.java
@@ -1,24 +1,24 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter;
-
-import java.io.IOException;
-
-import org.yaml.snakeyaml.events.Event;
-
-public interface Emitable {
- public void emit(Event event) throws IOException;
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter;
+
+import java.io.IOException;
+
+import org.yaml.snakeyaml.events.Event;
+
+public interface Emitable {
+ public void emit(Event event) throws IOException;
+}
diff --git a/src/main/java/org/yaml/snakeyaml/emitter/EmitterState.java b/src/main/java/org/yaml/snakeyaml/emitter/EmitterState.java
index 5c7d56c..b3f2b8d 100755
--- a/src/main/java/org/yaml/snakeyaml/emitter/EmitterState.java
+++ b/src/main/java/org/yaml/snakeyaml/emitter/EmitterState.java
@@ -1,26 +1,26 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter;
-
-import java.io.IOException;
-
-/**
- * Python's methods are first class object. Java needs a class.
- */
-interface EmitterState {
- void expect() throws IOException;
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter;
+
+import java.io.IOException;
+
+/**
+ * Python's methods are first class object. Java needs a class.
+ */
+interface EmitterState {
+ void expect() throws IOException;
}
\ No newline at end of file
diff --git a/src/main/java/org/yaml/snakeyaml/emitter/ScalarAnalysis.java b/src/main/java/org/yaml/snakeyaml/emitter/ScalarAnalysis.java
index 460fb77..1c0f576 100644
--- a/src/main/java/org/yaml/snakeyaml/emitter/ScalarAnalysis.java
+++ b/src/main/java/org/yaml/snakeyaml/emitter/ScalarAnalysis.java
@@ -1,41 +1,41 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter;
-
-public final class ScalarAnalysis {
- public String scalar;
- public boolean empty;
- public boolean multiline;
- public boolean allowFlowPlain;
- public boolean allowBlockPlain;
- public boolean allowSingleQuoted;
- public boolean allowDoubleQuoted;
- public boolean allowBlock;
-
- public ScalarAnalysis(String scalar, boolean empty, boolean multiline, boolean allowFlowPlain,
- boolean allowBlockPlain, boolean allowSingleQuoted, boolean allowDoubleQuoted,
- boolean allowBlock) {
- this.scalar = scalar;
- this.empty = empty;
- this.multiline = multiline;
- this.allowFlowPlain = allowFlowPlain;
- this.allowBlockPlain = allowBlockPlain;
- this.allowSingleQuoted = allowSingleQuoted;
- this.allowDoubleQuoted = allowDoubleQuoted;
- this.allowBlock = allowBlock;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter;
+
+public final class ScalarAnalysis {
+ public String scalar;
+ public boolean empty;
+ public boolean multiline;
+ public boolean allowFlowPlain;
+ public boolean allowBlockPlain;
+ public boolean allowSingleQuoted;
+ public boolean allowDoubleQuoted;
+ public boolean allowBlock;
+
+ public ScalarAnalysis(String scalar, boolean empty, boolean multiline, boolean allowFlowPlain,
+ boolean allowBlockPlain, boolean allowSingleQuoted, boolean allowDoubleQuoted,
+ boolean allowBlock) {
+ this.scalar = scalar;
+ this.empty = empty;
+ this.multiline = multiline;
+ this.allowFlowPlain = allowFlowPlain;
+ this.allowBlockPlain = allowBlockPlain;
+ this.allowSingleQuoted = allowSingleQuoted;
+ this.allowDoubleQuoted = allowDoubleQuoted;
+ this.allowBlock = allowBlock;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/yaml/snakeyaml/error/Mark.java b/src/main/java/org/yaml/snakeyaml/error/Mark.java
index 4891ae8..4c637a1 100644
--- a/src/main/java/org/yaml/snakeyaml/error/Mark.java
+++ b/src/main/java/org/yaml/snakeyaml/error/Mark.java
@@ -1,133 +1,133 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.error;
-
-import org.yaml.snakeyaml.scanner.Constant;
-
-/**
- * It's just a record and its only use is producing nice error messages. Parser
- * does not use it for any other purposes.
- */
-public final class Mark {
- private String name;
- private int index;
- private int line;
- private int column;
- private String buffer;
- private int pointer;
-
- public Mark(String name, int index, int line, int column, String buffer, int pointer) {
- super();
- this.name = name;
- this.index = index;
- this.line = line;
- this.column = column;
- this.buffer = buffer;
- this.pointer = pointer;
- }
-
- private boolean isLineBreak(char ch) {
- return Constant.NULL_OR_LINEBR.has(ch);
- }
-
- public String get_snippet(int indent, int max_length) {
- if (buffer == null) {
- return null;
- }
- float half = max_length / 2 - 1;
- int start = pointer;
- String head = "";
- while ((start > 0) && (!isLineBreak(buffer.charAt(start - 1)))) {
- start -= 1;
- if (pointer - start > half) {
- head = " ... ";
- start += 5;
- break;
- }
- }
- String tail = "";
- int end = pointer;
- while ((end < buffer.length()) && (!isLineBreak(buffer.charAt(end)))) {
- end += 1;
- if (end - pointer > half) {
- tail = " ... ";
- end -= 5;
- break;
- }
- }
- String snippet = buffer.substring(start, end);
- StringBuilder result = new StringBuilder();
- for (int i = 0; i < indent; i++) {
- result.append(" ");
- }
- result.append(head);
- result.append(snippet);
- result.append(tail);
- result.append("\n");
- for (int i = 0; i < indent + pointer - start + head.length(); i++) {
- result.append(" ");
- }
- result.append("^");
- return result.toString();
- }
-
- public String get_snippet() {
- return get_snippet(4, 75);
- }
-
- @Override
- public String toString() {
- String snippet = get_snippet();
- StringBuilder where = new StringBuilder(" in \"");
- where.append(name);
- where.append("\", line ");
- where.append(line + 1);
- where.append(", column ");
- where.append(column + 1);
- if (snippet != null) {
- where.append(":\n");
- where.append(snippet);
- }
- return where.toString();
- }
-
- public String getName() {
- return name;
- }
-
- /**
- * starts with 0
- */
- public int getLine() {
- return line;
- }
-
- /**
- * starts with 0
- */
- public int getColumn() {
- return column;
- }
-
- /**
- * starts with 0
- */
- public int getIndex() {
- return index;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.error;
+
+import org.yaml.snakeyaml.scanner.Constant;
+
+/**
+ * It's just a record and its only use is producing nice error messages. Parser
+ * does not use it for any other purposes.
+ */
+public final class Mark {
+ private String name;
+ private int index;
+ private int line;
+ private int column;
+ private String buffer;
+ private int pointer;
+
+ public Mark(String name, int index, int line, int column, String buffer, int pointer) {
+ super();
+ this.name = name;
+ this.index = index;
+ this.line = line;
+ this.column = column;
+ this.buffer = buffer;
+ this.pointer = pointer;
+ }
+
+ private boolean isLineBreak(char ch) {
+ return Constant.NULL_OR_LINEBR.has(ch);
+ }
+
+ public String get_snippet(int indent, int max_length) {
+ if (buffer == null) {
+ return null;
+ }
+ float half = max_length / 2 - 1;
+ int start = pointer;
+ String head = "";
+ while ((start > 0) && (!isLineBreak(buffer.charAt(start - 1)))) {
+ start -= 1;
+ if (pointer - start > half) {
+ head = " ... ";
+ start += 5;
+ break;
+ }
+ }
+ String tail = "";
+ int end = pointer;
+ while ((end < buffer.length()) && (!isLineBreak(buffer.charAt(end)))) {
+ end += 1;
+ if (end - pointer > half) {
+ tail = " ... ";
+ end -= 5;
+ break;
+ }
+ }
+ String snippet = buffer.substring(start, end);
+ StringBuilder result = new StringBuilder();
+ for (int i = 0; i < indent; i++) {
+ result.append(" ");
+ }
+ result.append(head);
+ result.append(snippet);
+ result.append(tail);
+ result.append("\n");
+ for (int i = 0; i < indent + pointer - start + head.length(); i++) {
+ result.append(" ");
+ }
+ result.append("^");
+ return result.toString();
+ }
+
+ public String get_snippet() {
+ return get_snippet(4, 75);
+ }
+
+ @Override
+ public String toString() {
+ String snippet = get_snippet();
+ StringBuilder where = new StringBuilder(" in \"");
+ where.append(name);
+ where.append("\", line ");
+ where.append(line + 1);
+ where.append(", column ");
+ where.append(column + 1);
+ if (snippet != null) {
+ where.append(":\n");
+ where.append(snippet);
+ }
+ return where.toString();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * starts with 0
+ */
+ public int getLine() {
+ return line;
+ }
+
+ /**
+ * starts with 0
+ */
+ public int getColumn() {
+ return column;
+ }
+
+ /**
+ * starts with 0
+ */
+ public int getIndex() {
+ return index;
+ }
+
+}
diff --git a/src/main/java/org/yaml/snakeyaml/error/MarkedYAMLException.java b/src/main/java/org/yaml/snakeyaml/error/MarkedYAMLException.java
index a90421b..604520a 100644
--- a/src/main/java/org/yaml/snakeyaml/error/MarkedYAMLException.java
+++ b/src/main/java/org/yaml/snakeyaml/error/MarkedYAMLException.java
@@ -1,97 +1,97 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.error;
-
-public class MarkedYAMLException extends YAMLException {
-
- private static final long serialVersionUID = -9119388488683035101L;
- private String context;
- private Mark contextMark;
- private String problem;
- private Mark problemMark;
- private String note;
-
- protected MarkedYAMLException(String context, Mark contextMark, String problem,
- Mark problemMark, String note) {
- this(context, contextMark, problem, problemMark, note, null);
- }
-
- protected MarkedYAMLException(String context, Mark contextMark, String problem,
- Mark problemMark, String note, Throwable cause) {
- super(context + "; " + problem, cause);
- this.context = context;
- this.contextMark = contextMark;
- this.problem = problem;
- this.problemMark = problemMark;
- this.note = note;
- }
-
- protected MarkedYAMLException(String context, Mark contextMark, String problem, Mark problemMark) {
- this(context, contextMark, problem, problemMark, null, null);
- }
-
- protected MarkedYAMLException(String context, Mark contextMark, String problem,
- Mark problemMark, Throwable cause) {
- this(context, contextMark, problem, problemMark, null, cause);
- }
-
- @Override
- public String toString() {
- StringBuilder lines = new StringBuilder();
- if (context != null) {
- lines.append(context);
- lines.append("\n");
- }
- if (contextMark != null
- && (problem == null || problemMark == null
- || (contextMark.getName() != problemMark.getName())
- || (contextMark.getLine() != problemMark.getLine()) || (contextMark
- .getColumn() != problemMark.getColumn()))) {
- lines.append(contextMark.toString());
- lines.append("\n");
- }
- if (problem != null) {
- lines.append(problem);
- lines.append("\n");
- }
- if (problemMark != null) {
- lines.append(problemMark.toString());
- lines.append("\n");
- }
- if (note != null) {
- lines.append(note);
- lines.append("\n");
- }
- return lines.toString();
- }
-
- public String getContext() {
- return context;
- }
-
- public Mark getContextMark() {
- return contextMark;
- }
-
- public String getProblem() {
- return problem;
- }
-
- public Mark getProblemMark() {
- return problemMark;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.error;
+
+public class MarkedYAMLException extends YAMLException {
+
+ private static final long serialVersionUID = -9119388488683035101L;
+ private String context;
+ private Mark contextMark;
+ private String problem;
+ private Mark problemMark;
+ private String note;
+
+ protected MarkedYAMLException(String context, Mark contextMark, String problem,
+ Mark problemMark, String note) {
+ this(context, contextMark, problem, problemMark, note, null);
+ }
+
+ protected MarkedYAMLException(String context, Mark contextMark, String problem,
+ Mark problemMark, String note, Throwable cause) {
+ super(context + "; " + problem, cause);
+ this.context = context;
+ this.contextMark = contextMark;
+ this.problem = problem;
+ this.problemMark = problemMark;
+ this.note = note;
+ }
+
+ protected MarkedYAMLException(String context, Mark contextMark, String problem, Mark problemMark) {
+ this(context, contextMark, problem, problemMark, null, null);
+ }
+
+ protected MarkedYAMLException(String context, Mark contextMark, String problem,
+ Mark problemMark, Throwable cause) {
+ this(context, contextMark, problem, problemMark, null, cause);
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder lines = new StringBuilder();
+ if (context != null) {
+ lines.append(context);
+ lines.append("\n");
+ }
+ if (contextMark != null
+ && (problem == null || problemMark == null
+ || (contextMark.getName() != problemMark.getName())
+ || (contextMark.getLine() != problemMark.getLine()) || (contextMark
+ .getColumn() != problemMark.getColumn()))) {
+ lines.append(contextMark.toString());
+ lines.append("\n");
+ }
+ if (problem != null) {
+ lines.append(problem);
+ lines.append("\n");
+ }
+ if (problemMark != null) {
+ lines.append(problemMark.toString());
+ lines.append("\n");
+ }
+ if (note != null) {
+ lines.append(note);
+ lines.append("\n");
+ }
+ return lines.toString();
+ }
+
+ public String getContext() {
+ return context;
+ }
+
+ public Mark getContextMark() {
+ return contextMark;
+ }
+
+ public String getProblem() {
+ return problem;
+ }
+
+ public Mark getProblemMark() {
+ return problemMark;
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/events/ImplicitTuple.java b/src/main/java/org/yaml/snakeyaml/events/ImplicitTuple.java
index 2362ca9..8809bfc 100644
--- a/src/main/java/org/yaml/snakeyaml/events/ImplicitTuple.java
+++ b/src/main/java/org/yaml/snakeyaml/events/ImplicitTuple.java
@@ -1,59 +1,59 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.events;
-
-/**
- * The implicit flag of a scalar event is a pair of boolean values that indicate
- * if the tag may be omitted when the scalar is emitted in a plain and non-plain
- * style correspondingly.
- *
- * @see http://pyyaml.org/wiki/PyYAMLDocumentation#Events
- */
-public class ImplicitTuple {
- private final boolean plain;
- private final boolean nonPlain;
-
- public ImplicitTuple(boolean plain, boolean nonplain) {
- this.plain = plain;
- this.nonPlain = nonplain;
- }
-
- /**
- * @return true when tag may be omitted when the scalar is emitted in a
- * plain style.
- */
- public boolean canOmitTagInPlainScalar() {
- return plain;
- }
-
- /**
- * @return true when tag may be omitted when the scalar is emitted in a
- * non-plain style.
- */
- public boolean canOmitTagInNonPlainScalar() {
- return nonPlain;
- }
-
- public boolean bothFalse() {
- return !plain && !nonPlain;
- }
-
- @Override
- public String toString() {
- return "implicit=[" + plain + ", " + nonPlain + "]";
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.events;
+
+/**
+ * The implicit flag of a scalar event is a pair of boolean values that indicate
+ * if the tag may be omitted when the scalar is emitted in a plain and non-plain
+ * style correspondingly.
+ *
+ * @see http://pyyaml.org/wiki/PyYAMLDocumentation#Events
+ */
+public class ImplicitTuple {
+ private final boolean plain;
+ private final boolean nonPlain;
+
+ public ImplicitTuple(boolean plain, boolean nonplain) {
+ this.plain = plain;
+ this.nonPlain = nonplain;
+ }
+
+ /**
+ * @return true when tag may be omitted when the scalar is emitted in a
+ * plain style.
+ */
+ public boolean canOmitTagInPlainScalar() {
+ return plain;
+ }
+
+ /**
+ * @return true when tag may be omitted when the scalar is emitted in a
+ * non-plain style.
+ */
+ public boolean canOmitTagInNonPlainScalar() {
+ return nonPlain;
+ }
+
+ public boolean bothFalse() {
+ return !plain && !nonPlain;
+ }
+
+ @Override
+ public String toString() {
+ return "implicit=[" + plain + ", " + nonPlain + "]";
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactData.java b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactData.java
index d9264f1..a499e0a 100644
--- a/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactData.java
+++ b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/CompactData.java
@@ -1,49 +1,49 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class CompactData {
- private String prefix;
- private List<String> arguments = new ArrayList<String>();
- private Map<String, String> properties = new HashMap<String, String>();
-
- public CompactData(String prefix) {
- this.prefix = prefix;
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public Map<String, String> getProperties() {
- return properties;
- }
-
- public List<String> getArguments() {
- return arguments;
- }
-
- @Override
- public String toString() {
- return "CompactData: " + prefix + " " + properties;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CompactData {
+ private String prefix;
+ private List<String> arguments = new ArrayList<String>();
+ private Map<String, String> properties = new HashMap<String, String>();
+
+ public CompactData(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ public List<String> getArguments() {
+ return arguments;
+ }
+
+ @Override
+ public String toString() {
+ return "CompactData: " + prefix + " " + properties;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructor.java b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructor.java
index 56cea31..7d56f1a 100644
--- a/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructor.java
+++ b/src/main/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructor.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-public class PackageCompactConstructor extends CompactConstructor {
- private String packageName;
-
- public PackageCompactConstructor(String packageName) {
- this.packageName = packageName;
- }
-
- @Override
- protected Class<?> getClassForName(String name) throws ClassNotFoundException {
- if (name.indexOf('.') < 0) {
- try {
- Class<?> clazz = Class.forName(packageName + "." + name);
- return clazz;
- } catch (ClassNotFoundException e) {
- // use super implementation
- }
- }
- return super.getClassForName(name);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+public class PackageCompactConstructor extends CompactConstructor {
+ private String packageName;
+
+ public PackageCompactConstructor(String packageName) {
+ this.packageName = packageName;
+ }
+
+ @Override
+ protected Class<?> getClassForName(String name) throws ClassNotFoundException {
+ if (name.indexOf('.') < 0) {
+ try {
+ Class<?> clazz = Class.forName(packageName + "." + name);
+ return clazz;
+ } catch (ClassNotFoundException e) {
+ // use super implementation
+ }
+ }
+ return super.getClassForName(name);
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/external/biz/base64Coder/Base64Coder.java b/src/main/java/org/yaml/snakeyaml/external/biz/base64Coder/Base64Coder.java
index 034d573..65923b6 100644
--- a/src/main/java/org/yaml/snakeyaml/external/biz/base64Coder/Base64Coder.java
+++ b/src/main/java/org/yaml/snakeyaml/external/biz/base64Coder/Base64Coder.java
@@ -1,305 +1,305 @@
-// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
-// www.source-code.biz, www.inventec.ch/chdh
-//
-// This module is multi-licensed and may be used under the terms
-// of any of the following licenses:
-//
-// EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
-// LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
-// GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
-// AL, Apache License, V2.0 or later, http://www.apache.org/licenses
-// BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
-//
-// Please contact the author if you need another license.
-// This module is provided "as is", without warranties of any kind.
-
-package org.yaml.snakeyaml.external.biz.base64Coder;
-
-/**
- * A Base64 encoder/decoder.
- *
- * <p>
- * This class is used to encode and decode data in Base64 format as described in
- * RFC 1521.
- *
- * <p>
- * Project home page: <a
- * href="http://www.source-code.biz/base64coder/java/">www.
- * source-code.biz/base64coder/java</a><br>
- * Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br>
- * Multi-licensed: EPL / LGPL / GPL / AL / BSD.
- */
-public class Base64Coder {
-
- // The line separator string of the operating system.
- private static final String systemLineSeparator = System.getProperty("line.separator");
-
- // Mapping table from 6-bit nibbles to Base64 characters.
- private static char[] map1 = new char[64];
- static {
- int i = 0;
- for (char c = 'A'; c <= 'Z'; c++)
- map1[i++] = c;
- for (char c = 'a'; c <= 'z'; c++)
- map1[i++] = c;
- for (char c = '0'; c <= '9'; c++)
- map1[i++] = c;
- map1[i++] = '+';
- map1[i++] = '/';
- }
-
- // Mapping table from Base64 characters to 6-bit nibbles.
- private static byte[] map2 = new byte[128];
- static {
- for (int i = 0; i < map2.length; i++)
- map2[i] = -1;
- for (int i = 0; i < 64; i++)
- map2[map1[i]] = (byte) i;
- }
-
- /**
- * Encodes a string into Base64 format. No blanks or line breaks are
- * inserted.
- *
- * @param s
- * A String to be encoded.
- * @return A String containing the Base64 encoded data.
- */
- public static String encodeString(String s) {
- return new String(encode(s.getBytes()));
- }
-
- /**
- * Encodes a byte array into Base 64 format and breaks the output into lines
- * of 76 characters. This method is compatible with
- * <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
- *
- * @param in
- * An array containing the data bytes to be encoded.
- * @return A String containing the Base64 encoded data, broken into lines.
- */
- public static String encodeLines(byte[] in) {
- return encodeLines(in, 0, in.length, 76, systemLineSeparator);
- }
-
- /**
- * Encodes a byte array into Base 64 format and breaks the output into
- * lines.
- *
- * @param in
- * An array containing the data bytes to be encoded.
- * @param iOff
- * Offset of the first byte in <code>in</code> to be processed.
- * @param iLen
- * Number of bytes to be processed in <code>in</code>, starting
- * at <code>iOff</code>.
- * @param lineLen
- * Line length for the output data. Should be a multiple of 4.
- * @param lineSeparator
- * The line separator to be used to separate the output lines.
- * @return A String containing the Base64 encoded data, broken into lines.
- */
- public static String encodeLines(byte[] in, int iOff, int iLen, int lineLen,
- String lineSeparator) {
- int blockLen = (lineLen * 3) / 4;
- if (blockLen <= 0)
- throw new IllegalArgumentException();
- int lines = (iLen + blockLen - 1) / blockLen;
- int bufLen = ((iLen + 2) / 3) * 4 + lines * lineSeparator.length();
- StringBuilder buf = new StringBuilder(bufLen);
- int ip = 0;
- while (ip < iLen) {
- int l = Math.min(iLen - ip, blockLen);
- buf.append(encode(in, iOff + ip, l));
- buf.append(lineSeparator);
- ip += l;
- }
- return buf.toString();
- }
-
- /**
- * Encodes a byte array into Base64 format. No blanks or line breaks are
- * inserted in the output.
- *
- * @param in
- * An array containing the data bytes to be encoded.
- * @return A character array containing the Base64 encoded data.
- */
- public static char[] encode(byte[] in) {
- return encode(in, 0, in.length);
- }
-
- /**
- * Encodes a byte array into Base64 format. No blanks or line breaks are
- * inserted in the output.
- *
- * @param in
- * An array containing the data bytes to be encoded.
- * @param iLen
- * Number of bytes to process in <code>in</code>.
- * @return A character array containing the Base64 encoded data.
- */
- public static char[] encode(byte[] in, int iLen) {
- return encode(in, 0, iLen);
- }
-
- /**
- * Encodes a byte array into Base64 format. No blanks or line breaks are
- * inserted in the output.
- *
- * @param in
- * An array containing the data bytes to be encoded.
- * @param iOff
- * Offset of the first byte in <code>in</code> to be processed.
- * @param iLen
- * Number of bytes to process in <code>in</code>, starting at
- * <code>iOff</code>.
- * @return A character array containing the Base64 encoded data.
- */
- public static char[] encode(byte[] in, int iOff, int iLen) {
- int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
- int oLen = ((iLen + 2) / 3) * 4; // output length including padding
- char[] out = new char[oLen];
- int ip = iOff;
- int iEnd = iOff + iLen;
- int op = 0;
- while (ip < iEnd) {
- int i0 = in[ip++] & 0xff;
- int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
- int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
- int o0 = i0 >>> 2;
- int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
- int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
- int o3 = i2 & 0x3F;
- out[op++] = map1[o0];
- out[op++] = map1[o1];
- out[op] = op < oDataLen ? map1[o2] : '=';
- op++;
- out[op] = op < oDataLen ? map1[o3] : '=';
- op++;
- }
- return out;
- }
-
- /**
- * Decodes a string from Base64 format. No blanks or line breaks are allowed
- * within the Base64 encoded input data.
- *
- * @param s
- * A Base64 String to be decoded.
- * @return A String containing the decoded data.
- * @throws IllegalArgumentException
- * If the input is not valid Base64 encoded data.
- */
- public static String decodeString(String s) {
- return new String(decode(s));
- }
-
- /**
- * Decodes a byte array from Base64 format and ignores line separators, tabs
- * and blanks. CR, LF, Tab and Space characters are ignored in the input
- * data. This method is compatible with
- * <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
- *
- * @param s
- * A Base64 String to be decoded.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException
- * If the input is not valid Base64 encoded data.
- */
- public static byte[] decodeLines(String s) {
- char[] buf = new char[s.length()];
- int p = 0;
- for (int ip = 0; ip < s.length(); ip++) {
- char c = s.charAt(ip);
- if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
- buf[p++] = c;
- }
- return decode(buf, 0, p);
- }
-
- /**
- * Decodes a byte array from Base64 format. No blanks or line breaks are
- * allowed within the Base64 encoded input data.
- *
- * @param s
- * A Base64 String to be decoded.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException
- * If the input is not valid Base64 encoded data.
- */
- public static byte[] decode(String s) {
- return decode(s.toCharArray());
- }
-
- /**
- * Decodes a byte array from Base64 format. No blanks or line breaks are
- * allowed within the Base64 encoded input data.
- *
- * @param in
- * A character array containing the Base64 encoded data.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException
- * If the input is not valid Base64 encoded data.
- */
- public static byte[] decode(char[] in) {
- return decode(in, 0, in.length);
- }
-
- /**
- * Decodes a byte array from Base64 format. No blanks or line breaks are
- * allowed within the Base64 encoded input data.
- *
- * @param in
- * A character array containing the Base64 encoded data.
- * @param iOff
- * Offset of the first character in <code>in</code> to be
- * processed.
- * @param iLen
- * Number of characters to process in <code>in</code>, starting
- * at <code>iOff</code>.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException
- * If the input is not valid Base64 encoded data.
- */
- public static byte[] decode(char[] in, int iOff, int iLen) {
- if (iLen % 4 != 0)
- throw new IllegalArgumentException(
- "Length of Base64 encoded input string is not a multiple of 4.");
- while (iLen > 0 && in[iOff + iLen - 1] == '=')
- iLen--;
- int oLen = (iLen * 3) / 4;
- byte[] out = new byte[oLen];
- int ip = iOff;
- int iEnd = iOff + iLen;
- int op = 0;
- while (ip < iEnd) {
- int i0 = in[ip++];
- int i1 = in[ip++];
- int i2 = ip < iEnd ? in[ip++] : 'A';
- int i3 = ip < iEnd ? in[ip++] : 'A';
- if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
- throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
- int b0 = map2[i0];
- int b1 = map2[i1];
- int b2 = map2[i2];
- int b3 = map2[i3];
- if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
- throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
- int o0 = (b0 << 2) | (b1 >>> 4);
- int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
- int o2 = ((b2 & 3) << 6) | b3;
- out[op++] = (byte) o0;
- if (op < oLen)
- out[op++] = (byte) o1;
- if (op < oLen)
- out[op++] = (byte) o2;
- }
- return out;
- }
-
- // Dummy constructor.
- private Base64Coder() {
- }
-
-} // end class Base64Coder
+// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
+// www.source-code.biz, www.inventec.ch/chdh
+//
+// This module is multi-licensed and may be used under the terms
+// of any of the following licenses:
+//
+// EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
+// LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
+// GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
+// AL, Apache License, V2.0 or later, http://www.apache.org/licenses
+// BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
+//
+// Please contact the author if you need another license.
+// This module is provided "as is", without warranties of any kind.
+
+package org.yaml.snakeyaml.external.biz.base64Coder;
+
+/**
+ * A Base64 encoder/decoder.
+ *
+ * <p>
+ * This class is used to encode and decode data in Base64 format as described in
+ * RFC 1521.
+ *
+ * <p>
+ * Project home page: <a
+ * href="http://www.source-code.biz/base64coder/java/">www.
+ * source-code.biz/base64coder/java</a><br>
+ * Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br>
+ * Multi-licensed: EPL / LGPL / GPL / AL / BSD.
+ */
+public class Base64Coder {
+
+ // The line separator string of the operating system.
+ private static final String systemLineSeparator = System.getProperty("line.separator");
+
+ // Mapping table from 6-bit nibbles to Base64 characters.
+ private static char[] map1 = new char[64];
+ static {
+ int i = 0;
+ for (char c = 'A'; c <= 'Z'; c++)
+ map1[i++] = c;
+ for (char c = 'a'; c <= 'z'; c++)
+ map1[i++] = c;
+ for (char c = '0'; c <= '9'; c++)
+ map1[i++] = c;
+ map1[i++] = '+';
+ map1[i++] = '/';
+ }
+
+ // Mapping table from Base64 characters to 6-bit nibbles.
+ private static byte[] map2 = new byte[128];
+ static {
+ for (int i = 0; i < map2.length; i++)
+ map2[i] = -1;
+ for (int i = 0; i < 64; i++)
+ map2[map1[i]] = (byte) i;
+ }
+
+ /**
+ * Encodes a string into Base64 format. No blanks or line breaks are
+ * inserted.
+ *
+ * @param s
+ * A String to be encoded.
+ * @return A String containing the Base64 encoded data.
+ */
+ public static String encodeString(String s) {
+ return new String(encode(s.getBytes()));
+ }
+
+ /**
+ * Encodes a byte array into Base 64 format and breaks the output into lines
+ * of 76 characters. This method is compatible with
+ * <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @return A String containing the Base64 encoded data, broken into lines.
+ */
+ public static String encodeLines(byte[] in) {
+ return encodeLines(in, 0, in.length, 76, systemLineSeparator);
+ }
+
+ /**
+ * Encodes a byte array into Base 64 format and breaks the output into
+ * lines.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iOff
+ * Offset of the first byte in <code>in</code> to be processed.
+ * @param iLen
+ * Number of bytes to be processed in <code>in</code>, starting
+ * at <code>iOff</code>.
+ * @param lineLen
+ * Line length for the output data. Should be a multiple of 4.
+ * @param lineSeparator
+ * The line separator to be used to separate the output lines.
+ * @return A String containing the Base64 encoded data, broken into lines.
+ */
+ public static String encodeLines(byte[] in, int iOff, int iLen, int lineLen,
+ String lineSeparator) {
+ int blockLen = (lineLen * 3) / 4;
+ if (blockLen <= 0)
+ throw new IllegalArgumentException();
+ int lines = (iLen + blockLen - 1) / blockLen;
+ int bufLen = ((iLen + 2) / 3) * 4 + lines * lineSeparator.length();
+ StringBuilder buf = new StringBuilder(bufLen);
+ int ip = 0;
+ while (ip < iLen) {
+ int l = Math.min(iLen - ip, blockLen);
+ buf.append(encode(in, iOff + ip, l));
+ buf.append(lineSeparator);
+ ip += l;
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Encodes a byte array into Base64 format. No blanks or line breaks are
+ * inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @return A character array containing the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in) {
+ return encode(in, 0, in.length);
+ }
+
+ /**
+ * Encodes a byte array into Base64 format. No blanks or line breaks are
+ * inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iLen
+ * Number of bytes to process in <code>in</code>.
+ * @return A character array containing the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in, int iLen) {
+ return encode(in, 0, iLen);
+ }
+
+ /**
+ * Encodes a byte array into Base64 format. No blanks or line breaks are
+ * inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iOff
+ * Offset of the first byte in <code>in</code> to be processed.
+ * @param iLen
+ * Number of bytes to process in <code>in</code>, starting at
+ * <code>iOff</code>.
+ * @return A character array containing the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in, int iOff, int iLen) {
+ int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
+ int oLen = ((iLen + 2) / 3) * 4; // output length including padding
+ char[] out = new char[oLen];
+ int ip = iOff;
+ int iEnd = iOff + iLen;
+ int op = 0;
+ while (ip < iEnd) {
+ int i0 = in[ip++] & 0xff;
+ int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
+ int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
+ int o0 = i0 >>> 2;
+ int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
+ int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
+ int o3 = i2 & 0x3F;
+ out[op++] = map1[o0];
+ out[op++] = map1[o1];
+ out[op] = op < oDataLen ? map1[o2] : '=';
+ op++;
+ out[op] = op < oDataLen ? map1[o3] : '=';
+ op++;
+ }
+ return out;
+ }
+
+ /**
+ * Decodes a string from Base64 format. No blanks or line breaks are allowed
+ * within the Base64 encoded input data.
+ *
+ * @param s
+ * A Base64 String to be decoded.
+ * @return A String containing the decoded data.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static String decodeString(String s) {
+ return new String(decode(s));
+ }
+
+ /**
+ * Decodes a byte array from Base64 format and ignores line separators, tabs
+ * and blanks. CR, LF, Tab and Space characters are ignored in the input
+ * data. This method is compatible with
+ * <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
+ *
+ * @param s
+ * A Base64 String to be decoded.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decodeLines(String s) {
+ char[] buf = new char[s.length()];
+ int p = 0;
+ for (int ip = 0; ip < s.length(); ip++) {
+ char c = s.charAt(ip);
+ if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
+ buf[p++] = c;
+ }
+ return decode(buf, 0, p);
+ }
+
+ /**
+ * Decodes a byte array from Base64 format. No blanks or line breaks are
+ * allowed within the Base64 encoded input data.
+ *
+ * @param s
+ * A Base64 String to be decoded.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(String s) {
+ return decode(s.toCharArray());
+ }
+
+ /**
+ * Decodes a byte array from Base64 format. No blanks or line breaks are
+ * allowed within the Base64 encoded input data.
+ *
+ * @param in
+ * A character array containing the Base64 encoded data.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(char[] in) {
+ return decode(in, 0, in.length);
+ }
+
+ /**
+ * Decodes a byte array from Base64 format. No blanks or line breaks are
+ * allowed within the Base64 encoded input data.
+ *
+ * @param in
+ * A character array containing the Base64 encoded data.
+ * @param iOff
+ * Offset of the first character in <code>in</code> to be
+ * processed.
+ * @param iLen
+ * Number of characters to process in <code>in</code>, starting
+ * at <code>iOff</code>.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException
+ * If the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(char[] in, int iOff, int iLen) {
+ if (iLen % 4 != 0)
+ throw new IllegalArgumentException(
+ "Length of Base64 encoded input string is not a multiple of 4.");
+ while (iLen > 0 && in[iOff + iLen - 1] == '=')
+ iLen--;
+ int oLen = (iLen * 3) / 4;
+ byte[] out = new byte[oLen];
+ int ip = iOff;
+ int iEnd = iOff + iLen;
+ int op = 0;
+ while (ip < iEnd) {
+ int i0 = in[ip++];
+ int i1 = in[ip++];
+ int i2 = ip < iEnd ? in[ip++] : 'A';
+ int i3 = ip < iEnd ? in[ip++] : 'A';
+ if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ int b0 = map2[i0];
+ int b1 = map2[i1];
+ int b2 = map2[i2];
+ int b3 = map2[i3];
+ if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ int o0 = (b0 << 2) | (b1 >>> 4);
+ int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
+ int o2 = ((b2 & 3) << 6) | b3;
+ out[op++] = (byte) o0;
+ if (op < oLen)
+ out[op++] = (byte) o1;
+ if (op < oLen)
+ out[op++] = (byte) o2;
+ }
+ return out;
+ }
+
+ // Dummy constructor.
+ private Base64Coder() {
+ }
+
+} // end class Base64Coder
diff --git a/src/main/java/org/yaml/snakeyaml/introspector/Property.java b/src/main/java/org/yaml/snakeyaml/introspector/Property.java
index 6991b9d..a9985c1 100644
--- a/src/main/java/org/yaml/snakeyaml/introspector/Property.java
+++ b/src/main/java/org/yaml/snakeyaml/introspector/Property.java
@@ -1,59 +1,59 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.introspector;
-
-public abstract class Property implements Comparable<Property> {
-
- private final String name;
- private final Class<?> type;
-
- public Property(String name, Class<?> type) {
- this.name = name;
- this.type = type;
- }
-
- public Class<?> getType() {
- return type;
- }
-
- abstract public Class<?>[] getActualTypeArguments();
-
- public String getName() {
- return name;
- }
-
- @Override
- public String toString() {
- return getName() + " of " + getType();
- }
-
- public int compareTo(Property o) {
- return name.compareTo(o.name);
- }
-
- public boolean isWritable() {
- return true;
- }
-
- public boolean isReadable() {
- return true;
- }
-
- abstract public void set(Object object, Object value) throws Exception;
-
- abstract public Object get(Object object);
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.introspector;
+
+public abstract class Property implements Comparable<Property> {
+
+ private final String name;
+ private final Class<?> type;
+
+ public Property(String name, Class<?> type) {
+ this.name = name;
+ this.type = type;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ abstract public Class<?>[] getActualTypeArguments();
+
+ public String getName() {
+ return name;
+ }
+
+ @Override
+ public String toString() {
+ return getName() + " of " + getType();
+ }
+
+ public int compareTo(Property o) {
+ return name.compareTo(o.name);
+ }
+
+ public boolean isWritable() {
+ return true;
+ }
+
+ public boolean isReadable() {
+ return true;
+ }
+
+ abstract public void set(Object object, Object value) throws Exception;
+
+ abstract public Object get(Object object);
}
\ No newline at end of file
diff --git a/src/main/java/org/yaml/snakeyaml/nodes/NodeId.java b/src/main/java/org/yaml/snakeyaml/nodes/NodeId.java
index ed840bf..6ad8286 100644
--- a/src/main/java/org/yaml/snakeyaml/nodes/NodeId.java
+++ b/src/main/java/org/yaml/snakeyaml/nodes/NodeId.java
@@ -1,24 +1,24 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-/**
- * Enum for the three basic YAML types: scalar, sequence and mapping.
- */
-public enum NodeId {
- scalar, sequence, mapping, anchor;
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+/**
+ * Enum for the three basic YAML types: scalar, sequence and mapping.
+ */
+public enum NodeId {
+ scalar, sequence, mapping, anchor;
+}
diff --git a/src/main/java/org/yaml/snakeyaml/nodes/Tag.java b/src/main/java/org/yaml/snakeyaml/nodes/Tag.java
index 2e7f579..6956627 100644
--- a/src/main/java/org/yaml/snakeyaml/nodes/Tag.java
+++ b/src/main/java/org/yaml/snakeyaml/nodes/Tag.java
@@ -1,176 +1,176 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URI;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.util.UriEncoder;
-
-public final class Tag implements Comparable<Tag> {
- public static final String PREFIX = "tag:yaml.org,2002:";
- public static final Tag YAML = new Tag(PREFIX + "yaml");
- public static final Tag VALUE = new Tag(PREFIX + "value");
- public static final Tag MERGE = new Tag(PREFIX + "merge");
- public static final Tag SET = new Tag(PREFIX + "set");
- public static final Tag PAIRS = new Tag(PREFIX + "pairs");
- public static final Tag OMAP = new Tag(PREFIX + "omap");
- public static final Tag BINARY = new Tag(PREFIX + "binary");
- public static final Tag INT = new Tag(PREFIX + "int");
- public static final Tag FLOAT = new Tag(PREFIX + "float");
- public static final Tag TIMESTAMP = new Tag(PREFIX + "timestamp");
- public static final Tag BOOL = new Tag(PREFIX + "bool");
- public static final Tag NULL = new Tag(PREFIX + "null");
- public static final Tag STR = new Tag(PREFIX + "str");
- public static final Tag SEQ = new Tag(PREFIX + "seq");
- public static final Tag MAP = new Tag(PREFIX + "map");
- public static final Map<Tag, Set<Class<?>>> COMPATIBILITY_MAP;
- static {
- COMPATIBILITY_MAP = new HashMap<Tag, Set<Class<?>>>();
- Set<Class<?>> floatSet = new HashSet<Class<?>>();
- floatSet.add(Double.class);
- floatSet.add(Float.class);
- floatSet.add(BigDecimal.class);
- COMPATIBILITY_MAP.put(FLOAT, floatSet);
- //
- Set<Class<?>> intSet = new HashSet<Class<?>>();
- intSet.add(Integer.class);
- intSet.add(Long.class);
- intSet.add(BigInteger.class);
- COMPATIBILITY_MAP.put(INT, intSet);
- //
- Set<Class<?>> timestampSet = new HashSet<Class<?>>();
- timestampSet.add(Date.class);
- timestampSet.add(java.sql.Date.class);
- timestampSet.add(Timestamp.class);
- COMPATIBILITY_MAP.put(TIMESTAMP, timestampSet);
- }
-
- private final String value;
-
- public Tag(String tag) {
- if (tag == null) {
- throw new NullPointerException("Tag must be provided.");
- } else if (tag.length() == 0) {
- throw new IllegalArgumentException("Tag must not be empty.");
- } else if (tag.trim().length() != tag.length()) {
- throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
- }
- this.value = UriEncoder.encode(tag);
- }
-
- public Tag(Class<? extends Object> clazz) {
- if (clazz == null) {
- throw new NullPointerException("Class for tag must be provided.");
- }
- this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
- }
-
- public Tag(URI uri) {
- if (uri == null) {
- throw new NullPointerException("URI for tag must be provided.");
- }
- this.value = uri.toASCIIString();
- }
-
- public String getValue() {
- return value;
- }
-
- public boolean startsWith(String prefix) {
- return value.startsWith(prefix);
- }
-
- public String getClassName() {
- if (!value.startsWith(Tag.PREFIX)) {
- throw new YAMLException("Invalid tag: " + value);
- }
- return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
- }
-
- public int getLength() {
- return value.length();
- }
-
- @Override
- public String toString() {
- return value;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == null) {
- return false;
- }
- if (obj instanceof Tag) {
- return value.equals(((Tag) obj).getValue());
- } else if (obj instanceof String) {
- if (value.equals(obj.toString())) {
- // TODO to be removed later (version 2.0?)
- System.err.println("Comparing Tag and String is deprecated.");
- return true;
- }
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return value.hashCode();
- }
-
- /**
- * Java has more then 1 class compatible with a language-independent tag
- * (!!int, !!float, !!timestamp etc)
- *
- * @param clazz
- * - Class to check compatibility
- * @return true when the Class can be represented by this
- * language-independent tag
- */
- public boolean isCompatible(Class<?> clazz) {
- Set<Class<?>> set = COMPATIBILITY_MAP.get(this);
- if (set != null) {
- return set.contains(clazz);
- } else {
- return false;
- }
- }
-
- /**
- * Check whether this tag matches the global tag for the Class
- *
- * @param clazz
- * - Class to check
- * @return true when the this tag can be used as a global tag for the Class
- */
- public boolean matches(Class<? extends Object> clazz) {
- return value.equals(Tag.PREFIX + clazz.getName());
- }
-
- public int compareTo(Tag o) {
- return value.compareTo(o.getValue());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.net.URI;
+import java.sql.Timestamp;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.util.UriEncoder;
+
+public final class Tag implements Comparable<Tag> {
+ public static final String PREFIX = "tag:yaml.org,2002:";
+ public static final Tag YAML = new Tag(PREFIX + "yaml");
+ public static final Tag VALUE = new Tag(PREFIX + "value");
+ public static final Tag MERGE = new Tag(PREFIX + "merge");
+ public static final Tag SET = new Tag(PREFIX + "set");
+ public static final Tag PAIRS = new Tag(PREFIX + "pairs");
+ public static final Tag OMAP = new Tag(PREFIX + "omap");
+ public static final Tag BINARY = new Tag(PREFIX + "binary");
+ public static final Tag INT = new Tag(PREFIX + "int");
+ public static final Tag FLOAT = new Tag(PREFIX + "float");
+ public static final Tag TIMESTAMP = new Tag(PREFIX + "timestamp");
+ public static final Tag BOOL = new Tag(PREFIX + "bool");
+ public static final Tag NULL = new Tag(PREFIX + "null");
+ public static final Tag STR = new Tag(PREFIX + "str");
+ public static final Tag SEQ = new Tag(PREFIX + "seq");
+ public static final Tag MAP = new Tag(PREFIX + "map");
+ public static final Map<Tag, Set<Class<?>>> COMPATIBILITY_MAP;
+ static {
+ COMPATIBILITY_MAP = new HashMap<Tag, Set<Class<?>>>();
+ Set<Class<?>> floatSet = new HashSet<Class<?>>();
+ floatSet.add(Double.class);
+ floatSet.add(Float.class);
+ floatSet.add(BigDecimal.class);
+ COMPATIBILITY_MAP.put(FLOAT, floatSet);
+ //
+ Set<Class<?>> intSet = new HashSet<Class<?>>();
+ intSet.add(Integer.class);
+ intSet.add(Long.class);
+ intSet.add(BigInteger.class);
+ COMPATIBILITY_MAP.put(INT, intSet);
+ //
+ Set<Class<?>> timestampSet = new HashSet<Class<?>>();
+ timestampSet.add(Date.class);
+ timestampSet.add(java.sql.Date.class);
+ timestampSet.add(Timestamp.class);
+ COMPATIBILITY_MAP.put(TIMESTAMP, timestampSet);
+ }
+
+ private final String value;
+
+ public Tag(String tag) {
+ if (tag == null) {
+ throw new NullPointerException("Tag must be provided.");
+ } else if (tag.length() == 0) {
+ throw new IllegalArgumentException("Tag must not be empty.");
+ } else if (tag.trim().length() != tag.length()) {
+ throw new IllegalArgumentException("Tag must not contain leading or trailing spaces.");
+ }
+ this.value = UriEncoder.encode(tag);
+ }
+
+ public Tag(Class<? extends Object> clazz) {
+ if (clazz == null) {
+ throw new NullPointerException("Class for tag must be provided.");
+ }
+ this.value = Tag.PREFIX + UriEncoder.encode(clazz.getName());
+ }
+
+ public Tag(URI uri) {
+ if (uri == null) {
+ throw new NullPointerException("URI for tag must be provided.");
+ }
+ this.value = uri.toASCIIString();
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public boolean startsWith(String prefix) {
+ return value.startsWith(prefix);
+ }
+
+ public String getClassName() {
+ if (!value.startsWith(Tag.PREFIX)) {
+ throw new YAMLException("Invalid tag: " + value);
+ }
+ return UriEncoder.decode(value.substring(Tag.PREFIX.length()));
+ }
+
+ public int getLength() {
+ return value.length();
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj instanceof Tag) {
+ return value.equals(((Tag) obj).getValue());
+ } else if (obj instanceof String) {
+ if (value.equals(obj.toString())) {
+ // TODO to be removed later (version 2.0?)
+ System.err.println("Comparing Tag and String is deprecated.");
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return value.hashCode();
+ }
+
+ /**
+ * Java has more then 1 class compatible with a language-independent tag
+ * (!!int, !!float, !!timestamp etc)
+ *
+ * @param clazz
+ * - Class to check compatibility
+ * @return true when the Class can be represented by this
+ * language-independent tag
+ */
+ public boolean isCompatible(Class<?> clazz) {
+ Set<Class<?>> set = COMPATIBILITY_MAP.get(this);
+ if (set != null) {
+ return set.contains(clazz);
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Check whether this tag matches the global tag for the Class
+ *
+ * @param clazz
+ * - Class to check
+ * @return true when the this tag can be used as a global tag for the Class
+ */
+ public boolean matches(Class<? extends Object> clazz) {
+ return value.equals(Tag.PREFIX + clazz.getName());
+ }
+
+ public int compareTo(Tag o) {
+ return value.compareTo(o.getValue());
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/parser/Production.java b/src/main/java/org/yaml/snakeyaml/parser/Production.java
index 8df3c4e..d81fe5a 100644
--- a/src/main/java/org/yaml/snakeyaml/parser/Production.java
+++ b/src/main/java/org/yaml/snakeyaml/parser/Production.java
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.parser;
-
-import org.yaml.snakeyaml.events.Event;
-
-/**
- * Helper for {@link ParserImpl}. A grammar rule to apply given the symbols on
- * top of its stack and the next input token
- *
- * @see http://en.wikipedia.org/wiki/LL_parser
- */
-interface Production {
- public Event produce();
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.parser;
+
+import org.yaml.snakeyaml.events.Event;
+
+/**
+ * Helper for {@link ParserImpl}. A grammar rule to apply given the symbols on
+ * top of its stack and the next input token
+ *
+ * @see http://en.wikipedia.org/wiki/LL_parser
+ */
+interface Production {
+ public Event produce();
+}
diff --git a/src/main/java/org/yaml/snakeyaml/reader/ReaderException.java b/src/main/java/org/yaml/snakeyaml/reader/ReaderException.java
index 84816ba..8c16f2e 100644
--- a/src/main/java/org/yaml/snakeyaml/reader/ReaderException.java
+++ b/src/main/java/org/yaml/snakeyaml/reader/ReaderException.java
@@ -1,40 +1,40 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.reader;
-
-import org.yaml.snakeyaml.error.YAMLException;
-
-public class ReaderException extends YAMLException {
- private static final long serialVersionUID = 8710781187529689083L;
- private String name;
- private char character;
- private int position;
-
- public ReaderException(String name, int position, char character, String message) {
- super(message);
- this.name = name;
- this.character = character;
- this.position = position;
- }
-
- @Override
- public String toString() {
- return "unacceptable character '" + character + "' (0x"
- + Integer.toHexString((int) character).toUpperCase() + ") " + getMessage()
- + "\nin \"" + name + "\", position " + position;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.reader;
+
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class ReaderException extends YAMLException {
+ private static final long serialVersionUID = 8710781187529689083L;
+ private String name;
+ private char character;
+ private int position;
+
+ public ReaderException(String name, int position, char character, String message) {
+ super(message);
+ this.name = name;
+ this.character = character;
+ this.position = position;
+ }
+
+ @Override
+ public String toString() {
+ return "unacceptable character '" + character + "' (0x"
+ + Integer.toHexString((int) character).toUpperCase() + ") " + getMessage()
+ + "\nin \"" + name + "\", position " + position;
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/reader/StreamReader.java b/src/main/java/org/yaml/snakeyaml/reader/StreamReader.java
index 95cf952..99f7640 100644
--- a/src/main/java/org/yaml/snakeyaml/reader/StreamReader.java
+++ b/src/main/java/org/yaml/snakeyaml/reader/StreamReader.java
@@ -1,219 +1,219 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.reader;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.charset.Charset;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.scanner.Constant;
-
-/**
- * Reader: checks if characters are in allowed range, adds '\0' to the end.
- */
-public class StreamReader {
- // NON_PRINTABLE changed from PyYAML: \uFFFD excluded because Java returns
- // it in case of data corruption
- final static Pattern NON_PRINTABLE = Pattern
- .compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
- private String name;
- private final Reader stream;
- private int pointer = 0;
- private boolean eof = true;
- private String buffer;
- private int index = 0;
- private int line = 0;
- private int column = 0;
- private char[] data;
-
- public StreamReader(String stream) {
- this.name = "<string>";
- this.buffer = ""; // to set length to 0
- checkPrintable(stream);
- this.buffer = stream + "\0";
- this.stream = null;
- this.eof = true;
- this.data = null;
- }
-
- public StreamReader(Reader reader) {
- this.name = "<reader>";
- this.buffer = "";
- this.stream = reader;
- this.eof = false;
- this.data = new char[1024];
- this.update();
- }
-
- void checkPrintable(CharSequence data) {
- Matcher em = NON_PRINTABLE.matcher(data);
- if (em.find()) {
- int position = this.index + this.buffer.length() - this.pointer + em.start();
- throw new ReaderException(name, position, em.group().charAt(0),
- "special characters are not allowed");
- }
- }
-
- /**
- * Checks <code>chars</chars> for the non-printable characters.
- *
- * @param chars
- * the array where to search.
- * @param begin
- * the beginning index, inclusive.
- * @param end
- * the ending index, exclusive.
- * @throws ReaderException
- * if <code>chars</code> contains non-printable character(s).
- */
- void checkPrintable(final char[] chars, final int begin, final int end) {
- for (int i = begin; i < end; i++) {
- final char c = chars[i];
-
- if ((c >= '\u0020' && c <= '\u007E') || c == '\n' || c == '\r' || c == '\t'
- || c == '\u0085' || (c >= '\u00A0' && c <= '\uD7FF')
- || (c >= '\uE000' && c <= '\uFFFC')) {
- continue;
- }
-
- int position = this.index + this.buffer.length() - this.pointer + i;
- throw new ReaderException(name, position, c, "special characters are not allowed");
- }
- }
-
- public Mark getMark() {
- return new Mark(name, this.index, this.line, this.column, this.buffer, this.pointer);
- }
-
- public void forward() {
- forward(1);
- }
-
- /**
- * read the next length characters and move the pointer.
- *
- * @param length
- */
- public void forward(int length) {
- if (this.pointer + length + 1 >= this.buffer.length()) {
- update();
- }
- char ch = 0;
- for (int i = 0; i < length; i++) {
- ch = this.buffer.charAt(this.pointer);
- this.pointer++;
- this.index++;
- if (Constant.LINEBR.has(ch) || (ch == '\r' && buffer.charAt(pointer) != '\n')) {
- this.line++;
- this.column = 0;
- } else if (ch != '\uFEFF') {
- this.column++;
- }
- }
- }
-
- public char peek() {
- return this.buffer.charAt(this.pointer);
- }
-
- /**
- * Peek the next index-th character
- *
- * @param index
- * @return
- */
- public char peek(int index) {
- if (this.pointer + index + 1 > this.buffer.length()) {
- update();
- }
- return this.buffer.charAt(this.pointer + index);
- }
-
- /**
- * peek the next length characters
- *
- * @param length
- * @return
- */
- public String prefix(int length) {
- if (this.pointer + length >= this.buffer.length()) {
- update();
- }
- if (this.pointer + length > this.buffer.length()) {
- return this.buffer.substring(this.pointer);
- }
- return this.buffer.substring(this.pointer, this.pointer + length);
- }
-
- /**
- * prefix(length) immediately followed by forward(length)
- */
- public String prefixForward(int length) {
- final String prefix = prefix(length);
- this.pointer += length;
- this.index += length;
- // prefix never contains new line characters
- this.column += length;
- return prefix;
- }
-
- private void update() {
- if (!this.eof) {
- this.buffer = buffer.substring(this.pointer);
- this.pointer = 0;
- try {
- int converted = this.stream.read(data);
- if (converted > 0) {
- /*
- * Let's create StringBuilder manually. Anyway str1 + str2
- * generates new StringBuilder(str1).append(str2).toSting()
- * Giving correct capacity to the constructor prevents
- * unnecessary operations in appends.
- */
- checkPrintable(data, 0, converted);
- this.buffer = new StringBuilder(buffer.length() + converted).append(buffer)
- .append(data, 0, converted).toString();
- } else {
- this.eof = true;
- this.buffer += "\0";
- }
- } catch (IOException ioe) {
- throw new YAMLException(ioe);
- }
- }
- }
-
- public int getColumn() {
- return column;
- }
-
- public Charset getEncoding() {
- return Charset.forName(((UnicodeReader) this.stream).getEncoding());
- }
-
- public int getIndex() {
- return index;
- }
-
- public int getLine() {
- return line;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.reader;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.nio.charset.Charset;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.scanner.Constant;
+
+/**
+ * Reader: checks if characters are in allowed range, adds '\0' to the end.
+ */
+public class StreamReader {
+ // NON_PRINTABLE changed from PyYAML: \uFFFD excluded because Java returns
+ // it in case of data corruption
+ final static Pattern NON_PRINTABLE = Pattern
+ .compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
+ private String name;
+ private final Reader stream;
+ private int pointer = 0;
+ private boolean eof = true;
+ private String buffer;
+ private int index = 0;
+ private int line = 0;
+ private int column = 0;
+ private char[] data;
+
+ public StreamReader(String stream) {
+ this.name = "<string>";
+ this.buffer = ""; // to set length to 0
+ checkPrintable(stream);
+ this.buffer = stream + "\0";
+ this.stream = null;
+ this.eof = true;
+ this.data = null;
+ }
+
+ public StreamReader(Reader reader) {
+ this.name = "<reader>";
+ this.buffer = "";
+ this.stream = reader;
+ this.eof = false;
+ this.data = new char[1024];
+ this.update();
+ }
+
+ void checkPrintable(CharSequence data) {
+ Matcher em = NON_PRINTABLE.matcher(data);
+ if (em.find()) {
+ int position = this.index + this.buffer.length() - this.pointer + em.start();
+ throw new ReaderException(name, position, em.group().charAt(0),
+ "special characters are not allowed");
+ }
+ }
+
+ /**
+ * Checks <code>chars</chars> for the non-printable characters.
+ *
+ * @param chars
+ * the array where to search.
+ * @param begin
+ * the beginning index, inclusive.
+ * @param end
+ * the ending index, exclusive.
+ * @throws ReaderException
+ * if <code>chars</code> contains non-printable character(s).
+ */
+ void checkPrintable(final char[] chars, final int begin, final int end) {
+ for (int i = begin; i < end; i++) {
+ final char c = chars[i];
+
+ if ((c >= '\u0020' && c <= '\u007E') || c == '\n' || c == '\r' || c == '\t'
+ || c == '\u0085' || (c >= '\u00A0' && c <= '\uD7FF')
+ || (c >= '\uE000' && c <= '\uFFFC')) {
+ continue;
+ }
+
+ int position = this.index + this.buffer.length() - this.pointer + i;
+ throw new ReaderException(name, position, c, "special characters are not allowed");
+ }
+ }
+
+ public Mark getMark() {
+ return new Mark(name, this.index, this.line, this.column, this.buffer, this.pointer);
+ }
+
+ public void forward() {
+ forward(1);
+ }
+
+ /**
+ * read the next length characters and move the pointer.
+ *
+ * @param length
+ */
+ public void forward(int length) {
+ if (this.pointer + length + 1 >= this.buffer.length()) {
+ update();
+ }
+ char ch = 0;
+ for (int i = 0; i < length; i++) {
+ ch = this.buffer.charAt(this.pointer);
+ this.pointer++;
+ this.index++;
+ if (Constant.LINEBR.has(ch) || (ch == '\r' && buffer.charAt(pointer) != '\n')) {
+ this.line++;
+ this.column = 0;
+ } else if (ch != '\uFEFF') {
+ this.column++;
+ }
+ }
+ }
+
+ public char peek() {
+ return this.buffer.charAt(this.pointer);
+ }
+
+ /**
+ * Peek the next index-th character
+ *
+ * @param index
+ * @return
+ */
+ public char peek(int index) {
+ if (this.pointer + index + 1 > this.buffer.length()) {
+ update();
+ }
+ return this.buffer.charAt(this.pointer + index);
+ }
+
+ /**
+ * peek the next length characters
+ *
+ * @param length
+ * @return
+ */
+ public String prefix(int length) {
+ if (this.pointer + length >= this.buffer.length()) {
+ update();
+ }
+ if (this.pointer + length > this.buffer.length()) {
+ return this.buffer.substring(this.pointer);
+ }
+ return this.buffer.substring(this.pointer, this.pointer + length);
+ }
+
+ /**
+ * prefix(length) immediately followed by forward(length)
+ */
+ public String prefixForward(int length) {
+ final String prefix = prefix(length);
+ this.pointer += length;
+ this.index += length;
+ // prefix never contains new line characters
+ this.column += length;
+ return prefix;
+ }
+
+ private void update() {
+ if (!this.eof) {
+ this.buffer = buffer.substring(this.pointer);
+ this.pointer = 0;
+ try {
+ int converted = this.stream.read(data);
+ if (converted > 0) {
+ /*
+ * Let's create StringBuilder manually. Anyway str1 + str2
+ * generates new StringBuilder(str1).append(str2).toSting()
+ * Giving correct capacity to the constructor prevents
+ * unnecessary operations in appends.
+ */
+ checkPrintable(data, 0, converted);
+ this.buffer = new StringBuilder(buffer.length() + converted).append(buffer)
+ .append(data, 0, converted).toString();
+ } else {
+ this.eof = true;
+ this.buffer += "\0";
+ }
+ } catch (IOException ioe) {
+ throw new YAMLException(ioe);
+ }
+ }
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ public Charset getEncoding() {
+ return Charset.forName(((UnicodeReader) this.stream).getEncoding());
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public int getLine() {
+ return line;
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/representer/BaseRepresenter.java b/src/main/java/org/yaml/snakeyaml/representer/BaseRepresenter.java
index dd74185..6d23820 100644
--- a/src/main/java/org/yaml/snakeyaml/representer/BaseRepresenter.java
+++ b/src/main/java/org/yaml/snakeyaml/representer/BaseRepresenter.java
@@ -1,209 +1,209 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.IdentityHashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.introspector.PropertyUtils;
-import org.yaml.snakeyaml.nodes.AnchorNode;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Represent basic YAML structures: scalar, sequence, mapping
- */
-public abstract class BaseRepresenter {
- protected final Map<Class<?>, Represent> representers = new HashMap<Class<?>, Represent>();
- /**
- * in Java 'null' is not a type. So we have to keep the null representer
- * separately otherwise it will coincide with the default representer which
- * is stored with the key null.
- */
- protected Represent nullRepresenter;
- // the order is important (map can be also a sequence of key-values)
- protected final Map<Class<?>, Represent> multiRepresenters = new LinkedHashMap<Class<?>, Represent>();
- protected Character defaultScalarStyle;
- protected FlowStyle defaultFlowStyle = FlowStyle.AUTO;
- protected final Map<Object, Node> representedObjects = new IdentityHashMap<Object, Node>() {
- private static final long serialVersionUID = -5576159264232131854L;
-
- public Node put(Object key, Node value) {
- return super.put(key, new AnchorNode(value));
- }
- };
-
- protected Object objectToRepresent;
- private PropertyUtils propertyUtils;
- private boolean explicitPropertyUtils = false;
-
- public Node represent(Object data) {
- Node node = representData(data);
- representedObjects.clear();
- objectToRepresent = null;
- return node;
- }
-
- protected final Node representData(Object data) {
- objectToRepresent = data;
- // check for identity
- if (representedObjects.containsKey(objectToRepresent)) {
- Node node = representedObjects.get(objectToRepresent);
- return node;
- }
- // }
- // check for null first
- if (data == null) {
- Node node = nullRepresenter.representData(data);
- return node;
- }
- // check the same class
- Node node;
- Class<?> clazz = data.getClass();
- if (representers.containsKey(clazz)) {
- Represent representer = representers.get(clazz);
- node = representer.representData(data);
- } else {
- // check the parents
- for (Class<?> repr : multiRepresenters.keySet()) {
- if (repr.isInstance(data)) {
- Represent representer = multiRepresenters.get(repr);
- node = representer.representData(data);
- return node;
- }
- }
- // check array of primitives
- if (clazz.isArray()) {
- throw new YAMLException("Arrays of primitives are not fully supported.");
- }
- // check defaults
- if (multiRepresenters.containsKey(null)) {
- Represent representer = multiRepresenters.get(null);
- node = representer.representData(data);
- } else {
- Represent representer = representers.get(null);
- node = representer.representData(data);
- }
- }
- return node;
- }
-
- protected Node representScalar(Tag tag, String value, Character style) {
- if (style == null) {
- style = this.defaultScalarStyle;
- }
- Node node = new ScalarNode(tag, value, null, null, style);
- return node;
- }
-
- protected Node representScalar(Tag tag, String value) {
- return representScalar(tag, value, null);
- }
-
- protected Node representSequence(Tag tag, Iterable<? extends Object> sequence, Boolean flowStyle) {
- int size = 10;// default for ArrayList
- if (sequence instanceof List<?>) {
- size = ((List<?>) sequence).size();
- }
- List<Node> value = new ArrayList<Node>(size);
- SequenceNode node = new SequenceNode(tag, value, flowStyle);
- representedObjects.put(objectToRepresent, node);
- boolean bestStyle = true;
- for (Object item : sequence) {
- Node nodeItem = representData(item);
- if (!((nodeItem instanceof ScalarNode && ((ScalarNode) nodeItem).getStyle() == null))) {
- bestStyle = false;
- }
- value.add(nodeItem);
- }
- if (flowStyle == null) {
- if (defaultFlowStyle != FlowStyle.AUTO) {
- node.setFlowStyle(defaultFlowStyle.getStyleBoolean());
- } else {
- node.setFlowStyle(bestStyle);
- }
- }
- return node;
- }
-
- protected Node representMapping(Tag tag, Map<? extends Object, Object> mapping,
- Boolean flowStyle) {
- List<NodeTuple> value = new ArrayList<NodeTuple>(mapping.size());
- MappingNode node = new MappingNode(tag, value, flowStyle);
- representedObjects.put(objectToRepresent, node);
- boolean bestStyle = true;
- for (Object itemKey : mapping.keySet()) {
- Object itemValue = mapping.get(itemKey);
- Node nodeKey = representData(itemKey);
- Node nodeValue = representData(itemValue);
- if (!((nodeKey instanceof ScalarNode && ((ScalarNode) nodeKey).getStyle() == null))) {
- bestStyle = false;
- }
- if (!((nodeValue instanceof ScalarNode && ((ScalarNode) nodeValue).getStyle() == null))) {
- bestStyle = false;
- }
- value.add(new NodeTuple(nodeKey, nodeValue));
- }
- if (flowStyle == null) {
- if (defaultFlowStyle != FlowStyle.AUTO) {
- node.setFlowStyle(defaultFlowStyle.getStyleBoolean());
- } else {
- node.setFlowStyle(bestStyle);
- }
- }
- return node;
- }
-
- public void setDefaultScalarStyle(ScalarStyle defaultStyle) {
- this.defaultScalarStyle = defaultStyle.getChar();
- }
-
- public void setDefaultFlowStyle(FlowStyle defaultFlowStyle) {
- this.defaultFlowStyle = defaultFlowStyle;
- }
-
- public FlowStyle getDefaultFlowStyle() {
- return this.defaultFlowStyle;
- }
-
- public void setPropertyUtils(PropertyUtils propertyUtils) {
- this.propertyUtils = propertyUtils;
- this.explicitPropertyUtils = true;
- }
-
- public final PropertyUtils getPropertyUtils() {
- if (propertyUtils == null) {
- propertyUtils = new PropertyUtils();
- }
- return propertyUtils;
- }
-
- public final boolean isExplicitPropertyUtils() {
- return explicitPropertyUtils;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.introspector.PropertyUtils;
+import org.yaml.snakeyaml.nodes.AnchorNode;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Represent basic YAML structures: scalar, sequence, mapping
+ */
+public abstract class BaseRepresenter {
+ protected final Map<Class<?>, Represent> representers = new HashMap<Class<?>, Represent>();
+ /**
+ * in Java 'null' is not a type. So we have to keep the null representer
+ * separately otherwise it will coincide with the default representer which
+ * is stored with the key null.
+ */
+ protected Represent nullRepresenter;
+ // the order is important (map can be also a sequence of key-values)
+ protected final Map<Class<?>, Represent> multiRepresenters = new LinkedHashMap<Class<?>, Represent>();
+ protected Character defaultScalarStyle;
+ protected FlowStyle defaultFlowStyle = FlowStyle.AUTO;
+ protected final Map<Object, Node> representedObjects = new IdentityHashMap<Object, Node>() {
+ private static final long serialVersionUID = -5576159264232131854L;
+
+ public Node put(Object key, Node value) {
+ return super.put(key, new AnchorNode(value));
+ }
+ };
+
+ protected Object objectToRepresent;
+ private PropertyUtils propertyUtils;
+ private boolean explicitPropertyUtils = false;
+
+ public Node represent(Object data) {
+ Node node = representData(data);
+ representedObjects.clear();
+ objectToRepresent = null;
+ return node;
+ }
+
+ protected final Node representData(Object data) {
+ objectToRepresent = data;
+ // check for identity
+ if (representedObjects.containsKey(objectToRepresent)) {
+ Node node = representedObjects.get(objectToRepresent);
+ return node;
+ }
+ // }
+ // check for null first
+ if (data == null) {
+ Node node = nullRepresenter.representData(data);
+ return node;
+ }
+ // check the same class
+ Node node;
+ Class<?> clazz = data.getClass();
+ if (representers.containsKey(clazz)) {
+ Represent representer = representers.get(clazz);
+ node = representer.representData(data);
+ } else {
+ // check the parents
+ for (Class<?> repr : multiRepresenters.keySet()) {
+ if (repr.isInstance(data)) {
+ Represent representer = multiRepresenters.get(repr);
+ node = representer.representData(data);
+ return node;
+ }
+ }
+ // check array of primitives
+ if (clazz.isArray()) {
+ throw new YAMLException("Arrays of primitives are not fully supported.");
+ }
+ // check defaults
+ if (multiRepresenters.containsKey(null)) {
+ Represent representer = multiRepresenters.get(null);
+ node = representer.representData(data);
+ } else {
+ Represent representer = representers.get(null);
+ node = representer.representData(data);
+ }
+ }
+ return node;
+ }
+
+ protected Node representScalar(Tag tag, String value, Character style) {
+ if (style == null) {
+ style = this.defaultScalarStyle;
+ }
+ Node node = new ScalarNode(tag, value, null, null, style);
+ return node;
+ }
+
+ protected Node representScalar(Tag tag, String value) {
+ return representScalar(tag, value, null);
+ }
+
+ protected Node representSequence(Tag tag, Iterable<? extends Object> sequence, Boolean flowStyle) {
+ int size = 10;// default for ArrayList
+ if (sequence instanceof List<?>) {
+ size = ((List<?>) sequence).size();
+ }
+ List<Node> value = new ArrayList<Node>(size);
+ SequenceNode node = new SequenceNode(tag, value, flowStyle);
+ representedObjects.put(objectToRepresent, node);
+ boolean bestStyle = true;
+ for (Object item : sequence) {
+ Node nodeItem = representData(item);
+ if (!((nodeItem instanceof ScalarNode && ((ScalarNode) nodeItem).getStyle() == null))) {
+ bestStyle = false;
+ }
+ value.add(nodeItem);
+ }
+ if (flowStyle == null) {
+ if (defaultFlowStyle != FlowStyle.AUTO) {
+ node.setFlowStyle(defaultFlowStyle.getStyleBoolean());
+ } else {
+ node.setFlowStyle(bestStyle);
+ }
+ }
+ return node;
+ }
+
+ protected Node representMapping(Tag tag, Map<? extends Object, Object> mapping,
+ Boolean flowStyle) {
+ List<NodeTuple> value = new ArrayList<NodeTuple>(mapping.size());
+ MappingNode node = new MappingNode(tag, value, flowStyle);
+ representedObjects.put(objectToRepresent, node);
+ boolean bestStyle = true;
+ for (Object itemKey : mapping.keySet()) {
+ Object itemValue = mapping.get(itemKey);
+ Node nodeKey = representData(itemKey);
+ Node nodeValue = representData(itemValue);
+ if (!((nodeKey instanceof ScalarNode && ((ScalarNode) nodeKey).getStyle() == null))) {
+ bestStyle = false;
+ }
+ if (!((nodeValue instanceof ScalarNode && ((ScalarNode) nodeValue).getStyle() == null))) {
+ bestStyle = false;
+ }
+ value.add(new NodeTuple(nodeKey, nodeValue));
+ }
+ if (flowStyle == null) {
+ if (defaultFlowStyle != FlowStyle.AUTO) {
+ node.setFlowStyle(defaultFlowStyle.getStyleBoolean());
+ } else {
+ node.setFlowStyle(bestStyle);
+ }
+ }
+ return node;
+ }
+
+ public void setDefaultScalarStyle(ScalarStyle defaultStyle) {
+ this.defaultScalarStyle = defaultStyle.getChar();
+ }
+
+ public void setDefaultFlowStyle(FlowStyle defaultFlowStyle) {
+ this.defaultFlowStyle = defaultFlowStyle;
+ }
+
+ public FlowStyle getDefaultFlowStyle() {
+ return this.defaultFlowStyle;
+ }
+
+ public void setPropertyUtils(PropertyUtils propertyUtils) {
+ this.propertyUtils = propertyUtils;
+ this.explicitPropertyUtils = true;
+ }
+
+ public final PropertyUtils getPropertyUtils() {
+ if (propertyUtils == null) {
+ propertyUtils = new PropertyUtils();
+ }
+ return propertyUtils;
+ }
+
+ public final boolean isExplicitPropertyUtils() {
+ return explicitPropertyUtils;
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java b/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
index 0f2491f..ff4744d 100644
--- a/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
+++ b/src/main/java/org/yaml/snakeyaml/representer/SafeRepresenter.java
@@ -1,312 +1,312 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimeZone;
-import java.util.regex.Pattern;
-
-import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Represent standard Java classes
- */
-class SafeRepresenter extends BaseRepresenter {
-
- protected Map<Class<? extends Object>, Tag> classTags;
-
- public SafeRepresenter() {
- this.nullRepresenter = new RepresentNull();
- this.representers.put(String.class, new RepresentString());
- this.representers.put(Boolean.class, new RepresentBoolean());
- this.representers.put(Character.class, new RepresentString());
- this.representers.put(byte[].class, new RepresentByteArray());
- this.multiRepresenters.put(Number.class, new RepresentNumber());
- this.multiRepresenters.put(List.class, new RepresentList());
- this.multiRepresenters.put(Map.class, new RepresentMap());
- this.multiRepresenters.put(Set.class, new RepresentSet());
- this.multiRepresenters.put(Iterator.class, new RepresentIterator());
- this.multiRepresenters.put(new Object[0].getClass(), new RepresentArray());
- this.multiRepresenters.put(Date.class, new RepresentDate());
- this.multiRepresenters.put(Enum.class, new RepresentEnum());
- this.multiRepresenters.put(Calendar.class, new RepresentDate());
- classTags = new HashMap<Class<? extends Object>, Tag>();
- }
-
- protected Tag getTag(Class<?> clazz, Tag defaultTag) {
- if (classTags.containsKey(clazz)) {
- return classTags.get(clazz);
- } else {
- return defaultTag;
- }
- }
-
- /**
- * Define a tag for the <code>Class</code> to serialize
- *
- * @deprecated use Tag instead of String
- * @param clazz
- * <code>Class</code> which tag is changed
- * @param tag
- * new tag to be used for every instance of the specified
- * <code>Class</code>
- * @return the previous tag associated with the <code>Class</code>
- */
- public Tag addClassTag(Class<? extends Object> clazz, String tag) {
- return addClassTag(clazz, new Tag(tag));
- }
-
- /**
- * Define a tag for the <code>Class</code> to serialize.
- *
- * @param clazz
- * <code>Class</code> which tag is changed
- * @param tag
- * new tag to be used for every instance of the specified
- * <code>Class</code>
- * @return the previous tag associated with the <code>Class</code>
- */
- public Tag addClassTag(Class<? extends Object> clazz, Tag tag) {
- if (tag == null) {
- throw new NullPointerException("Tag must be provided.");
- }
- return classTags.put(clazz, tag);
- }
-
- protected class RepresentNull implements Represent {
- public Node representData(Object data) {
- return representScalar(Tag.NULL, "null");
- }
- }
-
- public static Pattern BINARY_PATTERN = Pattern.compile("[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]");
- public static Pattern MULTILINE_PATTERN = Pattern.compile("\n|\u0085|\u2028|\u2029");
-
- protected class RepresentString implements Represent {
- public Node representData(Object data) {
- Tag tag = Tag.STR;
- Character style = null;
- String value = data.toString();
- if (BINARY_PATTERN.matcher(value).find()) {
- tag = Tag.BINARY;
- char[] binary;
- binary = Base64Coder.encode(value.getBytes());
- value = String.valueOf(binary);
- style = '|';
- }
- // if no other scalar style is explicitly set, use literal style for
- // multiline scalars
- if (defaultScalarStyle == null && MULTILINE_PATTERN.matcher(value).find()) {
- style = '|';
- }
- return representScalar(tag, value, style);
- }
- }
-
- protected class RepresentBoolean implements Represent {
- public Node representData(Object data) {
- String value;
- if (Boolean.TRUE.equals(data)) {
- value = "true";
- } else {
- value = "false";
- }
- return representScalar(Tag.BOOL, value);
- }
- }
-
- protected class RepresentNumber implements Represent {
- public Node representData(Object data) {
- Tag tag;
- String value;
- if (data instanceof Byte || data instanceof Short || data instanceof Integer
- || data instanceof Long || data instanceof BigInteger) {
- tag = Tag.INT;
- value = data.toString();
- } else {
- Number number = (Number) data;
- tag = Tag.FLOAT;
- if (number.equals(Double.NaN)) {
- value = ".NaN";
- } else if (number.equals(Double.POSITIVE_INFINITY)) {
- value = ".inf";
- } else if (number.equals(Double.NEGATIVE_INFINITY)) {
- value = "-.inf";
- } else {
- value = number.toString();
- }
- }
- return representScalar(getTag(data.getClass(), tag), value);
- }
- }
-
- protected class RepresentList implements Represent {
- @SuppressWarnings("unchecked")
- public Node representData(Object data) {
- return representSequence(getTag(data.getClass(), Tag.SEQ), (List<Object>) data, null);
- }
- }
-
- protected class RepresentIterator implements Represent {
- @SuppressWarnings("unchecked")
- public Node representData(Object data) {
- Iterator<Object> iter = (Iterator<Object>) data;
- return representSequence(getTag(data.getClass(), Tag.SEQ), new IteratorWrapper(iter),
- null);
- }
- }
-
- private class IteratorWrapper implements Iterable<Object> {
- private Iterator<Object> iter;
-
- public IteratorWrapper(Iterator<Object> iter) {
- this.iter = iter;
- }
-
- public Iterator<Object> iterator() {
- return iter;
- }
- }
-
- protected class RepresentArray implements Represent {
- public Node representData(Object data) {
- Object[] array = (Object[]) data;
- List<Object> list = Arrays.asList(array);
- return representSequence(Tag.SEQ, list, null);
- }
- }
-
- protected class RepresentMap implements Represent {
- @SuppressWarnings("unchecked")
- public Node representData(Object data) {
- return representMapping(getTag(data.getClass(), Tag.MAP), (Map<Object, Object>) data,
- null);
- }
- }
-
- protected class RepresentSet implements Represent {
- @SuppressWarnings("unchecked")
- public Node representData(Object data) {
- Map<Object, Object> value = new LinkedHashMap<Object, Object>();
- Set<Object> set = (Set<Object>) data;
- for (Object key : set) {
- value.put(key, null);
- }
- return representMapping(getTag(data.getClass(), Tag.SET), value, null);
- }
- }
-
- protected class RepresentDate implements Represent {
- public Node representData(Object data) {
- // because SimpleDateFormat ignores timezone we have to use Calendar
- Calendar calendar;
- if (data instanceof Calendar) {
- calendar = (Calendar) data;
- } else {
- calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- calendar.setTime((Date) data);
- }
- int years = calendar.get(Calendar.YEAR);
- int months = calendar.get(Calendar.MONTH) + 1; // 0..12
- int days = calendar.get(Calendar.DAY_OF_MONTH); // 1..31
- int hour24 = calendar.get(Calendar.HOUR_OF_DAY); // 0..24
- int minutes = calendar.get(Calendar.MINUTE); // 0..59
- int seconds = calendar.get(Calendar.SECOND); // 0..59
- int millis = calendar.get(Calendar.MILLISECOND);
- StringBuilder buffer = new StringBuilder(String.valueOf(years));
- while (buffer.length() < 4) {
- // ancient years
- buffer.insert(0, "0");
- }
- buffer.append("-");
- if (months < 10) {
- buffer.append("0");
- }
- buffer.append(String.valueOf(months));
- buffer.append("-");
- if (days < 10) {
- buffer.append("0");
- }
- buffer.append(String.valueOf(days));
- buffer.append("T");
- if (hour24 < 10) {
- buffer.append("0");
- }
- buffer.append(String.valueOf(hour24));
- buffer.append(":");
- if (minutes < 10) {
- buffer.append("0");
- }
- buffer.append(String.valueOf(minutes));
- buffer.append(":");
- if (seconds < 10) {
- buffer.append("0");
- }
- buffer.append(String.valueOf(seconds));
- if (millis > 0) {
- if (millis < 10) {
- buffer.append(".00");
- } else if (millis < 100) {
- buffer.append(".0");
- } else {
- buffer.append(".");
- }
- buffer.append(String.valueOf(millis));
- }
- if (TimeZone.getTimeZone("UTC").equals(calendar.getTimeZone())) {
- buffer.append("Z");
- } else {
- // Get the Offset from GMT taking DST into account
- int gmtOffset = calendar.getTimeZone().getOffset(calendar.get(Calendar.ERA),
- calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
- calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.DAY_OF_WEEK),
- calendar.get(Calendar.MILLISECOND));
- int minutesOffset = gmtOffset / (60 * 1000);
- int hoursOffset = minutesOffset / 60;
- int partOfHour = minutesOffset % 60;
- buffer.append((hoursOffset > 0 ? "+" : "") + hoursOffset + ":"
- + (partOfHour < 10 ? "0" + partOfHour : partOfHour));
- }
- return representScalar(getTag(data.getClass(), Tag.TIMESTAMP), buffer.toString(), null);
- }
- }
-
- protected class RepresentEnum implements Represent {
- public Node representData(Object data) {
- Tag tag = new Tag(data.getClass());
- return representScalar(getTag(data.getClass(), tag), ((Enum<?>) data).name());
- }
- }
-
- protected class RepresentByteArray implements Represent {
- public Node representData(Object data) {
- char[] binary = Base64Coder.encode((byte[]) data);
- return representScalar(Tag.BINARY, String.valueOf(binary), '|');
- }
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.regex.Pattern;
+
+import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Represent standard Java classes
+ */
+class SafeRepresenter extends BaseRepresenter {
+
+ protected Map<Class<? extends Object>, Tag> classTags;
+
+ public SafeRepresenter() {
+ this.nullRepresenter = new RepresentNull();
+ this.representers.put(String.class, new RepresentString());
+ this.representers.put(Boolean.class, new RepresentBoolean());
+ this.representers.put(Character.class, new RepresentString());
+ this.representers.put(byte[].class, new RepresentByteArray());
+ this.multiRepresenters.put(Number.class, new RepresentNumber());
+ this.multiRepresenters.put(List.class, new RepresentList());
+ this.multiRepresenters.put(Map.class, new RepresentMap());
+ this.multiRepresenters.put(Set.class, new RepresentSet());
+ this.multiRepresenters.put(Iterator.class, new RepresentIterator());
+ this.multiRepresenters.put(new Object[0].getClass(), new RepresentArray());
+ this.multiRepresenters.put(Date.class, new RepresentDate());
+ this.multiRepresenters.put(Enum.class, new RepresentEnum());
+ this.multiRepresenters.put(Calendar.class, new RepresentDate());
+ classTags = new HashMap<Class<? extends Object>, Tag>();
+ }
+
+ protected Tag getTag(Class<?> clazz, Tag defaultTag) {
+ if (classTags.containsKey(clazz)) {
+ return classTags.get(clazz);
+ } else {
+ return defaultTag;
+ }
+ }
+
+ /**
+ * Define a tag for the <code>Class</code> to serialize
+ *
+ * @deprecated use Tag instead of String
+ * @param clazz
+ * <code>Class</code> which tag is changed
+ * @param tag
+ * new tag to be used for every instance of the specified
+ * <code>Class</code>
+ * @return the previous tag associated with the <code>Class</code>
+ */
+ public Tag addClassTag(Class<? extends Object> clazz, String tag) {
+ return addClassTag(clazz, new Tag(tag));
+ }
+
+ /**
+ * Define a tag for the <code>Class</code> to serialize.
+ *
+ * @param clazz
+ * <code>Class</code> which tag is changed
+ * @param tag
+ * new tag to be used for every instance of the specified
+ * <code>Class</code>
+ * @return the previous tag associated with the <code>Class</code>
+ */
+ public Tag addClassTag(Class<? extends Object> clazz, Tag tag) {
+ if (tag == null) {
+ throw new NullPointerException("Tag must be provided.");
+ }
+ return classTags.put(clazz, tag);
+ }
+
+ protected class RepresentNull implements Represent {
+ public Node representData(Object data) {
+ return representScalar(Tag.NULL, "null");
+ }
+ }
+
+ public static Pattern BINARY_PATTERN = Pattern.compile("[\\x00-\\x08\\x0B\\x0C\\x0E-\\x1F]");
+ public static Pattern MULTILINE_PATTERN = Pattern.compile("\n|\u0085|\u2028|\u2029");
+
+ protected class RepresentString implements Represent {
+ public Node representData(Object data) {
+ Tag tag = Tag.STR;
+ Character style = null;
+ String value = data.toString();
+ if (BINARY_PATTERN.matcher(value).find()) {
+ tag = Tag.BINARY;
+ char[] binary;
+ binary = Base64Coder.encode(value.getBytes());
+ value = String.valueOf(binary);
+ style = '|';
+ }
+ // if no other scalar style is explicitly set, use literal style for
+ // multiline scalars
+ if (defaultScalarStyle == null && MULTILINE_PATTERN.matcher(value).find()) {
+ style = '|';
+ }
+ return representScalar(tag, value, style);
+ }
+ }
+
+ protected class RepresentBoolean implements Represent {
+ public Node representData(Object data) {
+ String value;
+ if (Boolean.TRUE.equals(data)) {
+ value = "true";
+ } else {
+ value = "false";
+ }
+ return representScalar(Tag.BOOL, value);
+ }
+ }
+
+ protected class RepresentNumber implements Represent {
+ public Node representData(Object data) {
+ Tag tag;
+ String value;
+ if (data instanceof Byte || data instanceof Short || data instanceof Integer
+ || data instanceof Long || data instanceof BigInteger) {
+ tag = Tag.INT;
+ value = data.toString();
+ } else {
+ Number number = (Number) data;
+ tag = Tag.FLOAT;
+ if (number.equals(Double.NaN)) {
+ value = ".NaN";
+ } else if (number.equals(Double.POSITIVE_INFINITY)) {
+ value = ".inf";
+ } else if (number.equals(Double.NEGATIVE_INFINITY)) {
+ value = "-.inf";
+ } else {
+ value = number.toString();
+ }
+ }
+ return representScalar(getTag(data.getClass(), tag), value);
+ }
+ }
+
+ protected class RepresentList implements Represent {
+ @SuppressWarnings("unchecked")
+ public Node representData(Object data) {
+ return representSequence(getTag(data.getClass(), Tag.SEQ), (List<Object>) data, null);
+ }
+ }
+
+ protected class RepresentIterator implements Represent {
+ @SuppressWarnings("unchecked")
+ public Node representData(Object data) {
+ Iterator<Object> iter = (Iterator<Object>) data;
+ return representSequence(getTag(data.getClass(), Tag.SEQ), new IteratorWrapper(iter),
+ null);
+ }
+ }
+
+ private class IteratorWrapper implements Iterable<Object> {
+ private Iterator<Object> iter;
+
+ public IteratorWrapper(Iterator<Object> iter) {
+ this.iter = iter;
+ }
+
+ public Iterator<Object> iterator() {
+ return iter;
+ }
+ }
+
+ protected class RepresentArray implements Represent {
+ public Node representData(Object data) {
+ Object[] array = (Object[]) data;
+ List<Object> list = Arrays.asList(array);
+ return representSequence(Tag.SEQ, list, null);
+ }
+ }
+
+ protected class RepresentMap implements Represent {
+ @SuppressWarnings("unchecked")
+ public Node representData(Object data) {
+ return representMapping(getTag(data.getClass(), Tag.MAP), (Map<Object, Object>) data,
+ null);
+ }
+ }
+
+ protected class RepresentSet implements Represent {
+ @SuppressWarnings("unchecked")
+ public Node representData(Object data) {
+ Map<Object, Object> value = new LinkedHashMap<Object, Object>();
+ Set<Object> set = (Set<Object>) data;
+ for (Object key : set) {
+ value.put(key, null);
+ }
+ return representMapping(getTag(data.getClass(), Tag.SET), value, null);
+ }
+ }
+
+ protected class RepresentDate implements Represent {
+ public Node representData(Object data) {
+ // because SimpleDateFormat ignores timezone we have to use Calendar
+ Calendar calendar;
+ if (data instanceof Calendar) {
+ calendar = (Calendar) data;
+ } else {
+ calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ calendar.setTime((Date) data);
+ }
+ int years = calendar.get(Calendar.YEAR);
+ int months = calendar.get(Calendar.MONTH) + 1; // 0..12
+ int days = calendar.get(Calendar.DAY_OF_MONTH); // 1..31
+ int hour24 = calendar.get(Calendar.HOUR_OF_DAY); // 0..24
+ int minutes = calendar.get(Calendar.MINUTE); // 0..59
+ int seconds = calendar.get(Calendar.SECOND); // 0..59
+ int millis = calendar.get(Calendar.MILLISECOND);
+ StringBuilder buffer = new StringBuilder(String.valueOf(years));
+ while (buffer.length() < 4) {
+ // ancient years
+ buffer.insert(0, "0");
+ }
+ buffer.append("-");
+ if (months < 10) {
+ buffer.append("0");
+ }
+ buffer.append(String.valueOf(months));
+ buffer.append("-");
+ if (days < 10) {
+ buffer.append("0");
+ }
+ buffer.append(String.valueOf(days));
+ buffer.append("T");
+ if (hour24 < 10) {
+ buffer.append("0");
+ }
+ buffer.append(String.valueOf(hour24));
+ buffer.append(":");
+ if (minutes < 10) {
+ buffer.append("0");
+ }
+ buffer.append(String.valueOf(minutes));
+ buffer.append(":");
+ if (seconds < 10) {
+ buffer.append("0");
+ }
+ buffer.append(String.valueOf(seconds));
+ if (millis > 0) {
+ if (millis < 10) {
+ buffer.append(".00");
+ } else if (millis < 100) {
+ buffer.append(".0");
+ } else {
+ buffer.append(".");
+ }
+ buffer.append(String.valueOf(millis));
+ }
+ if (TimeZone.getTimeZone("UTC").equals(calendar.getTimeZone())) {
+ buffer.append("Z");
+ } else {
+ // Get the Offset from GMT taking DST into account
+ int gmtOffset = calendar.getTimeZone().getOffset(calendar.get(Calendar.ERA),
+ calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH),
+ calendar.get(Calendar.DAY_OF_MONTH), calendar.get(Calendar.DAY_OF_WEEK),
+ calendar.get(Calendar.MILLISECOND));
+ int minutesOffset = gmtOffset / (60 * 1000);
+ int hoursOffset = minutesOffset / 60;
+ int partOfHour = minutesOffset % 60;
+ buffer.append((hoursOffset > 0 ? "+" : "") + hoursOffset + ":"
+ + (partOfHour < 10 ? "0" + partOfHour : partOfHour));
+ }
+ return representScalar(getTag(data.getClass(), Tag.TIMESTAMP), buffer.toString(), null);
+ }
+ }
+
+ protected class RepresentEnum implements Represent {
+ public Node representData(Object data) {
+ Tag tag = new Tag(data.getClass());
+ return representScalar(getTag(data.getClass(), tag), ((Enum<?>) data).name());
+ }
+ }
+
+ protected class RepresentByteArray implements Represent {
+ public Node representData(Object data) {
+ char[] binary = Base64Coder.encode((byte[]) data);
+ return representScalar(Tag.BINARY, String.valueOf(binary), '|');
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/yaml/snakeyaml/resolver/ResolverTuple.java b/src/main/java/org/yaml/snakeyaml/resolver/ResolverTuple.java
index d2fbe7a..53aef27 100644
--- a/src/main/java/org/yaml/snakeyaml/resolver/ResolverTuple.java
+++ b/src/main/java/org/yaml/snakeyaml/resolver/ResolverTuple.java
@@ -1,44 +1,44 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.resolver;
-
-import java.util.regex.Pattern;
-
-import org.yaml.snakeyaml.nodes.Tag;
-
-final class ResolverTuple {
- private final Tag tag;
- private final Pattern regexp;
-
- public ResolverTuple(Tag tag, Pattern regexp) {
- this.tag = tag;
- this.regexp = regexp;
- }
-
- public Tag getTag() {
- return tag;
- }
-
- public Pattern getRegexp() {
- return regexp;
- }
-
- @Override
- public String toString() {
- return "Tuple tag=" + tag + " regexp=" + regexp;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.resolver;
+
+import java.util.regex.Pattern;
+
+import org.yaml.snakeyaml.nodes.Tag;
+
+final class ResolverTuple {
+ private final Tag tag;
+ private final Pattern regexp;
+
+ public ResolverTuple(Tag tag, Pattern regexp) {
+ this.tag = tag;
+ this.regexp = regexp;
+ }
+
+ public Tag getTag() {
+ return tag;
+ }
+
+ public Pattern getRegexp() {
+ return regexp;
+ }
+
+ @Override
+ public String toString() {
+ return "Tuple tag=" + tag + " regexp=" + regexp;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/org/yaml/snakeyaml/scanner/Constant.java b/src/main/java/org/yaml/snakeyaml/scanner/Constant.java
index aeb1818..9030854 100644
--- a/src/main/java/org/yaml/snakeyaml/scanner/Constant.java
+++ b/src/main/java/org/yaml/snakeyaml/scanner/Constant.java
@@ -1,77 +1,77 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.scanner;
-
-import java.util.Arrays;
-
-public final class Constant {
- private final static String ALPHA_S = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
-
- private final static String LINEBR_S = "\n\u0085\u2028\u2029";
- private final static String FULL_LINEBR_S = "\r" + LINEBR_S;
- private final static String NULL_OR_LINEBR_S = "\0" + FULL_LINEBR_S;
- private final static String NULL_BL_LINEBR_S = " " + NULL_OR_LINEBR_S;
- private final static String NULL_BL_T_LINEBR_S = "\t" + NULL_BL_LINEBR_S;
- private final static String NULL_BL_T_S = "\0 \t";
- private final static String URI_CHARS_S = ALPHA_S + "-;/?:@&=+$,_.!~*\'()[]%";
-
- public final static Constant LINEBR = new Constant(LINEBR_S);
- public final static Constant FULL_LINEBR = new Constant(FULL_LINEBR_S);
- public final static Constant NULL_OR_LINEBR = new Constant(NULL_OR_LINEBR_S);
- public final static Constant NULL_BL_LINEBR = new Constant(NULL_BL_LINEBR_S);
- public final static Constant NULL_BL_T_LINEBR = new Constant(NULL_BL_T_LINEBR_S);
- public final static Constant NULL_BL_T = new Constant(NULL_BL_T_S);
- public final static Constant URI_CHARS = new Constant(URI_CHARS_S);
-
- public final static Constant ALPHA = new Constant(ALPHA_S);
-
- private String content;
- boolean[] contains = new boolean[128];
- boolean noASCII = false;
-
- private Constant(String content) {
- Arrays.fill(contains, false);
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < content.length(); i++) {
- char ch = content.charAt(i);
- if (ch < 128)
- contains[ch] = true;
- else
- sb.append(ch);
- }
- if (sb.length() > 0) {
- noASCII = true;
- this.content = sb.toString();
- }
- }
-
- public boolean has(char ch) {
- return (ch < 128) ? contains[ch] : noASCII && content.indexOf(ch, 0) != -1;
- }
-
- public boolean hasNo(char ch) {
- return !has(ch);
- }
-
- public boolean has(char ch, String additional) {
- return has(ch) || additional.indexOf(ch, 0) != -1;
- }
-
- public boolean hasNo(char ch, String additional) {
- return !has(ch, additional);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.scanner;
+
+import java.util.Arrays;
+
+public final class Constant {
+ private final static String ALPHA_S = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-_";
+
+ private final static String LINEBR_S = "\n\u0085\u2028\u2029";
+ private final static String FULL_LINEBR_S = "\r" + LINEBR_S;
+ private final static String NULL_OR_LINEBR_S = "\0" + FULL_LINEBR_S;
+ private final static String NULL_BL_LINEBR_S = " " + NULL_OR_LINEBR_S;
+ private final static String NULL_BL_T_LINEBR_S = "\t" + NULL_BL_LINEBR_S;
+ private final static String NULL_BL_T_S = "\0 \t";
+ private final static String URI_CHARS_S = ALPHA_S + "-;/?:@&=+$,_.!~*\'()[]%";
+
+ public final static Constant LINEBR = new Constant(LINEBR_S);
+ public final static Constant FULL_LINEBR = new Constant(FULL_LINEBR_S);
+ public final static Constant NULL_OR_LINEBR = new Constant(NULL_OR_LINEBR_S);
+ public final static Constant NULL_BL_LINEBR = new Constant(NULL_BL_LINEBR_S);
+ public final static Constant NULL_BL_T_LINEBR = new Constant(NULL_BL_T_LINEBR_S);
+ public final static Constant NULL_BL_T = new Constant(NULL_BL_T_S);
+ public final static Constant URI_CHARS = new Constant(URI_CHARS_S);
+
+ public final static Constant ALPHA = new Constant(ALPHA_S);
+
+ private String content;
+ boolean[] contains = new boolean[128];
+ boolean noASCII = false;
+
+ private Constant(String content) {
+ Arrays.fill(contains, false);
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < content.length(); i++) {
+ char ch = content.charAt(i);
+ if (ch < 128)
+ contains[ch] = true;
+ else
+ sb.append(ch);
+ }
+ if (sb.length() > 0) {
+ noASCII = true;
+ this.content = sb.toString();
+ }
+ }
+
+ public boolean has(char ch) {
+ return (ch < 128) ? contains[ch] : noASCII && content.indexOf(ch, 0) != -1;
+ }
+
+ public boolean hasNo(char ch) {
+ return !has(ch);
+ }
+
+ public boolean has(char ch, String additional) {
+ return has(ch) || additional.indexOf(ch, 0) != -1;
+ }
+
+ public boolean hasNo(char ch, String additional) {
+ return !has(ch, additional);
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/tokens/TagTuple.java b/src/main/java/org/yaml/snakeyaml/tokens/TagTuple.java
index f87deed..f66eb14 100644
--- a/src/main/java/org/yaml/snakeyaml/tokens/TagTuple.java
+++ b/src/main/java/org/yaml/snakeyaml/tokens/TagTuple.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-public final class TagTuple {
- private final String handle;
- private final String suffix;
-
- public TagTuple(String handle, String suffix) {
- if (suffix == null) {
- throw new NullPointerException("Suffix must be provided.");
- }
- this.handle = handle;
- this.suffix = suffix;
- }
-
- public String getHandle() {
- return handle;
- }
-
- public String getSuffix() {
- return suffix;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+public final class TagTuple {
+ private final String handle;
+ private final String suffix;
+
+ public TagTuple(String handle, String suffix) {
+ if (suffix == null) {
+ throw new NullPointerException("Suffix must be provided.");
+ }
+ this.handle = handle;
+ this.suffix = suffix;
+ }
+
+ public String getHandle() {
+ return handle;
+ }
+
+ public String getSuffix() {
+ return suffix;
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/util/ArrayStack.java b/src/main/java/org/yaml/snakeyaml/util/ArrayStack.java
index 97eb33e..9da3252 100644
--- a/src/main/java/org/yaml/snakeyaml/util/ArrayStack.java
+++ b/src/main/java/org/yaml/snakeyaml/util/ArrayStack.java
@@ -1,43 +1,43 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.util;
-
-import java.util.ArrayList;
-
-public class ArrayStack<T> {
- private ArrayList<T> stack;
-
- public ArrayStack(int initSize) {
- stack = new ArrayList<T>(initSize);
- }
-
- public void push(T obj) {
- stack.add(obj);
- }
-
- public T pop() {
- return stack.remove(stack.size() - 1);
- }
-
- public boolean isEmpty() {
- return stack.isEmpty();
- }
-
- public void clear() {
- stack.clear();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.util;
+
+import java.util.ArrayList;
+
+public class ArrayStack<T> {
+ private ArrayList<T> stack;
+
+ public ArrayStack(int initSize) {
+ stack = new ArrayList<T>(initSize);
+ }
+
+ public void push(T obj) {
+ stack.add(obj);
+ }
+
+ public T pop() {
+ return stack.remove(stack.size() - 1);
+ }
+
+ public boolean isEmpty() {
+ return stack.isEmpty();
+ }
+
+ public void clear() {
+ stack.clear();
+ }
+}
diff --git a/src/main/java/org/yaml/snakeyaml/util/UriEncoder.java b/src/main/java/org/yaml/snakeyaml/util/UriEncoder.java
index 7f386f2..f7cfdee 100644
--- a/src/main/java/org/yaml/snakeyaml/util/UriEncoder.java
+++ b/src/main/java/org/yaml/snakeyaml/util/UriEncoder.java
@@ -1,63 +1,63 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.util;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.nio.ByteBuffer;
-import java.nio.CharBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CodingErrorAction;
-
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.external.com.google.gdata.util.common.base.Escaper;
-import org.yaml.snakeyaml.external.com.google.gdata.util.common.base.PercentEscaper;
-
-public abstract class UriEncoder {
- private static final CharsetDecoder UTF8Decoder = Charset.forName("UTF-8").newDecoder()
- .onMalformedInput(CodingErrorAction.REPORT);
- // Include the [] chars to the SAFEPATHCHARS_URLENCODER to avoid
- // its escape as required by spec. See
- // http://yaml.org/spec/1.1/#escaping%20in%20URI/
- private static final String SAFE_CHARS = PercentEscaper.SAFEPATHCHARS_URLENCODER + "[]/";
- private static final Escaper escaper = new PercentEscaper(SAFE_CHARS, false);
-
- /**
- * Escape special characters with '%'
- */
- public static String encode(String uri) {
- return escaper.escape(uri);
- }
-
- /**
- * Decode '%'-escaped characters. Decoding fails in case of invalid UTF-8
- */
- public static String decode(ByteBuffer buff) throws CharacterCodingException {
- CharBuffer chars = UTF8Decoder.decode(buff);
- return chars.toString();
- }
-
- public static String decode(String buff) {
- try {
- return URLDecoder.decode(buff, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new YAMLException(e);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.util;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.nio.ByteBuffer;
+import java.nio.CharBuffer;
+import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CodingErrorAction;
+
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.external.com.google.gdata.util.common.base.Escaper;
+import org.yaml.snakeyaml.external.com.google.gdata.util.common.base.PercentEscaper;
+
+public abstract class UriEncoder {
+ private static final CharsetDecoder UTF8Decoder = Charset.forName("UTF-8").newDecoder()
+ .onMalformedInput(CodingErrorAction.REPORT);
+ // Include the [] chars to the SAFEPATHCHARS_URLENCODER to avoid
+ // its escape as required by spec. See
+ // http://yaml.org/spec/1.1/#escaping%20in%20URI/
+ private static final String SAFE_CHARS = PercentEscaper.SAFEPATHCHARS_URLENCODER + "[]/";
+ private static final Escaper escaper = new PercentEscaper(SAFE_CHARS, false);
+
+ /**
+ * Escape special characters with '%'
+ */
+ public static String encode(String uri) {
+ return escaper.escape(uri);
+ }
+
+ /**
+ * Decode '%'-escaped characters. Decoding fails in case of invalid UTF-8
+ */
+ public static String decode(ByteBuffer buff) throws CharacterCodingException {
+ CharBuffer chars = UTF8Decoder.decode(buff);
+ return chars.toString();
+ }
+
+ public static String decode(String buff) {
+ try {
+ return URLDecoder.decode(buff, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new YAMLException(e);
+ }
+ }
+}
diff --git a/src/test/java/biz/source_code/base64Coder/Base64CoderTest.java b/src/test/java/biz/source_code/base64Coder/Base64CoderTest.java
index 4aaf312..ab67ce7 100644
--- a/src/test/java/biz/source_code/base64Coder/Base64CoderTest.java
+++ b/src/test/java/biz/source_code/base64Coder/Base64CoderTest.java
@@ -1,74 +1,74 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 biz.source_code.base64Coder;
-
-import java.io.UnsupportedEncodingException;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
-
-public class Base64CoderTest extends TestCase {
-
- public void testDecode() throws UnsupportedEncodingException {
- check("Aladdin:open sesame", "QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
- check("a", "YQ==");
- check("aa", "YWE=");
- check("a=", "YT0=");
- check("", "");
- }
-
- public void testFailure1() throws UnsupportedEncodingException {
- try {
- Base64Coder.decode("YQ=".toCharArray());
- fail();
- } catch (Exception e) {
- assertEquals("Length of Base64 encoded input string is not a multiple of 4.",
- e.getMessage());
- }
- }
-
- public void testFailure2() throws UnsupportedEncodingException {
- checkInvalid("\tWE=");
- checkInvalid("Y\tE=");
- checkInvalid("YW\t=");
- checkInvalid("YWE\t");
- //
- checkInvalid("©WE=");
- checkInvalid("Y©E=");
- checkInvalid("YW©=");
- checkInvalid("YWE©");
- }
-
- private void checkInvalid(String encoded) {
- try {
- Base64Coder.decode(encoded.toCharArray());
- fail("Illegal chanracter.");
- } catch (Exception e) {
- assertEquals("Illegal character in Base64 encoded data.", e.getMessage());
- }
- }
-
- private void check(String text, String encoded) throws UnsupportedEncodingException {
- char[] s1 = Base64Coder.encode(text.getBytes("UTF-8"));
- String t1 = new String(s1);
- assertEquals(encoded, t1);
- byte[] s2 = Base64Coder.decode(encoded.toCharArray());
- String t2 = new String(s2, "UTF-8");
- assertEquals(text, t2);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 biz.source_code.base64Coder;
+
+import java.io.UnsupportedEncodingException;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
+
+public class Base64CoderTest extends TestCase {
+
+ public void testDecode() throws UnsupportedEncodingException {
+ check("Aladdin:open sesame", "QWxhZGRpbjpvcGVuIHNlc2FtZQ==");
+ check("a", "YQ==");
+ check("aa", "YWE=");
+ check("a=", "YT0=");
+ check("", "");
+ }
+
+ public void testFailure1() throws UnsupportedEncodingException {
+ try {
+ Base64Coder.decode("YQ=".toCharArray());
+ fail();
+ } catch (Exception e) {
+ assertEquals("Length of Base64 encoded input string is not a multiple of 4.",
+ e.getMessage());
+ }
+ }
+
+ public void testFailure2() throws UnsupportedEncodingException {
+ checkInvalid("\tWE=");
+ checkInvalid("Y\tE=");
+ checkInvalid("YW\t=");
+ checkInvalid("YWE\t");
+ //
+ checkInvalid("©WE=");
+ checkInvalid("Y©E=");
+ checkInvalid("YW©=");
+ checkInvalid("YWE©");
+ }
+
+ private void checkInvalid(String encoded) {
+ try {
+ Base64Coder.decode(encoded.toCharArray());
+ fail("Illegal chanracter.");
+ } catch (Exception e) {
+ assertEquals("Illegal character in Base64 encoded data.", e.getMessage());
+ }
+ }
+
+ private void check(String text, String encoded) throws UnsupportedEncodingException {
+ char[] s1 = Base64Coder.encode(text.getBytes("UTF-8"));
+ String t1 = new String(s1);
+ assertEquals(encoded, t1);
+ byte[] s2 = Base64Coder.decode(encoded.toCharArray());
+ String t2 = new String(s2, "UTF-8");
+ assertEquals(text, t2);
+ }
+}
diff --git a/src/test/java/examples/AnyObjectExampleTest.java b/src/test/java/examples/AnyObjectExampleTest.java
index 9326b33..75f6f47 100644
--- a/src/test/java/examples/AnyObjectExampleTest.java
+++ b/src/test/java/examples/AnyObjectExampleTest.java
@@ -1,60 +1,60 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-public class AnyObjectExampleTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testLoad() {
- String doc = Util.getLocalResource("examples/any-object-example.yaml");
- Yaml yaml = new Yaml();
- Map<String, Object> object = (Map<String, Object>) yaml.load(doc);
- assertEquals(6, object.size());
- assertEquals("[null, null]", object.get("none").toString());
- List<?> list1 = (List<?>) object.get("none");
- assertEquals(2, list1.size());
- for (Object object2 : list1) {
- assertNull(object2);
- }
- //
- assertEquals("[true, false, true, false]", object.get("bool").toString());
- assertEquals(4, ((List<?>) object.get("bool")).size());
- //
- assertEquals(new Integer(42), object.get("int"));
- assertEquals(new Double(3.14159), object.get("float"));
- //
- assertEquals("[LITE, RES_ACID, SUS_DEXT]", object.get("list").toString());
- List<?> list2 = (List<?>) object.get("list");
- assertEquals(3, list2.size());
- for (Object object2 : list2) {
- assertEquals(object2.toString(), object2.toString().toUpperCase());
- }
- //
- assertEquals("{hp=13, sp=5}", object.get("dict").toString());
- Map<String, Integer> map = (Map<String, Integer>) object.get("dict");
- assertEquals(2, map.keySet().size());
- assertEquals(new Integer(13), map.get("hp"));
- assertEquals(new Integer(5), map.get("sp"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+public class AnyObjectExampleTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testLoad() {
+ String doc = Util.getLocalResource("examples/any-object-example.yaml");
+ Yaml yaml = new Yaml();
+ Map<String, Object> object = (Map<String, Object>) yaml.load(doc);
+ assertEquals(6, object.size());
+ assertEquals("[null, null]", object.get("none").toString());
+ List<?> list1 = (List<?>) object.get("none");
+ assertEquals(2, list1.size());
+ for (Object object2 : list1) {
+ assertNull(object2);
+ }
+ //
+ assertEquals("[true, false, true, false]", object.get("bool").toString());
+ assertEquals(4, ((List<?>) object.get("bool")).size());
+ //
+ assertEquals(new Integer(42), object.get("int"));
+ assertEquals(new Double(3.14159), object.get("float"));
+ //
+ assertEquals("[LITE, RES_ACID, SUS_DEXT]", object.get("list").toString());
+ List<?> list2 = (List<?>) object.get("list");
+ assertEquals(3, list2.size());
+ for (Object object2 : list2) {
+ assertEquals(object2.toString(), object2.toString().toUpperCase());
+ }
+ //
+ assertEquals("{hp=13, sp=5}", object.get("dict").toString());
+ Map<String, Integer> map = (Map<String, Integer>) object.get("dict");
+ assertEquals(2, map.keySet().size());
+ assertEquals(new Integer(13), map.get("hp"));
+ assertEquals(new Integer(5), map.get("sp"));
+ }
+}
diff --git a/src/test/java/examples/CollectionStyleTest.java b/src/test/java/examples/CollectionStyleTest.java
index 6a78a77..727f32d 100644
--- a/src/test/java/examples/CollectionStyleTest.java
+++ b/src/test/java/examples/CollectionStyleTest.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-public class CollectionStyleTest extends TestCase {
- public void testNestedStyle() {
- Yaml yaml = new Yaml();
- String document = " a: 1\n b:\n c: 3\n d: 4\n";
- assertEquals("a: 1\nb: {c: 3, d: 4}\n", yaml.dump(yaml.load(document)));
- }
-
- public void testNestedStyle2() {
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- String document = " a: 1\n b:\n c: 3\n d: 4\n";
- assertEquals("a: 1\nb:\n c: 3\n d: 4\n", yaml.dump(yaml.load(document)));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+public class CollectionStyleTest extends TestCase {
+ public void testNestedStyle() {
+ Yaml yaml = new Yaml();
+ String document = " a: 1\n b:\n c: 3\n d: 4\n";
+ assertEquals("a: 1\nb: {c: 3, d: 4}\n", yaml.dump(yaml.load(document)));
+ }
+
+ public void testNestedStyle2() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ String document = " a: 1\n b:\n c: 3\n d: 4\n";
+ assertEquals("a: 1\nb:\n c: 3\n d: 4\n", yaml.dump(yaml.load(document)));
+ }
+}
diff --git a/src/test/java/examples/CustomBeanResolverTest.java b/src/test/java/examples/CustomBeanResolverTest.java
index 877e934..135bcfa 100644
--- a/src/test/java/examples/CustomBeanResolverTest.java
+++ b/src/test/java/examples/CustomBeanResolverTest.java
@@ -1,84 +1,84 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.math.BigDecimal;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeId;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-
-/**
- * http://code.google.com/p/snakeyaml/issues/detail?id=75
- */
-public class CustomBeanResolverTest extends TestCase {
- private final Pattern CUSTOM_PATTERN = Pattern.compile("\\d+%");
-
- public void testOnlyBigDecimal() {
- Yaml yaml = new Yaml(new BigBeanConstructor());
- Foo foo = (Foo) yaml.load("bar: 50\nbaz: 35%\nbas: 1250");
- assertEquals(50.0, foo.bar);
- assertEquals("0.35", foo.baz.toString());
- assertEquals("1250", foo.bas);
- }
-
- public void testPrimitive() {
- Yaml yaml = new Yaml(new BigBeanConstructor());
- Foo foo = (Foo) yaml.load("bar: 50%\nbaz: 35%\nbas: 1250%\nbaw: 35");
- assertEquals(0.5, foo.bar);
- assertEquals("0.35", foo.baz.toString());
- assertEquals("1250%", foo.bas);
- assertEquals("35", foo.baw.toString());
- }
-
- class BigBeanConstructor extends Constructor {
- public BigBeanConstructor() {
- super(Foo.class);
- yamlClassConstructors.put(NodeId.scalar, new ConstructBig());
- }
-
- private class ConstructBig extends ConstructScalar {
- public Object construct(Node node) {
- if (node.getType().equals(BigDecimal.class)) {
- String val = (String) constructScalar((ScalarNode) node);
- if (CUSTOM_PATTERN.matcher(val).matches()) {
- return new BigDecimal(val.substring(0, val.length() - 1))
- .divide(new BigDecimal(100));
- }
- } else if (node.getType().isAssignableFrom(double.class)) {
- String val = (String) constructScalar((ScalarNode) node);
- if (CUSTOM_PATTERN.matcher(val).matches()) {
- return new Double(val.substring(0, val.length() - 1)) / 100;
- }
- }
- return super.construct(node);
- }
- }
- }
-
- public static class Foo {
- public double bar = 0;
- public BigDecimal baz;
- public BigDecimal baw;
- public String bas;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.math.BigDecimal;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeId;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+
+/**
+ * http://code.google.com/p/snakeyaml/issues/detail?id=75
+ */
+public class CustomBeanResolverTest extends TestCase {
+ private final Pattern CUSTOM_PATTERN = Pattern.compile("\\d+%");
+
+ public void testOnlyBigDecimal() {
+ Yaml yaml = new Yaml(new BigBeanConstructor());
+ Foo foo = (Foo) yaml.load("bar: 50\nbaz: 35%\nbas: 1250");
+ assertEquals(50.0, foo.bar);
+ assertEquals("0.35", foo.baz.toString());
+ assertEquals("1250", foo.bas);
+ }
+
+ public void testPrimitive() {
+ Yaml yaml = new Yaml(new BigBeanConstructor());
+ Foo foo = (Foo) yaml.load("bar: 50%\nbaz: 35%\nbas: 1250%\nbaw: 35");
+ assertEquals(0.5, foo.bar);
+ assertEquals("0.35", foo.baz.toString());
+ assertEquals("1250%", foo.bas);
+ assertEquals("35", foo.baw.toString());
+ }
+
+ class BigBeanConstructor extends Constructor {
+ public BigBeanConstructor() {
+ super(Foo.class);
+ yamlClassConstructors.put(NodeId.scalar, new ConstructBig());
+ }
+
+ private class ConstructBig extends ConstructScalar {
+ public Object construct(Node node) {
+ if (node.getType().equals(BigDecimal.class)) {
+ String val = (String) constructScalar((ScalarNode) node);
+ if (CUSTOM_PATTERN.matcher(val).matches()) {
+ return new BigDecimal(val.substring(0, val.length() - 1))
+ .divide(new BigDecimal(100));
+ }
+ } else if (node.getType().isAssignableFrom(double.class)) {
+ String val = (String) constructScalar((ScalarNode) node);
+ if (CUSTOM_PATTERN.matcher(val).matches()) {
+ return new Double(val.substring(0, val.length() - 1)) / 100;
+ }
+ }
+ return super.construct(node);
+ }
+ }
+ }
+
+ public static class Foo {
+ public double bar = 0;
+ public BigDecimal baz;
+ public BigDecimal baw;
+ public String bas;
+ }
+}
diff --git a/src/test/java/examples/CustomConstructor.java b/src/test/java/examples/CustomConstructor.java
index 45ebe7b..5170d30 100644
--- a/src/test/java/examples/CustomConstructor.java
+++ b/src/test/java/examples/CustomConstructor.java
@@ -1,35 +1,35 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import org.yaml.snakeyaml.Invoice;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class CustomConstructor extends Constructor {
-
- public CustomConstructor() {
- super(Invoice.class);
- }
-
- @Override
- protected List<Object> createDefaultList(int initSize) {
- return new LinkedList<Object>();
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.yaml.snakeyaml.Invoice;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class CustomConstructor extends Constructor {
+
+ public CustomConstructor() {
+ super(Invoice.class);
+ }
+
+ @Override
+ protected List<Object> createDefaultList(int initSize) {
+ return new LinkedList<Object>();
+ }
}
\ No newline at end of file
diff --git a/src/test/java/examples/CustomImplicitResolverTest.java b/src/test/java/examples/CustomImplicitResolverTest.java
index c08c74b..2e73a98 100644
--- a/src/test/java/examples/CustomImplicitResolverTest.java
+++ b/src/test/java/examples/CustomImplicitResolverTest.java
@@ -1,73 +1,73 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.math.BigDecimal;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Use custom implicit resolver when the runtime class is not defined.
- * http://code.google.com/p/snakeyaml/issues/detail?id=75
- */
-public class CustomImplicitResolverTest extends TestCase {
- private final Tag CUSTOM_TAG = new Tag("!BigDecimalDividedBy100");
- private final Pattern CUSTOM_PATTERN = Pattern.compile("\\d+%");
-
- @SuppressWarnings("unchecked")
- public void testImplicit() {
- Yaml yaml = new Yaml(new BigConstructor());
- yaml.addImplicitResolver(CUSTOM_TAG, CUSTOM_PATTERN, "-0123456789");
- Map<String, Object> obj = (Map<String, Object>) yaml.load("bar: 50%");
- assertEquals("0.5", obj.get("bar").toString());
- assertEquals(BigDecimal.class, obj.get("bar").getClass());
- }
-
- public void testImplicitFailure() {
- Yaml yaml = new Yaml(new BigConstructor());
- yaml.addImplicitResolver(CUSTOM_TAG, Pattern.compile("\\d+%"), "-0123456789");
- try {
- yaml.load("bar: !!float 50%");
- fail("Both implicit and explicit are present.");
- } catch (NumberFormatException e) {
- assertEquals("For input string: \"50%\"", e.getMessage());
- }
- }
-
- class BigConstructor extends SafeConstructor {
- public BigConstructor() {
- this.yamlConstructors.put(CUSTOM_TAG, new ConstructBig());
- }
-
- private class ConstructBig extends AbstractConstruct {
- public Object construct(Node node) {
- String val = (String) constructScalar((ScalarNode) node);
- return new BigDecimal(val.substring(0, val.length() - 1))
- .divide(new BigDecimal(100));
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.math.BigDecimal;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Use custom implicit resolver when the runtime class is not defined.
+ * http://code.google.com/p/snakeyaml/issues/detail?id=75
+ */
+public class CustomImplicitResolverTest extends TestCase {
+ private final Tag CUSTOM_TAG = new Tag("!BigDecimalDividedBy100");
+ private final Pattern CUSTOM_PATTERN = Pattern.compile("\\d+%");
+
+ @SuppressWarnings("unchecked")
+ public void testImplicit() {
+ Yaml yaml = new Yaml(new BigConstructor());
+ yaml.addImplicitResolver(CUSTOM_TAG, CUSTOM_PATTERN, "-0123456789");
+ Map<String, Object> obj = (Map<String, Object>) yaml.load("bar: 50%");
+ assertEquals("0.5", obj.get("bar").toString());
+ assertEquals(BigDecimal.class, obj.get("bar").getClass());
+ }
+
+ public void testImplicitFailure() {
+ Yaml yaml = new Yaml(new BigConstructor());
+ yaml.addImplicitResolver(CUSTOM_TAG, Pattern.compile("\\d+%"), "-0123456789");
+ try {
+ yaml.load("bar: !!float 50%");
+ fail("Both implicit and explicit are present.");
+ } catch (NumberFormatException e) {
+ assertEquals("For input string: \"50%\"", e.getMessage());
+ }
+ }
+
+ class BigConstructor extends SafeConstructor {
+ public BigConstructor() {
+ this.yamlConstructors.put(CUSTOM_TAG, new ConstructBig());
+ }
+
+ private class ConstructBig extends AbstractConstruct {
+ public Object construct(Node node) {
+ String val = (String) constructScalar((ScalarNode) node);
+ return new BigDecimal(val.substring(0, val.length() - 1))
+ .divide(new BigDecimal(100));
+ }
+ }
+ }
+}
diff --git a/src/test/java/examples/CustomListExampleTest.java b/src/test/java/examples/CustomListExampleTest.java
index f8fb300..ec6e47d 100644
--- a/src/test/java/examples/CustomListExampleTest.java
+++ b/src/test/java/examples/CustomListExampleTest.java
@@ -1,41 +1,41 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class CustomListExampleTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testList() {
- Yaml yaml = new Yaml(new CustomConstructor());
- List<Integer> data = (List<Integer>) yaml.load("[1, 2, 3]");
- assertTrue(data instanceof LinkedList);
- }
-
- class CustomConstructor extends Constructor {
- @Override
- protected List<Object> createDefaultList(int initSize) {
- return new LinkedList<Object>();
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class CustomListExampleTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testList() {
+ Yaml yaml = new Yaml(new CustomConstructor());
+ List<Integer> data = (List<Integer>) yaml.load("[1, 2, 3]");
+ assertTrue(data instanceof LinkedList);
+ }
+
+ class CustomConstructor extends Constructor {
+ @Override
+ protected List<Object> createDefaultList(int initSize) {
+ return new LinkedList<Object>();
+ }
+ }
+}
diff --git a/src/test/java/examples/CustomMapExampleTest.java b/src/test/java/examples/CustomMapExampleTest.java
index ce66af6..4b64445 100644
--- a/src/test/java/examples/CustomMapExampleTest.java
+++ b/src/test/java/examples/CustomMapExampleTest.java
@@ -1,47 +1,47 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class CustomMapExampleTest extends TestCase {
- public void testMap() {
- Yaml yaml = new Yaml(new CustomConstructor());
- @SuppressWarnings("unchecked")
- Map<Integer, String> data = (Map<Integer, String>) yaml
- .load("{2: '222', 1: '111', 3: '333'}");
- assertTrue(data instanceof TreeMap);
- Object[] keys = data.keySet().toArray();
- // must be sorted
- assertEquals(new Integer(1), keys[0]);
- assertEquals(new Integer(2), keys[1]);
- assertEquals(new Integer(3), keys[2]);
- }
-
- class CustomConstructor extends Constructor {
- @Override
- protected Map<Object, Object> createDefaultMap() {
- return new TreeMap<Object, Object>();
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class CustomMapExampleTest extends TestCase {
+ public void testMap() {
+ Yaml yaml = new Yaml(new CustomConstructor());
+ @SuppressWarnings("unchecked")
+ Map<Integer, String> data = (Map<Integer, String>) yaml
+ .load("{2: '222', 1: '111', 3: '333'}");
+ assertTrue(data instanceof TreeMap);
+ Object[] keys = data.keySet().toArray();
+ // must be sorted
+ assertEquals(new Integer(1), keys[0]);
+ assertEquals(new Integer(2), keys[1]);
+ assertEquals(new Integer(3), keys[2]);
+ }
+
+ class CustomConstructor extends Constructor {
+ @Override
+ protected Map<Object, Object> createDefaultMap() {
+ return new TreeMap<Object, Object>();
+ }
+ }
+}
diff --git a/src/test/java/examples/Dice.java b/src/test/java/examples/Dice.java
index 03a57ad..fa16d57 100644
--- a/src/test/java/examples/Dice.java
+++ b/src/test/java/examples/Dice.java
@@ -1,54 +1,54 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-public class Dice {
- private Integer a;
- private Integer b;
-
- public Dice(Integer a, Integer b) {
- super();
- this.a = a;
- this.b = b;
- }
-
- public Integer getA() {
- return a;
- }
-
- public Integer getB() {
- return b;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Dice) {
- return toString().equals(obj.toString());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return toString().hashCode();
- }
-
- @Override
- public String toString() {
- return "Dice " + a + "d" + b;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+public class Dice {
+ private Integer a;
+ private Integer b;
+
+ public Dice(Integer a, Integer b) {
+ super();
+ this.a = a;
+ this.b = b;
+ }
+
+ public Integer getA() {
+ return a;
+ }
+
+ public Integer getB() {
+ return b;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Dice) {
+ return toString().equals(obj.toString());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "Dice " + a + "d" + b;
+ }
+}
diff --git a/src/test/java/examples/DiceExampleTest.java b/src/test/java/examples/DiceExampleTest.java
index d01cb2d..98e9e7d 100644
--- a/src/test/java/examples/DiceExampleTest.java
+++ b/src/test/java/examples/DiceExampleTest.java
@@ -1,125 +1,125 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Represent;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class DiceExampleTest extends TestCase {
- public void testRepresenter() {
- Dice dice = new Dice(3, 6);
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(dice);
- assertEquals("!!examples.Dice {a: 3, b: 6}\n", output);
- }
-
- public void testDiceRepresenter() {
- Dice dice = new Dice(3, 6);
- Map<String, Dice> data = new HashMap<String, Dice>();
- data.put("gold", dice);
- Yaml yaml = new Yaml(new DiceRepresenter(), new DumperOptions());
- String output = yaml.dump(data);
- assertEquals("{gold: !dice '3d6'}\n", output);
- }
-
- class DiceRepresenter extends Representer {
- public DiceRepresenter() {
- this.representers.put(Dice.class, new RepresentDice());
- }
-
- private class RepresentDice implements Represent {
- public Node representData(Object data) {
- Dice dice = (Dice) data;
- String value = dice.getA() + "d" + dice.getB();
- return representScalar(new Tag("!dice"), value);
- }
- }
- }
-
- class DiceConstructor extends SafeConstructor {
- public DiceConstructor() {
- this.yamlConstructors.put(new Tag("!dice"), new ConstructDice());
- }
-
- private class ConstructDice extends AbstractConstruct {
- public Object construct(Node node) {
- String val = (String) constructScalar((ScalarNode) node);
- int position = val.indexOf('d');
- Integer a = new Integer(val.substring(0, position));
- Integer b = new Integer(val.substring(position + 1));
- return new Dice(a, b);
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testConstructor() {
- Yaml yaml = new Yaml(new DiceConstructor());
- Object data = yaml.load("{initial hit points: !dice '8d4'}");
- Map<String, Dice> map = (Map<String, Dice>) data;
- assertEquals(new Dice(8, 4), map.get("initial hit points"));
- }
-
- // the tag must start with a digit
- @SuppressWarnings("unchecked")
- public void testImplicitResolver() {
- Yaml yaml = new Yaml(new DiceConstructor(), new DiceRepresenter());
- // the tag must start with a digit
- yaml.addImplicitResolver(new Tag("!dice"), Pattern.compile("\\d+d\\d+"), "123456789");
- // dump
- Map<String, Dice> treasure = (Map<String, Dice>) new HashMap<String, Dice>();
- treasure.put("treasure", new Dice(10, 20));
- String output = yaml.dump(treasure);
- assertEquals("{treasure: 10d20}\n", output);
- // load
- Object data = yaml.load("{damage: 5d10}");
- Map<String, Dice> map = (Map<String, Dice>) data;
- assertEquals(new Dice(5, 10), map.get("damage"));
- }
-
- // the tag may start with anything
- @SuppressWarnings("unchecked")
- public void testImplicitResolverWithNull() {
- Yaml yaml = new Yaml(new DiceConstructor(), new DiceRepresenter());
- // the tag may start with anything
- yaml.addImplicitResolver(new Tag("!dice"), Pattern.compile("\\d+d\\d+"), null);
- // dump
- Map<String, Dice> treasure = (Map<String, Dice>) new HashMap<String, Dice>();
- treasure.put("treasure", new Dice(10, 20));
- String output = yaml.dump(treasure);
- assertEquals("{treasure: 10d20}\n", output);
- // load
- Object data = yaml.load("{damage: 5d10}");
- Map<String, Dice> map = (Map<String, Dice>) data;
- assertEquals(new Dice(5, 10), map.get("damage"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Represent;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class DiceExampleTest extends TestCase {
+ public void testRepresenter() {
+ Dice dice = new Dice(3, 6);
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(dice);
+ assertEquals("!!examples.Dice {a: 3, b: 6}\n", output);
+ }
+
+ public void testDiceRepresenter() {
+ Dice dice = new Dice(3, 6);
+ Map<String, Dice> data = new HashMap<String, Dice>();
+ data.put("gold", dice);
+ Yaml yaml = new Yaml(new DiceRepresenter(), new DumperOptions());
+ String output = yaml.dump(data);
+ assertEquals("{gold: !dice '3d6'}\n", output);
+ }
+
+ class DiceRepresenter extends Representer {
+ public DiceRepresenter() {
+ this.representers.put(Dice.class, new RepresentDice());
+ }
+
+ private class RepresentDice implements Represent {
+ public Node representData(Object data) {
+ Dice dice = (Dice) data;
+ String value = dice.getA() + "d" + dice.getB();
+ return representScalar(new Tag("!dice"), value);
+ }
+ }
+ }
+
+ class DiceConstructor extends SafeConstructor {
+ public DiceConstructor() {
+ this.yamlConstructors.put(new Tag("!dice"), new ConstructDice());
+ }
+
+ private class ConstructDice extends AbstractConstruct {
+ public Object construct(Node node) {
+ String val = (String) constructScalar((ScalarNode) node);
+ int position = val.indexOf('d');
+ Integer a = new Integer(val.substring(0, position));
+ Integer b = new Integer(val.substring(position + 1));
+ return new Dice(a, b);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testConstructor() {
+ Yaml yaml = new Yaml(new DiceConstructor());
+ Object data = yaml.load("{initial hit points: !dice '8d4'}");
+ Map<String, Dice> map = (Map<String, Dice>) data;
+ assertEquals(new Dice(8, 4), map.get("initial hit points"));
+ }
+
+ // the tag must start with a digit
+ @SuppressWarnings("unchecked")
+ public void testImplicitResolver() {
+ Yaml yaml = new Yaml(new DiceConstructor(), new DiceRepresenter());
+ // the tag must start with a digit
+ yaml.addImplicitResolver(new Tag("!dice"), Pattern.compile("\\d+d\\d+"), "123456789");
+ // dump
+ Map<String, Dice> treasure = (Map<String, Dice>) new HashMap<String, Dice>();
+ treasure.put("treasure", new Dice(10, 20));
+ String output = yaml.dump(treasure);
+ assertEquals("{treasure: 10d20}\n", output);
+ // load
+ Object data = yaml.load("{damage: 5d10}");
+ Map<String, Dice> map = (Map<String, Dice>) data;
+ assertEquals(new Dice(5, 10), map.get("damage"));
+ }
+
+ // the tag may start with anything
+ @SuppressWarnings("unchecked")
+ public void testImplicitResolverWithNull() {
+ Yaml yaml = new Yaml(new DiceConstructor(), new DiceRepresenter());
+ // the tag may start with anything
+ yaml.addImplicitResolver(new Tag("!dice"), Pattern.compile("\\d+d\\d+"), null);
+ // dump
+ Map<String, Dice> treasure = (Map<String, Dice>) new HashMap<String, Dice>();
+ treasure.put("treasure", new Dice(10, 20));
+ String output = yaml.dump(treasure);
+ assertEquals("{treasure: 10d20}\n", output);
+ // load
+ Object data = yaml.load("{damage: 5d10}");
+ Map<String, Dice> map = (Map<String, Dice>) data;
+ assertEquals(new Dice(5, 10), map.get("damage"));
+ }
+}
diff --git a/src/test/java/examples/DumpExampleTest.java b/src/test/java/examples/DumpExampleTest.java
index 3841a53..c881b0b 100644
--- a/src/test/java/examples/DumpExampleTest.java
+++ b/src/test/java/examples/DumpExampleTest.java
@@ -1,136 +1,136 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-public class DumpExampleTest extends TestCase {
- public void testDump() {
- Map<String, Object> data = new HashMap<String, Object>();
- data.put("name", "Silenthand Olleander");
- data.put("race", "Human");
- data.put("traits", new String[] { "ONE_HAND", "ONE_EYE" });
- Yaml yaml = new Yaml();
- String output = yaml.dump(data);
- assertTrue(output.contains("name: Silenthand Olleander"));
- assertTrue(output.contains("race: Human"));
- assertTrue(output.contains("traits: [ONE_HAND, ONE_EYE]"));
- }
-
- public void testDumpWriter() {
- Map<String, Object> data = new HashMap<String, Object>();
- data.put("name", "Silenthand Olleander");
- data.put("race", "Human");
- data.put("traits", new String[] { "ONE_HAND", "ONE_EYE" });
- Yaml yaml = new Yaml();
- StringWriter writer = new StringWriter();
- yaml.dump(data, writer);
- assertTrue(writer.toString().contains("name: Silenthand Olleander"));
- assertTrue(writer.toString().contains("race: Human"));
- assertTrue(writer.toString().contains("traits: [ONE_HAND, ONE_EYE]"));
- }
-
- public void testDumpMany() {
- List<Integer> docs = new ArrayList<Integer>();
- for (int i = 1; i < 4; i++) {
- docs.add(i);
- }
- DumperOptions options = new DumperOptions();
- options.setExplicitStart(true);
- Yaml yaml = new Yaml(options);
- String result = yaml.dumpAll(docs.iterator());
- assertNotNull(result);
- assertTrue(result.contains("--- 2"));
- }
-
- public void testDumpCustomJavaClass() {
- Hero hero = new Hero("Galain Ysseleg", -3, 2);
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(hero);
- assertEquals("!!examples.Hero {hp: -3, name: Galain Ysseleg, sp: 2}\n", output);
- }
-
- public void testDumperOptions() {
- List<Integer> data = new ArrayList<Integer>();
- for (int i = 0; i < 50; i++) {
- data.add(i);
- }
- Yaml yaml = new Yaml();
- String output = yaml.dump(data);
- assertTrue(output.contains("[0, 1, 2, 3, 4, 5, 6, 7, 8"));
- //
- DumperOptions options = new DumperOptions();
- options.setWidth(50);
- options.setIndent(4);
- yaml = new Yaml(options);
- output = yaml.dump(data);
- assertTrue(output.contains("1, 2"));
- }
-
- public void testDumperOptionsCanonical() {
- List<Integer> data = new ArrayList<Integer>();
- for (int i = 0; i < 5; i++) {
- data.add(i);
- }
- DumperOptions options = new DumperOptions();
- options.setCanonical(true);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(data);
- assertTrue(output.contains("---"));
- assertTrue(output.contains("!!seq ["));
- assertTrue(output.contains("!!int \"3\","));
- }
-
- public void testDumperOptionsFlowStyle() {
- List<Integer> data = new ArrayList<Integer>();
- for (int i = 0; i < 5; i++) {
- data.add(i);
- }
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(data);
- assertTrue(output.contains("- 0\n"));
- assertTrue(output.contains("- 1\n"));
- assertTrue(output.contains("- 4\n"));
- }
-
- public void testDumperOptionsStyle() {
- List<Integer> data = new ArrayList<Integer>();
- for (int i = 0; i < 5; i++) {
- data.add(i);
- }
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(data);
- assertTrue(output.contains("- !!int \"0\""));
- assertTrue(output.contains("- !!int \"1\""));
- assertTrue(output.contains("- !!int \"4\""));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+public class DumpExampleTest extends TestCase {
+ public void testDump() {
+ Map<String, Object> data = new HashMap<String, Object>();
+ data.put("name", "Silenthand Olleander");
+ data.put("race", "Human");
+ data.put("traits", new String[] { "ONE_HAND", "ONE_EYE" });
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(data);
+ assertTrue(output.contains("name: Silenthand Olleander"));
+ assertTrue(output.contains("race: Human"));
+ assertTrue(output.contains("traits: [ONE_HAND, ONE_EYE]"));
+ }
+
+ public void testDumpWriter() {
+ Map<String, Object> data = new HashMap<String, Object>();
+ data.put("name", "Silenthand Olleander");
+ data.put("race", "Human");
+ data.put("traits", new String[] { "ONE_HAND", "ONE_EYE" });
+ Yaml yaml = new Yaml();
+ StringWriter writer = new StringWriter();
+ yaml.dump(data, writer);
+ assertTrue(writer.toString().contains("name: Silenthand Olleander"));
+ assertTrue(writer.toString().contains("race: Human"));
+ assertTrue(writer.toString().contains("traits: [ONE_HAND, ONE_EYE]"));
+ }
+
+ public void testDumpMany() {
+ List<Integer> docs = new ArrayList<Integer>();
+ for (int i = 1; i < 4; i++) {
+ docs.add(i);
+ }
+ DumperOptions options = new DumperOptions();
+ options.setExplicitStart(true);
+ Yaml yaml = new Yaml(options);
+ String result = yaml.dumpAll(docs.iterator());
+ assertNotNull(result);
+ assertTrue(result.contains("--- 2"));
+ }
+
+ public void testDumpCustomJavaClass() {
+ Hero hero = new Hero("Galain Ysseleg", -3, 2);
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(hero);
+ assertEquals("!!examples.Hero {hp: -3, name: Galain Ysseleg, sp: 2}\n", output);
+ }
+
+ public void testDumperOptions() {
+ List<Integer> data = new ArrayList<Integer>();
+ for (int i = 0; i < 50; i++) {
+ data.add(i);
+ }
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(data);
+ assertTrue(output.contains("[0, 1, 2, 3, 4, 5, 6, 7, 8"));
+ //
+ DumperOptions options = new DumperOptions();
+ options.setWidth(50);
+ options.setIndent(4);
+ yaml = new Yaml(options);
+ output = yaml.dump(data);
+ assertTrue(output.contains("1, 2"));
+ }
+
+ public void testDumperOptionsCanonical() {
+ List<Integer> data = new ArrayList<Integer>();
+ for (int i = 0; i < 5; i++) {
+ data.add(i);
+ }
+ DumperOptions options = new DumperOptions();
+ options.setCanonical(true);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(data);
+ assertTrue(output.contains("---"));
+ assertTrue(output.contains("!!seq ["));
+ assertTrue(output.contains("!!int \"3\","));
+ }
+
+ public void testDumperOptionsFlowStyle() {
+ List<Integer> data = new ArrayList<Integer>();
+ for (int i = 0; i < 5; i++) {
+ data.add(i);
+ }
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(data);
+ assertTrue(output.contains("- 0\n"));
+ assertTrue(output.contains("- 1\n"));
+ assertTrue(output.contains("- 4\n"));
+ }
+
+ public void testDumperOptionsStyle() {
+ List<Integer> data = new ArrayList<Integer>();
+ for (int i = 0; i < 5; i++) {
+ data.add(i);
+ }
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(data);
+ assertTrue(output.contains("- !!int \"0\""));
+ assertTrue(output.contains("- !!int \"1\""));
+ assertTrue(output.contains("- !!int \"4\""));
+ }
+}
diff --git a/src/test/java/examples/Hero.java b/src/test/java/examples/Hero.java
index 90fefed..f299988 100644
--- a/src/test/java/examples/Hero.java
+++ b/src/test/java/examples/Hero.java
@@ -1,43 +1,43 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-public class Hero {
- private String name;
- private Integer sp;
- private Integer hp;
-
- public Hero(String name, Integer hp, Integer sp) {
- super();
- this.name = name;
- this.sp = sp;
- this.hp = hp;
- }
-
- public String getName() {
- return name;
- }
-
- public Integer getSp() {
- return sp;
- }
-
- public Integer getHp() {
- return hp;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+public class Hero {
+ private String name;
+ private Integer sp;
+ private Integer hp;
+
+ public Hero(String name, Integer hp, Integer sp) {
+ super();
+ this.name = name;
+ this.sp = sp;
+ this.hp = hp;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Integer getSp() {
+ return sp;
+ }
+
+ public Integer getHp() {
+ return hp;
+ }
+
+}
diff --git a/src/test/java/examples/IgnoreTagsExampleTest.java b/src/test/java/examples/IgnoreTagsExampleTest.java
index 113241e..5a250a9 100644
--- a/src/test/java/examples/IgnoreTagsExampleTest.java
+++ b/src/test/java/examples/IgnoreTagsExampleTest.java
@@ -1,83 +1,83 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Construct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class IgnoreTagsExampleTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testLoad() {
- String input = Util.getLocalResource("examples/unknown-tags-example.yaml");
- // System.out.println(input);
- Yaml yaml = new Yaml(new MyConstructor());
- Map<String, Object> result = (Map<String, Object>) yaml.load(input);
- // Check the result
- assertNotNull(result);
- assertEquals(3, result.size());
- assertEquals("123", result.get("aaa"));
- //
- List<Object> bbb = (List<Object>) result.get("bbb");
- assertEquals(2, bbb.size());
- assertEquals(new Integer(111), bbb.get(0));
- assertEquals("ddd", bbb.get(1));
- //
- Map<String, Object> ccc = (Map<String, Object>) result.get("ccc");
- assertEquals(2, ccc.size());
- assertEquals(1.0, ccc.get("x"));
- assertEquals(3.1416, ccc.get("y"));
- }
-
- private class MyConstructor extends Constructor {
- private Construct original;
-
- public MyConstructor() {
- original = this.yamlConstructors.get(null);
- this.yamlConstructors.put(null, new IgnoringConstruct());
- }
-
- private class IgnoringConstruct extends AbstractConstruct {
- public Object construct(Node node) {
- if (node.getTag().startsWith("!KnownTag")) {
- return original.construct(node);
- } else {
- switch (node.getNodeId()) {
- case scalar:
- return yamlConstructors.get(Tag.STR).construct(node);
- case sequence:
- return yamlConstructors.get(Tag.SEQ).construct(node);
- case mapping:
- return yamlConstructors.get(Tag.MAP).construct(node);
- default:
- throw new YAMLException("Unexpected node");
- }
- }
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Construct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class IgnoreTagsExampleTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testLoad() {
+ String input = Util.getLocalResource("examples/unknown-tags-example.yaml");
+ // System.out.println(input);
+ Yaml yaml = new Yaml(new MyConstructor());
+ Map<String, Object> result = (Map<String, Object>) yaml.load(input);
+ // Check the result
+ assertNotNull(result);
+ assertEquals(3, result.size());
+ assertEquals("123", result.get("aaa"));
+ //
+ List<Object> bbb = (List<Object>) result.get("bbb");
+ assertEquals(2, bbb.size());
+ assertEquals(new Integer(111), bbb.get(0));
+ assertEquals("ddd", bbb.get(1));
+ //
+ Map<String, Object> ccc = (Map<String, Object>) result.get("ccc");
+ assertEquals(2, ccc.size());
+ assertEquals(1.0, ccc.get("x"));
+ assertEquals(3.1416, ccc.get("y"));
+ }
+
+ private class MyConstructor extends Constructor {
+ private Construct original;
+
+ public MyConstructor() {
+ original = this.yamlConstructors.get(null);
+ this.yamlConstructors.put(null, new IgnoringConstruct());
+ }
+
+ private class IgnoringConstruct extends AbstractConstruct {
+ public Object construct(Node node) {
+ if (node.getTag().startsWith("!KnownTag")) {
+ return original.construct(node);
+ } else {
+ switch (node.getNodeId()) {
+ case scalar:
+ return yamlConstructors.get(Tag.STR).construct(node);
+ case sequence:
+ return yamlConstructors.get(Tag.SEQ).construct(node);
+ case mapping:
+ return yamlConstructors.get(Tag.MAP).construct(node);
+ default:
+ throw new YAMLException("Unexpected node");
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/src/test/java/examples/LoadExampleTest.java b/src/test/java/examples/LoadExampleTest.java
index 948f608..89348d0 100644
--- a/src/test/java/examples/LoadExampleTest.java
+++ b/src/test/java/examples/LoadExampleTest.java
@@ -1,73 +1,73 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class LoadExampleTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testLoad() {
- Yaml yaml = new Yaml();
- String document = "\n- Hesperiidae\n- Papilionidae\n- Apatelodidae\n- Epiplemidae";
- List<String> list = (List<String>) yaml.load(document);
- assertEquals("[Hesperiidae, Papilionidae, Apatelodidae, Epiplemidae]", list.toString());
- }
-
- public void testLoadFromString() {
- Yaml yaml = new Yaml();
- String document = "hello: 25";
- @SuppressWarnings("unchecked")
- Map<String, Integer> map = (Map<String, Integer>) yaml.load(document);
- assertEquals("{hello=25}", map.toString());
- assertEquals(new Integer(25), map.get("hello"));
- }
-
- public void testLoadFromStream() throws IOException {
- InputStream input = new FileInputStream(new File("src/test/resources/reader/utf-8.txt"));
- Yaml yaml = new Yaml();
- Object data = yaml.load(input);
- assertEquals("test", data);
- //
- data = yaml.load(new ByteArrayInputStream("test2".getBytes()));
- assertEquals("test2", data);
- input.close();
- }
-
- public void testLoadManyDocuments() throws IOException {
- InputStream input = new FileInputStream(new File(
- "src/test/resources/specification/example2_28.yaml"));
- Yaml yaml = new Yaml();
- int counter = 0;
- for (Object data : yaml.loadAll(input)) {
- assertNotNull(data);
- assertTrue(data.toString().length() > 1);
- counter++;
- }
- assertEquals(3, counter);
- input.close();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class LoadExampleTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testLoad() {
+ Yaml yaml = new Yaml();
+ String document = "\n- Hesperiidae\n- Papilionidae\n- Apatelodidae\n- Epiplemidae";
+ List<String> list = (List<String>) yaml.load(document);
+ assertEquals("[Hesperiidae, Papilionidae, Apatelodidae, Epiplemidae]", list.toString());
+ }
+
+ public void testLoadFromString() {
+ Yaml yaml = new Yaml();
+ String document = "hello: 25";
+ @SuppressWarnings("unchecked")
+ Map<String, Integer> map = (Map<String, Integer>) yaml.load(document);
+ assertEquals("{hello=25}", map.toString());
+ assertEquals(new Integer(25), map.get("hello"));
+ }
+
+ public void testLoadFromStream() throws IOException {
+ InputStream input = new FileInputStream(new File("src/test/resources/reader/utf-8.txt"));
+ Yaml yaml = new Yaml();
+ Object data = yaml.load(input);
+ assertEquals("test", data);
+ //
+ data = yaml.load(new ByteArrayInputStream("test2".getBytes()));
+ assertEquals("test2", data);
+ input.close();
+ }
+
+ public void testLoadManyDocuments() throws IOException {
+ InputStream input = new FileInputStream(new File(
+ "src/test/resources/specification/example2_28.yaml"));
+ Yaml yaml = new Yaml();
+ int counter = 0;
+ for (Object data : yaml.loadAll(input)) {
+ assertNotNull(data);
+ assertTrue(data.toString().length() > 1);
+ counter++;
+ }
+ assertEquals(3, counter);
+ input.close();
+ }
+}
diff --git a/src/test/java/examples/SafeConstructorExampleTest.java b/src/test/java/examples/SafeConstructorExampleTest.java
index 384b669..99ec7ce 100644
--- a/src/test/java/examples/SafeConstructorExampleTest.java
+++ b/src/test/java/examples/SafeConstructorExampleTest.java
@@ -1,50 +1,50 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-
-public class SafeConstructorExampleTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testConstruct() {
- String doc = "- 5\n- Person\n- true";
- Yaml yaml = new Yaml(new SafeConstructor());
- List<Object> list = (List<Object>) yaml.load(doc);
- assertEquals(3, list.size());
- assertEquals(new Integer(5), list.get(0));
- assertEquals("Person", list.get(1));
- assertEquals(Boolean.TRUE, list.get(2));
- }
-
- public void testSafeConstruct() {
- String doc = "- 5\n- !org.yaml.snakeyaml.constructor.Person\n firstName: Andrey\n age: 99\n- true";
- Yaml yaml = new Yaml(new SafeConstructor());
- try {
- yaml.load(doc);
- fail("Custom Java classes should not be created.");
- } catch (Exception e) {
- assertEquals(
- "null; could not determine a constructor for the tag !org.yaml.snakeyaml.constructor.Person",
- e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
+
+public class SafeConstructorExampleTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testConstruct() {
+ String doc = "- 5\n- Person\n- true";
+ Yaml yaml = new Yaml(new SafeConstructor());
+ List<Object> list = (List<Object>) yaml.load(doc);
+ assertEquals(3, list.size());
+ assertEquals(new Integer(5), list.get(0));
+ assertEquals("Person", list.get(1));
+ assertEquals(Boolean.TRUE, list.get(2));
+ }
+
+ public void testSafeConstruct() {
+ String doc = "- 5\n- !org.yaml.snakeyaml.constructor.Person\n firstName: Andrey\n age: 99\n- true";
+ Yaml yaml = new Yaml(new SafeConstructor());
+ try {
+ yaml.load(doc);
+ fail("Custom Java classes should not be created.");
+ } catch (Exception e) {
+ assertEquals(
+ "null; could not determine a constructor for the tag !org.yaml.snakeyaml.constructor.Person",
+ e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/examples/SelectiveConstructorTest.java b/src/test/java/examples/SelectiveConstructorTest.java
index f71e193..e1ff1dd 100644
--- a/src/test/java/examples/SelectiveConstructorTest.java
+++ b/src/test/java/examples/SelectiveConstructorTest.java
@@ -1,102 +1,102 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.NodeId;
-
-/**
- * Example for http://code.google.com/p/snakeyaml/wiki/howto
- */
-public class SelectiveConstructorTest extends TestCase {
- class SelectiveConstructor extends Constructor {
- public SelectiveConstructor() {
- // define a custom way to create a mapping node
- yamlClassConstructors.put(NodeId.mapping, new MyPersistentObjectConstruct());
- }
-
- class MyPersistentObjectConstruct extends Constructor.ConstructMapping {
- @Override
- protected Object constructJavaBean2ndStep(MappingNode node, Object object) {
- Class<?> type = node.getType();
- if (type.equals(MyPersistentObject.class)) {
- // create a map
- Map<Object, Object> map = constructMapping(node);
- String id = (String) map.get("id");
- return new MyPersistentObject(id, 17);
- } else {
- // create JavaBean
- return super.constructJavaBean2ndStep(node, object);
- }
- }
- }
- }
-
- public void testConstructor() {
- Yaml yaml = new Yaml(new SelectiveConstructor());
- List<?> data = (List<?>) yaml
- .load("- 1\n- 2\n- !!examples.MyPersistentObject {amount: 222, id: persistent}");
- // System.out.println(data);
- assertEquals(3, data.size());
- MyPersistentObject myObject = (MyPersistentObject) data.get(2);
- assertEquals(17, myObject.getAmount());
- assertEquals("persistent", myObject.getId());
- }
-}
-
-class MyPersistentObject {
- private String id;
- private int amount;
-
- public MyPersistentObject() {
- this.id = "noid";
- this.amount = 222;
- }
-
- public MyPersistentObject(String id, int amount) {
- this.id = id;
- this.amount = amount;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public int getAmount() {
- return amount;
- }
-
- public void setAmount(int amount) {
- this.amount = amount;
- }
-
- @Override
- public String toString() {
- return "MyPersistentObject [id=" + id + ", amount=" + amount + "]";
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.NodeId;
+
+/**
+ * Example for http://code.google.com/p/snakeyaml/wiki/howto
+ */
+public class SelectiveConstructorTest extends TestCase {
+ class SelectiveConstructor extends Constructor {
+ public SelectiveConstructor() {
+ // define a custom way to create a mapping node
+ yamlClassConstructors.put(NodeId.mapping, new MyPersistentObjectConstruct());
+ }
+
+ class MyPersistentObjectConstruct extends Constructor.ConstructMapping {
+ @Override
+ protected Object constructJavaBean2ndStep(MappingNode node, Object object) {
+ Class<?> type = node.getType();
+ if (type.equals(MyPersistentObject.class)) {
+ // create a map
+ Map<Object, Object> map = constructMapping(node);
+ String id = (String) map.get("id");
+ return new MyPersistentObject(id, 17);
+ } else {
+ // create JavaBean
+ return super.constructJavaBean2ndStep(node, object);
+ }
+ }
+ }
+ }
+
+ public void testConstructor() {
+ Yaml yaml = new Yaml(new SelectiveConstructor());
+ List<?> data = (List<?>) yaml
+ .load("- 1\n- 2\n- !!examples.MyPersistentObject {amount: 222, id: persistent}");
+ // System.out.println(data);
+ assertEquals(3, data.size());
+ MyPersistentObject myObject = (MyPersistentObject) data.get(2);
+ assertEquals(17, myObject.getAmount());
+ assertEquals("persistent", myObject.getId());
+ }
+}
+
+class MyPersistentObject {
+ private String id;
+ private int amount;
+
+ public MyPersistentObject() {
+ this.id = "noid";
+ this.amount = 222;
+ }
+
+ public MyPersistentObject(String id, int amount) {
+ this.id = id;
+ this.amount = amount;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int getAmount() {
+ return amount;
+ }
+
+ public void setAmount(int amount) {
+ this.amount = amount;
+ }
+
+ @Override
+ public String toString() {
+ return "MyPersistentObject [id=" + id + ", amount=" + amount + "]";
+ }
+}
diff --git a/src/test/java/examples/SpringTest.java b/src/test/java/examples/SpringTest.java
index 84d5ada..5849130 100644
--- a/src/test/java/examples/SpringTest.java
+++ b/src/test/java/examples/SpringTest.java
@@ -1,37 +1,37 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples;
-
-import junit.framework.TestCase;
-
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-import org.yaml.snakeyaml.Yaml;
-
-public class SpringTest extends TestCase {
- public void testSimple() {
- ApplicationContext context = new ClassPathXmlApplicationContext("examples/spring.xml");
- Yaml yaml = (Yaml) context.getBean("standardYaml");
- assertNotNull(yaml);
- //
- yaml = (Yaml) context.getBean("javabeanYaml");
- assertNotNull(yaml);
- //
- yaml = (Yaml) context.getBean("snakeYaml");
- assertNotNull(yaml);
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples;
+
+import junit.framework.TestCase;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.yaml.snakeyaml.Yaml;
+
+public class SpringTest extends TestCase {
+ public void testSimple() {
+ ApplicationContext context = new ClassPathXmlApplicationContext("examples/spring.xml");
+ Yaml yaml = (Yaml) context.getBean("standardYaml");
+ assertNotNull(yaml);
+ //
+ yaml = (Yaml) context.getBean("javabeanYaml");
+ assertNotNull(yaml);
+ //
+ yaml = (Yaml) context.getBean("snakeYaml");
+ assertNotNull(yaml);
+ }
}
\ No newline at end of file
diff --git a/src/test/java/examples/collections/ListFileldBeanTest.java b/src/test/java/examples/collections/ListFileldBeanTest.java
index c08e854..8db7dc4 100644
--- a/src/test/java/examples/collections/ListFileldBeanTest.java
+++ b/src/test/java/examples/collections/ListFileldBeanTest.java
@@ -1,122 +1,122 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test public field ListBean->List<Developer> developers <br/>
- * Developer class must be properly recognised
- */
-public class ListFileldBeanTest extends TestCase {
- public void testDumpList() {
- ListFieldBean bean = new ListFieldBean();
- List<String> list = new ArrayList<String>();
- list.add("aaa");
- list.add("bbb");
- bean.setChildren(list);
- List<Developer> developers = new ArrayList<Developer>();
- developers.add(new Developer("Fred", "creator"));
- developers.add(new Developer("John", "committer"));
- bean.developers = developers;
- bean.setName("Bean123");
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/list-bean-1.yaml");
- assertEquals(etalon, output);
- }
-
- public void testLoadList() {
- String output = Util.getLocalResource("examples/list-bean-1.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- ListFieldBean parsed = beanLoader.loadAs(output, ListFieldBean.class);
- assertNotNull(parsed);
- List<String> list2 = parsed.getChildren();
- assertEquals(2, list2.size());
- assertEquals("aaa", list2.get(0));
- assertEquals("bbb", list2.get(1));
- List<Developer> developers = parsed.developers;
- assertEquals(2, developers.size());
- assertEquals("Developer must be recognised.", Developer.class, developers.get(0).getClass());
- Developer fred = developers.get(0);
- assertEquals("Fred", fred.getName());
- assertEquals("creator", fred.getRole());
- }
-
- public static class ListFieldBean {
- private List<String> children;
- private String name;
- public List<Developer> developers;
-
- public ListFieldBean() {
- name = "Bean456";
- }
-
- public List<String> getChildren() {
- return children;
- }
-
- public void setChildren(List<String> children) {
- this.children = children;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- public static class Developer {
- private String name;
- private String role;
-
- public Developer() {
- }
-
- public Developer(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test public field ListBean->List<Developer> developers <br/>
+ * Developer class must be properly recognised
+ */
+public class ListFileldBeanTest extends TestCase {
+ public void testDumpList() {
+ ListFieldBean bean = new ListFieldBean();
+ List<String> list = new ArrayList<String>();
+ list.add("aaa");
+ list.add("bbb");
+ bean.setChildren(list);
+ List<Developer> developers = new ArrayList<Developer>();
+ developers.add(new Developer("Fred", "creator"));
+ developers.add(new Developer("John", "committer"));
+ bean.developers = developers;
+ bean.setName("Bean123");
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/list-bean-1.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testLoadList() {
+ String output = Util.getLocalResource("examples/list-bean-1.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ ListFieldBean parsed = beanLoader.loadAs(output, ListFieldBean.class);
+ assertNotNull(parsed);
+ List<String> list2 = parsed.getChildren();
+ assertEquals(2, list2.size());
+ assertEquals("aaa", list2.get(0));
+ assertEquals("bbb", list2.get(1));
+ List<Developer> developers = parsed.developers;
+ assertEquals(2, developers.size());
+ assertEquals("Developer must be recognised.", Developer.class, developers.get(0).getClass());
+ Developer fred = developers.get(0);
+ assertEquals("Fred", fred.getName());
+ assertEquals("creator", fred.getRole());
+ }
+
+ public static class ListFieldBean {
+ private List<String> children;
+ private String name;
+ public List<Developer> developers;
+
+ public ListFieldBean() {
+ name = "Bean456";
+ }
+
+ public List<String> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<String> children) {
+ this.children = children;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ public static class Developer {
+ private String name;
+ private String role;
+
+ public Developer() {
+ }
+
+ public Developer(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+ }
+}
diff --git a/src/test/java/examples/collections/TypeSafeListNoGerericsTest.java b/src/test/java/examples/collections/TypeSafeListNoGerericsTest.java
index 0d6812b..25fa397 100644
--- a/src/test/java/examples/collections/TypeSafeListNoGerericsTest.java
+++ b/src/test/java/examples/collections/TypeSafeListNoGerericsTest.java
@@ -1,131 +1,131 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test ListBean->List developers <br/>
- * Developer class cannot be properly recognised
- */
-public class TypeSafeListNoGerericsTest extends TestCase {
- public void testDumpList() {
- ListBean bean = new ListBean();
- List<String> list = new ArrayList<String>();
- list.add("aaa");
- list.add("bbb");
- bean.setChildren(list);
- List<Developer> developers = new ArrayList<Developer>();
- developers.add(new Developer("Fred", "creator"));
- developers.add(new Developer("John", "committer"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/list-bean-4.yaml");
- assertEquals(etalon, output);
- }
-
- @SuppressWarnings("unchecked")
- public void testLoadList() {
- String output = Util.getLocalResource("examples/list-bean-1.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- ListBean parsed = beanLoader.loadAs(output, ListBean.class);
- assertNotNull(parsed);
- List<String> list2 = parsed.getChildren();
- assertEquals(2, list2.size());
- assertEquals("aaa", list2.get(0));
- assertEquals("bbb", list2.get(1));
- List<Map<String, String>> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- Map<String, String> fred = developers.get(0);
- assertEquals("Fred", fred.get("name"));
- assertEquals("creator", fred.get("role"));
- }
-
- @SuppressWarnings("rawtypes")
- public static class ListBean {
- private List<String> children;
- private String name;
- private List developers;
-
- public ListBean() {
- name = "Bean123";
- }
-
- public List<String> getChildren() {
- return children;
- }
-
- public void setChildren(List<String> children) {
- this.children = children;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(List developers) {
- this.developers = developers;
- }
- }
-
- public static class Developer {
- private String name;
- private String role;
-
- public Developer() {
- }
-
- public Developer(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test ListBean->List developers <br/>
+ * Developer class cannot be properly recognised
+ */
+public class TypeSafeListNoGerericsTest extends TestCase {
+ public void testDumpList() {
+ ListBean bean = new ListBean();
+ List<String> list = new ArrayList<String>();
+ list.add("aaa");
+ list.add("bbb");
+ bean.setChildren(list);
+ List<Developer> developers = new ArrayList<Developer>();
+ developers.add(new Developer("Fred", "creator"));
+ developers.add(new Developer("John", "committer"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/list-bean-4.yaml");
+ assertEquals(etalon, output);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testLoadList() {
+ String output = Util.getLocalResource("examples/list-bean-1.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ ListBean parsed = beanLoader.loadAs(output, ListBean.class);
+ assertNotNull(parsed);
+ List<String> list2 = parsed.getChildren();
+ assertEquals(2, list2.size());
+ assertEquals("aaa", list2.get(0));
+ assertEquals("bbb", list2.get(1));
+ List<Map<String, String>> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ Map<String, String> fred = developers.get(0);
+ assertEquals("Fred", fred.get("name"));
+ assertEquals("creator", fred.get("role"));
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static class ListBean {
+ private List<String> children;
+ private String name;
+ private List developers;
+
+ public ListBean() {
+ name = "Bean123";
+ }
+
+ public List<String> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<String> children) {
+ this.children = children;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(List developers) {
+ this.developers = developers;
+ }
+ }
+
+ public static class Developer {
+ private String name;
+ private String role;
+
+ public Developer() {
+ }
+
+ public Developer(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+ }
+}
diff --git a/src/test/java/examples/collections/TypeSafeListTest.java b/src/test/java/examples/collections/TypeSafeListTest.java
index 3092b30..9578d76 100644
--- a/src/test/java/examples/collections/TypeSafeListTest.java
+++ b/src/test/java/examples/collections/TypeSafeListTest.java
@@ -1,129 +1,129 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test ListBean->List<Developer> developers <br/>
- * Developer class must be properly recognised
- */
-public class TypeSafeListTest extends TestCase {
- public void testDumpList() {
- ListBean1 bean = new ListBean1();
- List<String> list = new ArrayList<String>();
- list.add("aaa");
- list.add("bbb");
- bean.setChildren(list);
- List<Developer> developers = new ArrayList<Developer>();
- developers.add(new Developer("Fred", "creator"));
- developers.add(new Developer("John", "committer"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/list-bean-1.yaml");
- assertEquals(etalon, output);
- }
-
- public void testLoadList() {
- String output = Util.getLocalResource("examples/list-bean-1.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- ListBean1 parsed = beanLoader.loadAs(output, ListBean1.class);
- assertNotNull(parsed);
- List<String> list2 = parsed.getChildren();
- assertEquals(2, list2.size());
- assertEquals("aaa", list2.get(0));
- assertEquals("bbb", list2.get(1));
- List<Developer> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- assertEquals("Developer must be recognised.", Developer.class, developers.get(0).getClass());
- Developer fred = developers.get(0);
- assertEquals("Fred", fred.getName());
- assertEquals("creator", fred.getRole());
- }
-
- public static class ListBean1 {
- private List<String> children;
- private String name;
- private List<Developer> developers;
-
- public ListBean1() {
- name = "Bean123";
- }
-
- public List<String> getChildren() {
- return children;
- }
-
- public void setChildren(List<String> children) {
- this.children = children;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<Developer> getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(List<Developer> developers) {
- this.developers = developers;
- }
- }
-
- public static class Developer {
- private String name;
- private String role;
-
- public Developer() {
- }
-
- public Developer(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test ListBean->List<Developer> developers <br/>
+ * Developer class must be properly recognised
+ */
+public class TypeSafeListTest extends TestCase {
+ public void testDumpList() {
+ ListBean1 bean = new ListBean1();
+ List<String> list = new ArrayList<String>();
+ list.add("aaa");
+ list.add("bbb");
+ bean.setChildren(list);
+ List<Developer> developers = new ArrayList<Developer>();
+ developers.add(new Developer("Fred", "creator"));
+ developers.add(new Developer("John", "committer"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/list-bean-1.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testLoadList() {
+ String output = Util.getLocalResource("examples/list-bean-1.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ ListBean1 parsed = beanLoader.loadAs(output, ListBean1.class);
+ assertNotNull(parsed);
+ List<String> list2 = parsed.getChildren();
+ assertEquals(2, list2.size());
+ assertEquals("aaa", list2.get(0));
+ assertEquals("bbb", list2.get(1));
+ List<Developer> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ assertEquals("Developer must be recognised.", Developer.class, developers.get(0).getClass());
+ Developer fred = developers.get(0);
+ assertEquals("Fred", fred.getName());
+ assertEquals("creator", fred.getRole());
+ }
+
+ public static class ListBean1 {
+ private List<String> children;
+ private String name;
+ private List<Developer> developers;
+
+ public ListBean1() {
+ name = "Bean123";
+ }
+
+ public List<String> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<String> children) {
+ this.children = children;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Developer> getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(List<Developer> developers) {
+ this.developers = developers;
+ }
+ }
+
+ public static class Developer {
+ private String name;
+ private String role;
+
+ public Developer() {
+ }
+
+ public Developer(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+ }
+}
diff --git a/src/test/java/examples/collections/TypeSafeListWithInterfaceTest.java b/src/test/java/examples/collections/TypeSafeListWithInterfaceTest.java
index c43d0de..b883784 100644
--- a/src/test/java/examples/collections/TypeSafeListWithInterfaceTest.java
+++ b/src/test/java/examples/collections/TypeSafeListWithInterfaceTest.java
@@ -1,173 +1,173 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test ListBean->List<Human> developers <br/>
- * Human is an interface and the global tags are required
- */
-public class TypeSafeListWithInterfaceTest extends TestCase {
- public void testDumpList() {
- ListBean bean = new ListBean();
- List<String> list = new ArrayList<String>();
- list.add("aaa");
- list.add("bbb");
- bean.setChildren(list);
- List<Human> developers = new ArrayList<Human>();
- developers.add(new Developer("Fred", "creator"));
- developers.add(new Committer("John", "committer", 34));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/list-bean-2.yaml");
- assertEquals(etalon, output);
- }
-
- public void testLoadWrongList() {
- String output = Util.getLocalResource("examples/list-bean-1.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- try {
- beanLoader.loadAs(output, ListBean.class);
- fail("Global tags are required since Human is an interface.");
- } catch (Exception e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Cannot create property=developers"));
- }
- }
-
- public void testLoadList() {
- String output = Util.getLocalResource("examples/list-bean-2.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- ListBean parsed = beanLoader.loadAs(output, ListBean.class);
- assertNotNull(parsed);
- List<String> list2 = parsed.getChildren();
- assertEquals(2, list2.size());
- assertEquals("aaa", list2.get(0));
- assertEquals("bbb", list2.get(1));
- List<Human> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- assertEquals("Developer must be recognised.", Developer.class, developers.get(0).getClass());
- Developer fred = (Developer) developers.get(0);
- assertEquals("Fred", fred.getName());
- assertEquals("creator", fred.getRole());
- Committer john = (Committer) developers.get(1);
- assertEquals("John", john.getName());
- assertEquals("committer", john.getRole());
- assertEquals(34, john.getKey());
- }
-
- public static class ListBean {
- private List<String> children;
- private String name;
- private List<Human> developers;
-
- public ListBean() {
- name = "Bean123";
- }
-
- public List<String> getChildren() {
- return children;
- }
-
- public void setChildren(List<String> children) {
- this.children = children;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<Human> getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(List<Human> developers) {
- this.developers = developers;
- }
- }
-
- public static interface Human {
-
- public String getName();
-
- public void setName(String name);
-
- }
-
- public static class Developer implements Human {
- private String name;
- private String role;
-
- public Developer() {
- }
-
- public Developer(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
- }
-
- public static class Committer extends Developer {
- private int key;
-
- public Committer() {
- }
-
- public Committer(String string, String string2, int i) {
- super(string, string2);
- this.key = i;
- }
-
- public int getKey() {
- return key;
- }
-
- public void setKey(int key) {
- this.key = key;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test ListBean->List<Human> developers <br/>
+ * Human is an interface and the global tags are required
+ */
+public class TypeSafeListWithInterfaceTest extends TestCase {
+ public void testDumpList() {
+ ListBean bean = new ListBean();
+ List<String> list = new ArrayList<String>();
+ list.add("aaa");
+ list.add("bbb");
+ bean.setChildren(list);
+ List<Human> developers = new ArrayList<Human>();
+ developers.add(new Developer("Fred", "creator"));
+ developers.add(new Committer("John", "committer", 34));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/list-bean-2.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testLoadWrongList() {
+ String output = Util.getLocalResource("examples/list-bean-1.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ try {
+ beanLoader.loadAs(output, ListBean.class);
+ fail("Global tags are required since Human is an interface.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("Cannot create property=developers"));
+ }
+ }
+
+ public void testLoadList() {
+ String output = Util.getLocalResource("examples/list-bean-2.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ ListBean parsed = beanLoader.loadAs(output, ListBean.class);
+ assertNotNull(parsed);
+ List<String> list2 = parsed.getChildren();
+ assertEquals(2, list2.size());
+ assertEquals("aaa", list2.get(0));
+ assertEquals("bbb", list2.get(1));
+ List<Human> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ assertEquals("Developer must be recognised.", Developer.class, developers.get(0).getClass());
+ Developer fred = (Developer) developers.get(0);
+ assertEquals("Fred", fred.getName());
+ assertEquals("creator", fred.getRole());
+ Committer john = (Committer) developers.get(1);
+ assertEquals("John", john.getName());
+ assertEquals("committer", john.getRole());
+ assertEquals(34, john.getKey());
+ }
+
+ public static class ListBean {
+ private List<String> children;
+ private String name;
+ private List<Human> developers;
+
+ public ListBean() {
+ name = "Bean123";
+ }
+
+ public List<String> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<String> children) {
+ this.children = children;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Human> getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(List<Human> developers) {
+ this.developers = developers;
+ }
+ }
+
+ public static interface Human {
+
+ public String getName();
+
+ public void setName(String name);
+
+ }
+
+ public static class Developer implements Human {
+ private String name;
+ private String role;
+
+ public Developer() {
+ }
+
+ public Developer(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+ }
+
+ public static class Committer extends Developer {
+ private int key;
+
+ public Committer() {
+ }
+
+ public Committer(String string, String string2, int i) {
+ super(string, string2);
+ this.key = i;
+ }
+
+ public int getKey() {
+ return key;
+ }
+
+ public void setKey(int key) {
+ this.key = key;
+ }
+ }
+}
diff --git a/src/test/java/examples/collections/TypeSafeMap2Test.java b/src/test/java/examples/collections/TypeSafeMap2Test.java
index 9e50b7a..1ed7c22 100644
--- a/src/test/java/examples/collections/TypeSafeMap2Test.java
+++ b/src/test/java/examples/collections/TypeSafeMap2Test.java
@@ -1,231 +1,231 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test MapBean->Map<Enum, Developer> developers <br/>
- * Developer class must be properly recognised
- */
-public class TypeSafeMap2Test extends TestCase {
- public void testDumpMap() {
- MapBean2 bean = new MapBean2();
- Map<Developer2, Color> data = new LinkedHashMap<Developer2, Color>();
- data.put(new Developer2("Andy", "tester"), Color.BLACK);
- data.put(new Developer2("Lisa", "owner"), Color.RED);
- bean.setData(data);
- Map<Color, Developer2> developers = new LinkedHashMap<Color, Developer2>();
- developers.put(Color.WHITE, new Developer2("Fred", "creator"));
- developers.put(Color.BLACK, new Developer2("John", "committer"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-bean-12.yaml");
- assertEquals(etalon, output);
- }
-
- public void testMap2() {
- MapBean2 bean = new MapBean2();
- Map<Developer2, Color> data = new LinkedHashMap<Developer2, Color>();
- data.put(new Developer2("Andy", "tester"), Color.BLACK);
- data.put(new SuperMan("Bill", "cleaner", false), Color.BLACK);
- data.put(new Developer2("Lisa", "owner"), Color.RED);
- bean.setData(data);
- Map<Color, Developer2> developers = new LinkedHashMap<Color, Developer2>();
- developers.put(Color.WHITE, new Developer2("Fred", "creator"));
- developers.put(Color.RED, new SuperMan("Jason", "contributor", true));
- developers.put(Color.BLACK, new Developer2("John", "committer"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-bean-13.yaml");
- assertEquals(etalon, output);
- // load
- Yaml beanLoader = new Yaml();
- MapBean2 parsed = beanLoader.loadAs(etalon, MapBean2.class);
- assertNotNull(parsed);
- Map<Developer2, Color> parsedData = parsed.getData();
- assertEquals(3, parsedData.size());
- assertTrue(parsedData.containsKey(new SuperMan("Bill", "cleaner", false)));
- assertEquals(Color.BLACK, parsedData.get(new SuperMan("Bill", "cleaner", false)));
- //
- Map<Color, Developer2> parsedDevelopers = parsed.getDevelopers();
- assertEquals(3, parsedDevelopers.size());
- assertEquals(new SuperMan("Jason", "contributor", true), parsedDevelopers.get(Color.RED));
- }
-
- public void testLoadMap() {
- String output = Util.getLocalResource("examples/map-bean-12.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- MapBean2 parsed = beanLoader.loadAs(output, MapBean2.class);
- assertNotNull(parsed);
- Map<Developer2, Color> data = parsed.getData();
- assertEquals(2, data.size());
- Iterator<Developer2> iter = data.keySet().iterator();
- Developer2 first = iter.next();
- assertEquals("Andy", first.getName());
- assertEquals("tester", first.getRole());
- assertEquals(Color.BLACK, data.get(first));
- Developer2 second = iter.next();
- assertEquals("Lisa", second.getName());
- assertEquals("owner", second.getRole());
- assertEquals(Color.RED, data.get(second));
- //
- Map<Color, Developer2> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- Iterator<Color> iter2 = developers.keySet().iterator();
- Color firstColor = iter2.next();
- assertEquals(Color.WHITE, firstColor);
- Developer2 dev1 = developers.get(firstColor);
- assertEquals("Fred", dev1.getName());
- assertEquals("creator", dev1.getRole());
- Color secondColor = iter2.next();
- assertEquals(Color.BLACK, secondColor);
- Developer2 dev2 = developers.get(secondColor);
- assertEquals("John", dev2.getName());
- assertEquals("committer", dev2.getRole());
- }
-
- public static enum Color {
- WHITE, BLACK, RED;
- }
-
- public static class MapBean2 {
- private Map<Developer2, Color> data;
- private String name;
- private Map<Color, Developer2> developers;
-
- public MapBean2() {
- name = "Bean123";
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Map<Color, Developer2> getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(Map<Color, Developer2> developers) {
- this.developers = developers;
- }
-
- public Map<Developer2, Color> getData() {
- return data;
- }
-
- public void setData(Map<Developer2, Color> data) {
- this.data = data;
- }
-
- }
-
- public static class Developer2 implements Comparable<Developer2> {
- private String name;
- private String role;
-
- public Developer2() {
- }
-
- private Developer2(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public int compareTo(Developer2 o) {
- return name.compareTo(o.name);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Developer2) {
- return toString().equals(obj.toString());
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return toString().hashCode();
- }
-
- @Override
- public String toString() {
- return "Developer " + name + " " + role;
- }
-
- }
-
- public static class SuperMan extends Developer2 {
- private boolean smart;
-
- public SuperMan() {
- super();
- }
-
- private SuperMan(String name, String role, boolean smart) {
- super(name, role);
- this.smart = smart;
- }
-
- public boolean isSmart() {
- return smart;
- }
-
- public void setSmart(boolean smart) {
- this.smart = smart;
- }
-
- @Override
- public String toString() {
- return "Super" + super.toString();
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test MapBean->Map<Enum, Developer> developers <br/>
+ * Developer class must be properly recognised
+ */
+public class TypeSafeMap2Test extends TestCase {
+ public void testDumpMap() {
+ MapBean2 bean = new MapBean2();
+ Map<Developer2, Color> data = new LinkedHashMap<Developer2, Color>();
+ data.put(new Developer2("Andy", "tester"), Color.BLACK);
+ data.put(new Developer2("Lisa", "owner"), Color.RED);
+ bean.setData(data);
+ Map<Color, Developer2> developers = new LinkedHashMap<Color, Developer2>();
+ developers.put(Color.WHITE, new Developer2("Fred", "creator"));
+ developers.put(Color.BLACK, new Developer2("John", "committer"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-bean-12.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testMap2() {
+ MapBean2 bean = new MapBean2();
+ Map<Developer2, Color> data = new LinkedHashMap<Developer2, Color>();
+ data.put(new Developer2("Andy", "tester"), Color.BLACK);
+ data.put(new SuperMan("Bill", "cleaner", false), Color.BLACK);
+ data.put(new Developer2("Lisa", "owner"), Color.RED);
+ bean.setData(data);
+ Map<Color, Developer2> developers = new LinkedHashMap<Color, Developer2>();
+ developers.put(Color.WHITE, new Developer2("Fred", "creator"));
+ developers.put(Color.RED, new SuperMan("Jason", "contributor", true));
+ developers.put(Color.BLACK, new Developer2("John", "committer"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-bean-13.yaml");
+ assertEquals(etalon, output);
+ // load
+ Yaml beanLoader = new Yaml();
+ MapBean2 parsed = beanLoader.loadAs(etalon, MapBean2.class);
+ assertNotNull(parsed);
+ Map<Developer2, Color> parsedData = parsed.getData();
+ assertEquals(3, parsedData.size());
+ assertTrue(parsedData.containsKey(new SuperMan("Bill", "cleaner", false)));
+ assertEquals(Color.BLACK, parsedData.get(new SuperMan("Bill", "cleaner", false)));
+ //
+ Map<Color, Developer2> parsedDevelopers = parsed.getDevelopers();
+ assertEquals(3, parsedDevelopers.size());
+ assertEquals(new SuperMan("Jason", "contributor", true), parsedDevelopers.get(Color.RED));
+ }
+
+ public void testLoadMap() {
+ String output = Util.getLocalResource("examples/map-bean-12.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ MapBean2 parsed = beanLoader.loadAs(output, MapBean2.class);
+ assertNotNull(parsed);
+ Map<Developer2, Color> data = parsed.getData();
+ assertEquals(2, data.size());
+ Iterator<Developer2> iter = data.keySet().iterator();
+ Developer2 first = iter.next();
+ assertEquals("Andy", first.getName());
+ assertEquals("tester", first.getRole());
+ assertEquals(Color.BLACK, data.get(first));
+ Developer2 second = iter.next();
+ assertEquals("Lisa", second.getName());
+ assertEquals("owner", second.getRole());
+ assertEquals(Color.RED, data.get(second));
+ //
+ Map<Color, Developer2> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ Iterator<Color> iter2 = developers.keySet().iterator();
+ Color firstColor = iter2.next();
+ assertEquals(Color.WHITE, firstColor);
+ Developer2 dev1 = developers.get(firstColor);
+ assertEquals("Fred", dev1.getName());
+ assertEquals("creator", dev1.getRole());
+ Color secondColor = iter2.next();
+ assertEquals(Color.BLACK, secondColor);
+ Developer2 dev2 = developers.get(secondColor);
+ assertEquals("John", dev2.getName());
+ assertEquals("committer", dev2.getRole());
+ }
+
+ public static enum Color {
+ WHITE, BLACK, RED;
+ }
+
+ public static class MapBean2 {
+ private Map<Developer2, Color> data;
+ private String name;
+ private Map<Color, Developer2> developers;
+
+ public MapBean2() {
+ name = "Bean123";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map<Color, Developer2> getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(Map<Color, Developer2> developers) {
+ this.developers = developers;
+ }
+
+ public Map<Developer2, Color> getData() {
+ return data;
+ }
+
+ public void setData(Map<Developer2, Color> data) {
+ this.data = data;
+ }
+
+ }
+
+ public static class Developer2 implements Comparable<Developer2> {
+ private String name;
+ private String role;
+
+ public Developer2() {
+ }
+
+ private Developer2(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public int compareTo(Developer2 o) {
+ return name.compareTo(o.name);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Developer2) {
+ return toString().equals(obj.toString());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "Developer " + name + " " + role;
+ }
+
+ }
+
+ public static class SuperMan extends Developer2 {
+ private boolean smart;
+
+ public SuperMan() {
+ super();
+ }
+
+ private SuperMan(String name, String role, boolean smart) {
+ super(name, role);
+ this.smart = smart;
+ }
+
+ public boolean isSmart() {
+ return smart;
+ }
+
+ public void setSmart(boolean smart) {
+ this.smart = smart;
+ }
+
+ @Override
+ public String toString() {
+ return "Super" + super.toString();
+ }
+ }
+}
diff --git a/src/test/java/examples/collections/TypeSafeMapImplementationsTest.java b/src/test/java/examples/collections/TypeSafeMapImplementationsTest.java
index 39b489c..20aa6d5 100644
--- a/src/test/java/examples/collections/TypeSafeMapImplementationsTest.java
+++ b/src/test/java/examples/collections/TypeSafeMapImplementationsTest.java
@@ -1,204 +1,204 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.SortedMap;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test different Map implementations as JavaBean properties
- */
-public class TypeSafeMapImplementationsTest extends TestCase {
- public void testDumpMap() {
- MapBean bean = new MapBean();
- SortedMap<String, String> sortedMap = new TreeMap<String, String>();
- sortedMap.put("2", "two");
- sortedMap.put("1", "one");
- bean.setSorted(sortedMap);
- Properties props = new Properties();
- props.setProperty("key1", "value1");
- props.setProperty("key2", "value2");
- bean.setProperties(props);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-bean-1.yaml");
- assertEquals(etalon, output);
- }
-
- public void testLoadMap() {
- String output = Util.getLocalResource("examples/map-bean-1.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- MapBean parsed = beanLoader.loadAs(output, MapBean.class);
- assertNotNull(parsed);
- SortedMap<String, String> sortedMap = parsed.getSorted();
- assertEquals(2, sortedMap.size());
- assertEquals("one", sortedMap.get("1"));
- assertEquals("two", sortedMap.get("2"));
- String first = sortedMap.keySet().iterator().next();
- assertEquals("1", first);
- //
- Properties props = parsed.getProperties();
- assertEquals(2, props.size());
- assertEquals("value1", props.getProperty("key1"));
- assertEquals("value2", props.getProperty("key2"));
- }
-
- public static class MapBean {
- private SortedMap<String, String> sorted;
- private Properties properties;
- private String name;
-
- public MapBean() {
- name = "Bean123";
- }
-
- public SortedMap<String, String> getSorted() {
- return sorted;
- }
-
- public void setSorted(SortedMap<String, String> sorted) {
- this.sorted = sorted;
- }
-
- public Properties getProperties() {
- return properties;
- }
-
- public void setProperties(Properties properties) {
- this.properties = properties;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testNoJavaBeanMap() {
- List<Object> list = new ArrayList<Object>(3);
- SortedMap<String, String> sortedMap = new TreeMap<String, String>();
- sortedMap.put("2", "two");
- sortedMap.put("1", "one");
- list.add(sortedMap);
- Properties props = new Properties();
- props.setProperty("key1", "value1");
- props.setProperty("key2", "value2");
- list.add(props);
- list.add("aaa");
- Yaml yaml = new Yaml();
- String output = yaml.dump(list);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-bean-2.yaml");
- assertEquals(etalon, output);
- // load
- List<Object> list2 = (List<Object>) yaml.load(output);
- assertEquals(3, list2.size());
- Map<Object, Object> map1 = (Map<Object, Object>) list.get(0);// it was
- // SortedMap
- assertEquals(2, map1.size());
- assertEquals("one", map1.get("1"));
- assertEquals("two", map1.get("2"));
- Map<Object, Object> map2 = (Map<Object, Object>) list.get(1);// it was
- // Properties
- assertEquals(2, map2.size());
- assertEquals("value1", map2.get("key1"));
- assertEquals("value2", map2.get("key2"));
- assertEquals("aaa", list.get(2));
- }
-
- public void testRecursiveNoJavaBeanMap1() {
- SortedMap<String, Object> sortedMap = new TreeMap<String, Object>();
- sortedMap.put("2", "two");
- sortedMap.put("1", "one");
- sortedMap.put("3", sortedMap);
- Yaml yaml = new Yaml();
- String output = yaml.dump(sortedMap);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-recursive-1.yaml");
- assertEquals(etalon, output);
- // load with different order
- @SuppressWarnings("unchecked")
- Map<Object, Object> map1 = (Map<Object, Object>) yaml.load(Util
- .getLocalResource("examples/map-recursive-1_1.yaml"));
- assertEquals(3, map1.size());
- assertEquals("one", map1.get("1"));
- assertEquals("two", map1.get("2"));
- // test that the order is taken from YAML instead of sorting
- String first = (String) map1.keySet().iterator().next();
- assertEquals("2", first);
- }
-
- @SuppressWarnings("unchecked")
- public void testRecursiveNoJavaBeanProperties2() {
- Properties props = new Properties();
- props.setProperty("key1", "value1");
- props.setProperty("key2", "value2");
- Map<Object, Object> map = props;
- map.put("key3", props);
- Yaml yaml = new Yaml();
- String output = yaml.dump(props);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-recursive-2.yaml");
- assertEquals(etalon, output);
- // load
- Map<Object, Object> map2 = (Map<Object, Object>) yaml.load(output);
- assertEquals(3, map2.size());
- assertEquals("value1", map2.get("key1"));
- assertEquals("value2", map2.get("key2"));
- }
-
- public void testRecursiveNoJavaBeanMap3() {
- Yaml yaml = new Yaml();
- String output = Util.getLocalResource("examples/map-recursive-3.yaml");
- // System.out.println(output);
- @SuppressWarnings("unchecked")
- SortedMap<Object, Object> map1 = (SortedMap<Object, Object>) yaml.load(output);
- assertEquals(3, map1.size());
- assertEquals("one", map1.get("1"));
- assertEquals("two", map1.get("2"));
- // test that the order is NOT taken from YAML but sorted
- String first = (String) map1.keySet().iterator().next();
- assertEquals("1", first);
- }
-
- public void testRecursiveNoJavaBeanProperties4() {
- Yaml yaml = new Yaml();
- String output = Util.getLocalResource("examples/map-recursive-4.yaml");
- // System.out.println(output);
- try {
- yaml.load(output);
- fail("Recursive Properties are not supported.");
- } catch (Exception e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Properties must not be recursive."));
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.SortedMap;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test different Map implementations as JavaBean properties
+ */
+public class TypeSafeMapImplementationsTest extends TestCase {
+ public void testDumpMap() {
+ MapBean bean = new MapBean();
+ SortedMap<String, String> sortedMap = new TreeMap<String, String>();
+ sortedMap.put("2", "two");
+ sortedMap.put("1", "one");
+ bean.setSorted(sortedMap);
+ Properties props = new Properties();
+ props.setProperty("key1", "value1");
+ props.setProperty("key2", "value2");
+ bean.setProperties(props);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-bean-1.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testLoadMap() {
+ String output = Util.getLocalResource("examples/map-bean-1.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ MapBean parsed = beanLoader.loadAs(output, MapBean.class);
+ assertNotNull(parsed);
+ SortedMap<String, String> sortedMap = parsed.getSorted();
+ assertEquals(2, sortedMap.size());
+ assertEquals("one", sortedMap.get("1"));
+ assertEquals("two", sortedMap.get("2"));
+ String first = sortedMap.keySet().iterator().next();
+ assertEquals("1", first);
+ //
+ Properties props = parsed.getProperties();
+ assertEquals(2, props.size());
+ assertEquals("value1", props.getProperty("key1"));
+ assertEquals("value2", props.getProperty("key2"));
+ }
+
+ public static class MapBean {
+ private SortedMap<String, String> sorted;
+ private Properties properties;
+ private String name;
+
+ public MapBean() {
+ name = "Bean123";
+ }
+
+ public SortedMap<String, String> getSorted() {
+ return sorted;
+ }
+
+ public void setSorted(SortedMap<String, String> sorted) {
+ this.sorted = sorted;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testNoJavaBeanMap() {
+ List<Object> list = new ArrayList<Object>(3);
+ SortedMap<String, String> sortedMap = new TreeMap<String, String>();
+ sortedMap.put("2", "two");
+ sortedMap.put("1", "one");
+ list.add(sortedMap);
+ Properties props = new Properties();
+ props.setProperty("key1", "value1");
+ props.setProperty("key2", "value2");
+ list.add(props);
+ list.add("aaa");
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(list);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-bean-2.yaml");
+ assertEquals(etalon, output);
+ // load
+ List<Object> list2 = (List<Object>) yaml.load(output);
+ assertEquals(3, list2.size());
+ Map<Object, Object> map1 = (Map<Object, Object>) list.get(0);// it was
+ // SortedMap
+ assertEquals(2, map1.size());
+ assertEquals("one", map1.get("1"));
+ assertEquals("two", map1.get("2"));
+ Map<Object, Object> map2 = (Map<Object, Object>) list.get(1);// it was
+ // Properties
+ assertEquals(2, map2.size());
+ assertEquals("value1", map2.get("key1"));
+ assertEquals("value2", map2.get("key2"));
+ assertEquals("aaa", list.get(2));
+ }
+
+ public void testRecursiveNoJavaBeanMap1() {
+ SortedMap<String, Object> sortedMap = new TreeMap<String, Object>();
+ sortedMap.put("2", "two");
+ sortedMap.put("1", "one");
+ sortedMap.put("3", sortedMap);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(sortedMap);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-recursive-1.yaml");
+ assertEquals(etalon, output);
+ // load with different order
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> map1 = (Map<Object, Object>) yaml.load(Util
+ .getLocalResource("examples/map-recursive-1_1.yaml"));
+ assertEquals(3, map1.size());
+ assertEquals("one", map1.get("1"));
+ assertEquals("two", map1.get("2"));
+ // test that the order is taken from YAML instead of sorting
+ String first = (String) map1.keySet().iterator().next();
+ assertEquals("2", first);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testRecursiveNoJavaBeanProperties2() {
+ Properties props = new Properties();
+ props.setProperty("key1", "value1");
+ props.setProperty("key2", "value2");
+ Map<Object, Object> map = props;
+ map.put("key3", props);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(props);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-recursive-2.yaml");
+ assertEquals(etalon, output);
+ // load
+ Map<Object, Object> map2 = (Map<Object, Object>) yaml.load(output);
+ assertEquals(3, map2.size());
+ assertEquals("value1", map2.get("key1"));
+ assertEquals("value2", map2.get("key2"));
+ }
+
+ public void testRecursiveNoJavaBeanMap3() {
+ Yaml yaml = new Yaml();
+ String output = Util.getLocalResource("examples/map-recursive-3.yaml");
+ // System.out.println(output);
+ @SuppressWarnings("unchecked")
+ SortedMap<Object, Object> map1 = (SortedMap<Object, Object>) yaml.load(output);
+ assertEquals(3, map1.size());
+ assertEquals("one", map1.get("1"));
+ assertEquals("two", map1.get("2"));
+ // test that the order is NOT taken from YAML but sorted
+ String first = (String) map1.keySet().iterator().next();
+ assertEquals("1", first);
+ }
+
+ public void testRecursiveNoJavaBeanProperties4() {
+ Yaml yaml = new Yaml();
+ String output = Util.getLocalResource("examples/map-recursive-4.yaml");
+ // System.out.println(output);
+ try {
+ yaml.load(output);
+ fail("Recursive Properties are not supported.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("Properties must not be recursive."));
+ }
+ }
+}
diff --git a/src/test/java/examples/collections/TypeSafeMapTest.java b/src/test/java/examples/collections/TypeSafeMapTest.java
index d437c5e..d5b61b2 100644
--- a/src/test/java/examples/collections/TypeSafeMapTest.java
+++ b/src/test/java/examples/collections/TypeSafeMapTest.java
@@ -1,220 +1,220 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test MapBean->Map<String, Developer> developers <br/>
- * Developer class must be properly recognised
- */
-public class TypeSafeMapTest extends TestCase {
- public void testDumpMap() {
- MapBean bean = new MapBean();
- Map<String, Integer> data = new LinkedHashMap<String, Integer>();
- data.put("aaa", 1);
- data.put("bbb", 2);
- data.put("zzz", 3);
- bean.setData(data);
- Map<String, Developer2> developers = new LinkedHashMap<String, Developer2>();
- developers.put("team1", new Developer2("Fred", "creator"));
- developers.put("team2", new Developer2("John", "committer"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-bean-10.yaml");
- assertEquals(etalon, output);
- }
-
- public void testDumpMap2() {
- MapBean bean = new MapBean();
- Map<String, Integer> data = new LinkedHashMap<String, Integer>();
- data.put("aaa", 1);
- data.put("bbb", 2);
- bean.setData(data);
- Map<String, Developer2> developers = new LinkedHashMap<String, Developer2>();
- developers.put("team1", new Developer2("Fred", "creator"));
- developers.put("team2", new Developer2("John", "committer"));
- developers.put("team3", new Developer222("Bill", "head"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/map-bean-11.yaml");
- assertEquals(etalon, output);
- }
-
- public void testLoadMap() {
- String output = Util.getLocalResource("examples/map-bean-10.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- MapBean parsed = beanLoader.loadAs(output, MapBean.class);
- assertNotNull(parsed);
- Map<String, Integer> data = parsed.getData();
- assertEquals(3, data.size());
- assertEquals(new Integer(1), data.get("aaa"));
- assertEquals(new Integer(2), data.get("bbb"));
- assertEquals(new Integer(3), data.get("zzz"));
- Map<String, Developer2> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- assertEquals("Developer must be recognised.", Developer2.class, developers.get("team1")
- .getClass());
- Developer2 fred = developers.get("team1");
- assertEquals("Fred", fred.getName());
- assertEquals("creator", fred.getRole());
- }
-
- public static class MapBean {
- private Map<String, Integer> data;
- private String name;
- private Map<String, Developer2> developers;
-
- public MapBean() {
- name = "Bean123";
- }
-
- public Map<String, Integer> getData() {
- return data;
- }
-
- public void setData(Map<String, Integer> data) {
- this.data = data;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Map<String, Developer2> getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(Map<String, Developer2> developers) {
- this.developers = developers;
- }
- }
-
- public static class Developer2 {
- private String name;
- private String role;
-
- public Developer2() {
- }
-
- public Developer2(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
- }
-
- public static class Developer222 extends Developer2 {
- public Developer222() {
- super();
- }
-
- public Developer222(String name, String role) {
- super(name, role);
- }
- }
-
- /*
- * No generic collection
- */
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void testLoadMapWithObject() {
- String output = Util.getLocalResource("examples/map-bean-10.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- MapBeanNoGenerics parsed = beanLoader.loadAs(output, MapBeanNoGenerics.class);
- assertNotNull(parsed);
- Map<String, Integer> data = parsed.getData();
- assertEquals(3, data.size());
- assertEquals(new Integer(1), data.get("aaa"));
- assertEquals(new Integer(2), data.get("bbb"));
- assertEquals(new Integer(3), data.get("zzz"));
- Map developers = parsed.getDevelopers();
- assertNotNull(developers);
- assertEquals(2, developers.size());
- Object o1 = developers.get("team1");
- // because of erasure we get simply Map
- Map<String, String> developer = (Map<String, String>) o1;
- assertEquals("Fred", developer.get("name"));
- assertEquals("creator", developer.get("role"));
- }
-
- @SuppressWarnings("rawtypes")
- public static class MapBeanNoGenerics {
- private Map data;
- private String name;
- private Map developers;
-
- public MapBeanNoGenerics() {
- name = "Bean123";
- }
-
- public Map getData() {
- return data;
- }
-
- public void setData(Map data) {
- this.data = data;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Map getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(Map developers) {
- this.developers = developers;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test MapBean->Map<String, Developer> developers <br/>
+ * Developer class must be properly recognised
+ */
+public class TypeSafeMapTest extends TestCase {
+ public void testDumpMap() {
+ MapBean bean = new MapBean();
+ Map<String, Integer> data = new LinkedHashMap<String, Integer>();
+ data.put("aaa", 1);
+ data.put("bbb", 2);
+ data.put("zzz", 3);
+ bean.setData(data);
+ Map<String, Developer2> developers = new LinkedHashMap<String, Developer2>();
+ developers.put("team1", new Developer2("Fred", "creator"));
+ developers.put("team2", new Developer2("John", "committer"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-bean-10.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testDumpMap2() {
+ MapBean bean = new MapBean();
+ Map<String, Integer> data = new LinkedHashMap<String, Integer>();
+ data.put("aaa", 1);
+ data.put("bbb", 2);
+ bean.setData(data);
+ Map<String, Developer2> developers = new LinkedHashMap<String, Developer2>();
+ developers.put("team1", new Developer2("Fred", "creator"));
+ developers.put("team2", new Developer2("John", "committer"));
+ developers.put("team3", new Developer222("Bill", "head"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/map-bean-11.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testLoadMap() {
+ String output = Util.getLocalResource("examples/map-bean-10.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ MapBean parsed = beanLoader.loadAs(output, MapBean.class);
+ assertNotNull(parsed);
+ Map<String, Integer> data = parsed.getData();
+ assertEquals(3, data.size());
+ assertEquals(new Integer(1), data.get("aaa"));
+ assertEquals(new Integer(2), data.get("bbb"));
+ assertEquals(new Integer(3), data.get("zzz"));
+ Map<String, Developer2> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ assertEquals("Developer must be recognised.", Developer2.class, developers.get("team1")
+ .getClass());
+ Developer2 fred = developers.get("team1");
+ assertEquals("Fred", fred.getName());
+ assertEquals("creator", fred.getRole());
+ }
+
+ public static class MapBean {
+ private Map<String, Integer> data;
+ private String name;
+ private Map<String, Developer2> developers;
+
+ public MapBean() {
+ name = "Bean123";
+ }
+
+ public Map<String, Integer> getData() {
+ return data;
+ }
+
+ public void setData(Map<String, Integer> data) {
+ this.data = data;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map<String, Developer2> getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(Map<String, Developer2> developers) {
+ this.developers = developers;
+ }
+ }
+
+ public static class Developer2 {
+ private String name;
+ private String role;
+
+ public Developer2() {
+ }
+
+ public Developer2(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+ }
+
+ public static class Developer222 extends Developer2 {
+ public Developer222() {
+ super();
+ }
+
+ public Developer222(String name, String role) {
+ super(name, role);
+ }
+ }
+
+ /*
+ * No generic collection
+ */
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testLoadMapWithObject() {
+ String output = Util.getLocalResource("examples/map-bean-10.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ MapBeanNoGenerics parsed = beanLoader.loadAs(output, MapBeanNoGenerics.class);
+ assertNotNull(parsed);
+ Map<String, Integer> data = parsed.getData();
+ assertEquals(3, data.size());
+ assertEquals(new Integer(1), data.get("aaa"));
+ assertEquals(new Integer(2), data.get("bbb"));
+ assertEquals(new Integer(3), data.get("zzz"));
+ Map developers = parsed.getDevelopers();
+ assertNotNull(developers);
+ assertEquals(2, developers.size());
+ Object o1 = developers.get("team1");
+ // because of erasure we get simply Map
+ Map<String, String> developer = (Map<String, String>) o1;
+ assertEquals("Fred", developer.get("name"));
+ assertEquals("creator", developer.get("role"));
+ }
+
+ @SuppressWarnings("rawtypes")
+ public static class MapBeanNoGenerics {
+ private Map data;
+ private String name;
+ private Map developers;
+
+ public MapBeanNoGenerics() {
+ name = "Bean123";
+ }
+
+ public Map getData() {
+ return data;
+ }
+
+ public void setData(Map data) {
+ this.data = data;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Map getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(Map developers) {
+ this.developers = developers;
+ }
+ }
+}
diff --git a/src/test/java/examples/collections/TypeSafePriorityTest.java b/src/test/java/examples/collections/TypeSafePriorityTest.java
index 20ddcd4..a693606 100644
--- a/src/test/java/examples/collections/TypeSafePriorityTest.java
+++ b/src/test/java/examples/collections/TypeSafePriorityTest.java
@@ -1,119 +1,119 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-/**
- * Test ListBean->List<Human> developers <br/>
- * Human is an interface and the global tags are required
- */
-public class TypeSafePriorityTest extends TestCase {
-
- /**
- * explicit TypeDescription is more important then runtime class (which may
- * be an interface)
- */
- public void testLoadList2() {
- String output = Util.getLocalResource("examples/list-bean-3.yaml");
- // System.out.println(output);
- TypeDescription descr = new TypeDescription(ListBean.class);
- descr.putListPropertyType("developers", Developer.class);
- Yaml beanLoader = new Yaml(new Constructor(descr));
- ListBean parsed = beanLoader.loadAs(output, ListBean.class);
- assertNotNull(parsed);
- List<Human> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- assertEquals("Committer must be recognised.", Developer.class, developers.get(0).getClass());
- Developer fred = (Developer) developers.get(0);
- assertEquals("Fred", fred.getName());
- assertEquals("creator", fred.getRole());
- Developer john = (Developer) developers.get(1);
- assertEquals("John", john.getName());
- assertEquals("committer", john.getRole());
- }
-
- public static class ListBean {
- private String name;
- private List<Human> developers;
-
- public ListBean() {
- name = "Bean123";
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<Human> getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(List<Human> developers) {
- this.developers = developers;
- }
- }
-
- public static interface Human {
-
- public String getName();
-
- public void setName(String name);
-
- }
-
- public static class Developer implements Human {
- private String name;
- private String role;
-
- public Developer() {
- }
-
- public Developer(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+/**
+ * Test ListBean->List<Human> developers <br/>
+ * Human is an interface and the global tags are required
+ */
+public class TypeSafePriorityTest extends TestCase {
+
+ /**
+ * explicit TypeDescription is more important then runtime class (which may
+ * be an interface)
+ */
+ public void testLoadList2() {
+ String output = Util.getLocalResource("examples/list-bean-3.yaml");
+ // System.out.println(output);
+ TypeDescription descr = new TypeDescription(ListBean.class);
+ descr.putListPropertyType("developers", Developer.class);
+ Yaml beanLoader = new Yaml(new Constructor(descr));
+ ListBean parsed = beanLoader.loadAs(output, ListBean.class);
+ assertNotNull(parsed);
+ List<Human> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ assertEquals("Committer must be recognised.", Developer.class, developers.get(0).getClass());
+ Developer fred = (Developer) developers.get(0);
+ assertEquals("Fred", fred.getName());
+ assertEquals("creator", fred.getRole());
+ Developer john = (Developer) developers.get(1);
+ assertEquals("John", john.getName());
+ assertEquals("committer", john.getRole());
+ }
+
+ public static class ListBean {
+ private String name;
+ private List<Human> developers;
+
+ public ListBean() {
+ name = "Bean123";
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<Human> getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(List<Human> developers) {
+ this.developers = developers;
+ }
+ }
+
+ public static interface Human {
+
+ public String getName();
+
+ public void setName(String name);
+
+ }
+
+ public static class Developer implements Human {
+ private String name;
+ private String role;
+
+ public Developer() {
+ }
+
+ public Developer(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+ }
+
+}
diff --git a/src/test/java/examples/collections/TypeSafeSetImplementationsTest.java b/src/test/java/examples/collections/TypeSafeSetImplementationsTest.java
index aa89a1c..f6cc7c3 100644
--- a/src/test/java/examples/collections/TypeSafeSetImplementationsTest.java
+++ b/src/test/java/examples/collections/TypeSafeSetImplementationsTest.java
@@ -1,271 +1,271 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.collections;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test different Map implementations as JavaBean properties
- */
-public class TypeSafeSetImplementationsTest extends TestCase {
- public void testDumpSet() {
- SetBean bean = new SetBean();
- SortedSet<String> sortedSet = new TreeSet<String>();
- sortedSet.add("two");
- sortedSet.add("one");
- sortedSet.add("three");
- bean.setSorted(sortedSet);
- SortedSet<Developer> developers = new TreeSet<Developer>();
- developers.add(new Developer("John", "founder"));
- developers.add(new Developer("Karl", "user"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/set-bean-1.yaml");
- assertEquals(etalon, output);
- }
-
- public void testDumpSet2() {
- SetBean bean = new SetBean();
- SortedSet<String> sortedSet = new TreeSet<String>();
- sortedSet.add("two");
- sortedSet.add("one");
- sortedSet.add("three");
- bean.setSorted(sortedSet);
- SortedSet<Developer> developers = new TreeSet<Developer>();
- developers.add(new Developer("John", "founder"));
- developers.add(new Developer("Karl", "user"));
- developers.add(new SuperDeveloper("Bill", "super"));
- bean.setDevelopers(developers);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- String etalon = Util.getLocalResource("examples/set-bean-6.yaml");
- assertEquals(etalon, output);
- }
-
- public void testLoadSet() {
- String output = Util.getLocalResource("examples/set-bean-1.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- SetBean parsed = beanLoader.loadAs(output, SetBean.class);
- assertNotNull(parsed);
- SortedSet<String> sortedMap = parsed.getSorted();
- assertEquals(3, sortedMap.size());
- assertTrue(sortedMap.contains("one"));
- assertTrue(sortedMap.contains("two"));
- assertTrue(sortedMap.contains("three"));
- String first = sortedMap.iterator().next();
- assertEquals("one", first);
- //
- SortedSet<Developer> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- assertEquals("John", developers.first().getName());
- assertEquals("Karl", developers.last().getName());
- }
-
- public void testLoadSetReversed() {
- String output = Util.getLocalResource("examples/set-bean-2.yaml");
- // System.out.println(output);
- Yaml beanLoader = new Yaml();
- SetBean parsed = beanLoader.loadAs(output, SetBean.class);
- assertNotNull(parsed);
- SortedSet<String> sortedMap = parsed.getSorted();
- assertEquals(3, sortedMap.size());
- assertTrue(sortedMap.contains("one"));
- assertTrue(sortedMap.contains("two"));
- assertTrue(sortedMap.contains("three"));
- // alphabetically: one, three, two
- assertEquals("one", sortedMap.first());
- assertEquals("two", sortedMap.last());
- // the order is not from YAML (must be sorted)
- SortedSet<Developer> developers = parsed.getDevelopers();
- assertEquals(2, developers.size());
- assertEquals("John", developers.first().getName());
- assertEquals("Karl", developers.last().getName());
- }
-
- public static class SetBean {
- private SortedSet<String> sorted;
- private SortedSet<Developer> developers;
- private String name;
-
- public SetBean() {
- name = "Bean123";
- }
-
- public SortedSet<String> getSorted() {
- return sorted;
- }
-
- public void setSorted(SortedSet<String> sorted) {
- this.sorted = sorted;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public SortedSet<Developer> getDevelopers() {
- return developers;
- }
-
- public void setDevelopers(SortedSet<Developer> developers) {
- this.developers = developers;
- }
- }
-
- public static class Developer implements Comparable<Developer> {
- private String name;
- private String role;
-
- public Developer() {
- }
-
- public Developer(String name, String role) {
- this.name = name;
- this.role = role;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getRole() {
- return role;
- }
-
- public void setRole(String role) {
- this.role = role;
- }
-
- public int compareTo(Developer o) {
- return name.compareTo(o.name);
- }
- }
-
- public static class SuperDeveloper extends Developer {
-
- public SuperDeveloper() {
- super();
- }
-
- public SuperDeveloper(String string, String string2) {
- super(string, string2);
- }
-
- }
-
- @SuppressWarnings("unchecked")
- public void testNoJavaBeanSetRecursive() {
- Set<Object> set = new HashSet<Object>(3);
- set.add("aaa");
- set.add(111);
- Box box = new Box();
- box.setId("id123");
- box.setSet(set);
- set.add(box);
- Yaml yaml = new Yaml();
- String output = yaml.dump(set);
- // System.out.println(output);
- // the order may differ on different JVMs
- // String etalon = Util.getLocalResource("examples/set-bean-3.yaml");
- // assertEquals(etalon, output);
- assertTrue(output.contains("&id001 !!set"));
- assertTrue(output.contains("? !!examples.collections.TypeSafeSetImplementationsTest$Box"));
- assertTrue(output.contains("set: *id001"));
- assertTrue(output.contains("111: null"));
- // load
- Set<Object> list2 = (Set<Object>) yaml.load(output);
- assertEquals(3, list2.size());
- assertTrue(list2.contains("aaa"));
- assertTrue(list2.contains(111));
- }
-
- public static class Box {
- private String id;
- private Set<Object> set;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Set<Object> getSet() {
- return set;
- }
-
- public void setSet(Set<Object> set) {
- this.set = set;
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testNoJavaBeanSet() {
- Yaml yaml = new Yaml();
- String output = Util.getLocalResource("examples/set-bean-4.yaml");
- // System.out.println(output);
- // load
- Set<String> set = (Set<String>) yaml.load(output);
- assertEquals(3, set.size());
- assertTrue(set.contains("aaa"));
- assertTrue(set.contains("bbb"));
- assertTrue(set.contains("zzz"));
- Iterator<String> iter = set.iterator();
- assertEquals("bbb", iter.next());
- assertEquals("aaa", iter.next());
- assertEquals("zzz", iter.next());
- }
-
- @SuppressWarnings("unchecked")
- public void testNoJavaBeanSet2() {
- Yaml yaml = new Yaml();
- String output = Util.getLocalResource("examples/set-bean-5.yaml");
- // System.out.println(output);
- // load and sort
- Set<String> set = (Set<String>) yaml.load(output);
- assertEquals(3, set.size());
- assertTrue(set.contains("aaa"));
- assertTrue(set.contains("bbb"));
- assertTrue(set.contains("zzz"));
- Iterator<String> iter = set.iterator();
- assertEquals("aaa", iter.next());
- assertEquals("bbb", iter.next());
- assertEquals("zzz", iter.next());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.collections;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test different Map implementations as JavaBean properties
+ */
+public class TypeSafeSetImplementationsTest extends TestCase {
+ public void testDumpSet() {
+ SetBean bean = new SetBean();
+ SortedSet<String> sortedSet = new TreeSet<String>();
+ sortedSet.add("two");
+ sortedSet.add("one");
+ sortedSet.add("three");
+ bean.setSorted(sortedSet);
+ SortedSet<Developer> developers = new TreeSet<Developer>();
+ developers.add(new Developer("John", "founder"));
+ developers.add(new Developer("Karl", "user"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/set-bean-1.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testDumpSet2() {
+ SetBean bean = new SetBean();
+ SortedSet<String> sortedSet = new TreeSet<String>();
+ sortedSet.add("two");
+ sortedSet.add("one");
+ sortedSet.add("three");
+ bean.setSorted(sortedSet);
+ SortedSet<Developer> developers = new TreeSet<Developer>();
+ developers.add(new Developer("John", "founder"));
+ developers.add(new Developer("Karl", "user"));
+ developers.add(new SuperDeveloper("Bill", "super"));
+ bean.setDevelopers(developers);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("examples/set-bean-6.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testLoadSet() {
+ String output = Util.getLocalResource("examples/set-bean-1.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ SetBean parsed = beanLoader.loadAs(output, SetBean.class);
+ assertNotNull(parsed);
+ SortedSet<String> sortedMap = parsed.getSorted();
+ assertEquals(3, sortedMap.size());
+ assertTrue(sortedMap.contains("one"));
+ assertTrue(sortedMap.contains("two"));
+ assertTrue(sortedMap.contains("three"));
+ String first = sortedMap.iterator().next();
+ assertEquals("one", first);
+ //
+ SortedSet<Developer> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ assertEquals("John", developers.first().getName());
+ assertEquals("Karl", developers.last().getName());
+ }
+
+ public void testLoadSetReversed() {
+ String output = Util.getLocalResource("examples/set-bean-2.yaml");
+ // System.out.println(output);
+ Yaml beanLoader = new Yaml();
+ SetBean parsed = beanLoader.loadAs(output, SetBean.class);
+ assertNotNull(parsed);
+ SortedSet<String> sortedMap = parsed.getSorted();
+ assertEquals(3, sortedMap.size());
+ assertTrue(sortedMap.contains("one"));
+ assertTrue(sortedMap.contains("two"));
+ assertTrue(sortedMap.contains("three"));
+ // alphabetically: one, three, two
+ assertEquals("one", sortedMap.first());
+ assertEquals("two", sortedMap.last());
+ // the order is not from YAML (must be sorted)
+ SortedSet<Developer> developers = parsed.getDevelopers();
+ assertEquals(2, developers.size());
+ assertEquals("John", developers.first().getName());
+ assertEquals("Karl", developers.last().getName());
+ }
+
+ public static class SetBean {
+ private SortedSet<String> sorted;
+ private SortedSet<Developer> developers;
+ private String name;
+
+ public SetBean() {
+ name = "Bean123";
+ }
+
+ public SortedSet<String> getSorted() {
+ return sorted;
+ }
+
+ public void setSorted(SortedSet<String> sorted) {
+ this.sorted = sorted;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public SortedSet<Developer> getDevelopers() {
+ return developers;
+ }
+
+ public void setDevelopers(SortedSet<Developer> developers) {
+ this.developers = developers;
+ }
+ }
+
+ public static class Developer implements Comparable<Developer> {
+ private String name;
+ private String role;
+
+ public Developer() {
+ }
+
+ public Developer(String name, String role) {
+ this.name = name;
+ this.role = role;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getRole() {
+ return role;
+ }
+
+ public void setRole(String role) {
+ this.role = role;
+ }
+
+ public int compareTo(Developer o) {
+ return name.compareTo(o.name);
+ }
+ }
+
+ public static class SuperDeveloper extends Developer {
+
+ public SuperDeveloper() {
+ super();
+ }
+
+ public SuperDeveloper(String string, String string2) {
+ super(string, string2);
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testNoJavaBeanSetRecursive() {
+ Set<Object> set = new HashSet<Object>(3);
+ set.add("aaa");
+ set.add(111);
+ Box box = new Box();
+ box.setId("id123");
+ box.setSet(set);
+ set.add(box);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(set);
+ // System.out.println(output);
+ // the order may differ on different JVMs
+ // String etalon = Util.getLocalResource("examples/set-bean-3.yaml");
+ // assertEquals(etalon, output);
+ assertTrue(output.contains("&id001 !!set"));
+ assertTrue(output.contains("? !!examples.collections.TypeSafeSetImplementationsTest$Box"));
+ assertTrue(output.contains("set: *id001"));
+ assertTrue(output.contains("111: null"));
+ // load
+ Set<Object> list2 = (Set<Object>) yaml.load(output);
+ assertEquals(3, list2.size());
+ assertTrue(list2.contains("aaa"));
+ assertTrue(list2.contains(111));
+ }
+
+ public static class Box {
+ private String id;
+ private Set<Object> set;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Set<Object> getSet() {
+ return set;
+ }
+
+ public void setSet(Set<Object> set) {
+ this.set = set;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testNoJavaBeanSet() {
+ Yaml yaml = new Yaml();
+ String output = Util.getLocalResource("examples/set-bean-4.yaml");
+ // System.out.println(output);
+ // load
+ Set<String> set = (Set<String>) yaml.load(output);
+ assertEquals(3, set.size());
+ assertTrue(set.contains("aaa"));
+ assertTrue(set.contains("bbb"));
+ assertTrue(set.contains("zzz"));
+ Iterator<String> iter = set.iterator();
+ assertEquals("bbb", iter.next());
+ assertEquals("aaa", iter.next());
+ assertEquals("zzz", iter.next());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testNoJavaBeanSet2() {
+ Yaml yaml = new Yaml();
+ String output = Util.getLocalResource("examples/set-bean-5.yaml");
+ // System.out.println(output);
+ // load and sort
+ Set<String> set = (Set<String>) yaml.load(output);
+ assertEquals(3, set.size());
+ assertTrue(set.contains("aaa"));
+ assertTrue(set.contains("bbb"));
+ assertTrue(set.contains("zzz"));
+ Iterator<String> iter = set.iterator();
+ assertEquals("aaa", iter.next());
+ assertEquals("bbb", iter.next());
+ assertEquals("zzz", iter.next());
+ }
+}
diff --git a/src/test/java/examples/jodatime/JodaTimeImplicitContructor.java b/src/test/java/examples/jodatime/JodaTimeImplicitContructor.java
index 2c21dd0..b54364c 100644
--- a/src/test/java/examples/jodatime/JodaTimeImplicitContructor.java
+++ b/src/test/java/examples/jodatime/JodaTimeImplicitContructor.java
@@ -1,41 +1,41 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.jodatime;
-
-import java.util.Date;
-
-import org.joda.time.DateTime;
-import org.joda.time.DateTimeZone;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * It works only when JodaTime is not a JavaBean property
- */
-public class JodaTimeImplicitContructor extends Constructor {
- public JodaTimeImplicitContructor() {
- this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructJodaTimestamp());
- }
-
- private class ConstructJodaTimestamp extends ConstructYamlTimestamp {
- public Object construct(Node node) {
- Date date = (Date) super.construct(node);
- return new DateTime(date, DateTimeZone.UTC);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.jodatime;
+
+import java.util.Date;
+
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * It works only when JodaTime is not a JavaBean property
+ */
+public class JodaTimeImplicitContructor extends Constructor {
+ public JodaTimeImplicitContructor() {
+ this.yamlConstructors.put(Tag.TIMESTAMP, new ConstructJodaTimestamp());
+ }
+
+ private class ConstructJodaTimestamp extends ConstructYamlTimestamp {
+ public Object construct(Node node) {
+ Date date = (Date) super.construct(node);
+ return new DateTime(date, DateTimeZone.UTC);
+ }
+ }
+}
diff --git a/src/test/java/examples/jodatime/JodaTimeRepresenter.java b/src/test/java/examples/jodatime/JodaTimeRepresenter.java
index 8fd6d14..0e64b40 100644
--- a/src/test/java/examples/jodatime/JodaTimeRepresenter.java
+++ b/src/test/java/examples/jodatime/JodaTimeRepresenter.java
@@ -1,37 +1,37 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.jodatime;
-
-import java.util.Date;
-
-import org.joda.time.DateTime;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.representer.Representer;
-
-class JodaTimeRepresenter extends Representer {
- public JodaTimeRepresenter() {
- multiRepresenters.put(DateTime.class, new RepresentJodaDateTime());
- }
-
- private class RepresentJodaDateTime extends RepresentDate {
-
- public Node representData(Object data) {
- DateTime date = (DateTime) data;
- return super.representData(new Date(date.getMillis()));
- }
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.jodatime;
+
+import java.util.Date;
+
+import org.joda.time.DateTime;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.representer.Representer;
+
+class JodaTimeRepresenter extends Representer {
+ public JodaTimeRepresenter() {
+ multiRepresenters.put(DateTime.class, new RepresentJodaDateTime());
+ }
+
+ private class RepresentJodaDateTime extends RepresentDate {
+
+ public Node representData(Object data) {
+ DateTime date = (DateTime) data;
+ return super.representData(new Date(date.getMillis()));
+ }
+ }
}
\ No newline at end of file
diff --git a/src/test/java/examples/jodatime/MyBean.java b/src/test/java/examples/jodatime/MyBean.java
index e635023..0ddc7bb 100644
--- a/src/test/java/examples/jodatime/MyBean.java
+++ b/src/test/java/examples/jodatime/MyBean.java
@@ -1,40 +1,40 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.jodatime;
-
-import org.joda.time.DateTime;
-
-public class MyBean {
- private String id;
- private DateTime date;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public DateTime getDate() {
- return date;
- }
-
- public void setDate(DateTime date) {
- this.date = date;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.jodatime;
+
+import org.joda.time.DateTime;
+
+public class MyBean {
+ private String id;
+ private DateTime date;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public DateTime getDate() {
+ return date;
+ }
+
+ public void setDate(DateTime date) {
+ this.date = date;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/examples/resolver/CustomIntResolver.java b/src/test/java/examples/resolver/CustomIntResolver.java
index 6d98971..27da964 100644
--- a/src/test/java/examples/resolver/CustomIntResolver.java
+++ b/src/test/java/examples/resolver/CustomIntResolver.java
@@ -1,41 +1,41 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.resolver;
-
-import java.util.regex.Pattern;
-
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-public class CustomIntResolver extends Resolver {
- public static final Pattern PURE_INT = Pattern.compile("^[0-9]+$");
-
- /*
- * do not resolve int if it has underscores
- */
- protected void addImplicitResolvers() {
- addImplicitResolver(Tag.BOOL, BOOL, "yYnNtTfFoO");
- addImplicitResolver(Tag.FLOAT, FLOAT, "-+0123456789.");
- // define simple int pattern
- addImplicitResolver(Tag.INT, PURE_INT, "0123456789");
- addImplicitResolver(Tag.MERGE, MERGE, "<");
- addImplicitResolver(Tag.NULL, NULL, "~nN\0");
- addImplicitResolver(Tag.NULL, EMPTY, null);
- addImplicitResolver(Tag.TIMESTAMP, TIMESTAMP, "0123456789");
- addImplicitResolver(Tag.VALUE, VALUE, "=");
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.resolver;
+
+import java.util.regex.Pattern;
+
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+public class CustomIntResolver extends Resolver {
+ public static final Pattern PURE_INT = Pattern.compile("^[0-9]+$");
+
+ /*
+ * do not resolve int if it has underscores
+ */
+ protected void addImplicitResolvers() {
+ addImplicitResolver(Tag.BOOL, BOOL, "yYnNtTfFoO");
+ addImplicitResolver(Tag.FLOAT, FLOAT, "-+0123456789.");
+ // define simple int pattern
+ addImplicitResolver(Tag.INT, PURE_INT, "0123456789");
+ addImplicitResolver(Tag.MERGE, MERGE, "<");
+ addImplicitResolver(Tag.NULL, NULL, "~nN\0");
+ addImplicitResolver(Tag.NULL, EMPTY, null);
+ addImplicitResolver(Tag.TIMESTAMP, TIMESTAMP, "0123456789");
+ addImplicitResolver(Tag.VALUE, VALUE, "=");
+ }
+}
diff --git a/src/test/java/examples/resolver/CustomResolver.java b/src/test/java/examples/resolver/CustomResolver.java
index bbeb3ad..407f1cc 100644
--- a/src/test/java/examples/resolver/CustomResolver.java
+++ b/src/test/java/examples/resolver/CustomResolver.java
@@ -1,37 +1,37 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.resolver;
-
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-public class CustomResolver extends Resolver {
-
- /*
- * do not resolve float and timestamp
- */
- protected void addImplicitResolvers() {
- addImplicitResolver(Tag.BOOL, BOOL, "yYnNtTfFoO");
- // addImplicitResolver(Tags.FLOAT, FLOAT, "-+0123456789.");
- addImplicitResolver(Tag.INT, INT, "-+0123456789");
- addImplicitResolver(Tag.MERGE, MERGE, "<");
- addImplicitResolver(Tag.NULL, NULL, "~nN\0");
- addImplicitResolver(Tag.NULL, EMPTY, null);
- // addImplicitResolver(Tags.TIMESTAMP, TIMESTAMP, "0123456789");
- addImplicitResolver(Tag.VALUE, VALUE, "=");
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.resolver;
+
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+public class CustomResolver extends Resolver {
+
+ /*
+ * do not resolve float and timestamp
+ */
+ protected void addImplicitResolvers() {
+ addImplicitResolver(Tag.BOOL, BOOL, "yYnNtTfFoO");
+ // addImplicitResolver(Tags.FLOAT, FLOAT, "-+0123456789.");
+ addImplicitResolver(Tag.INT, INT, "-+0123456789");
+ addImplicitResolver(Tag.MERGE, MERGE, "<");
+ addImplicitResolver(Tag.NULL, NULL, "~nN\0");
+ addImplicitResolver(Tag.NULL, EMPTY, null);
+ // addImplicitResolver(Tags.TIMESTAMP, TIMESTAMP, "0123456789");
+ addImplicitResolver(Tag.VALUE, VALUE, "=");
+ }
+}
diff --git a/src/test/java/examples/resolver/CustomResolverTest.java b/src/test/java/examples/resolver/CustomResolverTest.java
index a6fe109..3aa8473 100644
--- a/src/test/java/examples/resolver/CustomResolverTest.java
+++ b/src/test/java/examples/resolver/CustomResolverTest.java
@@ -1,57 +1,57 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.resolver;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class CustomResolverTest extends TestCase {
-
- public void testResolverToDump() {
- Map<Object, Object> map = new HashMap<Object, Object>();
- map.put("1.0", "2009-01-01");
- Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(),
- new CustomResolver());
- String output = yaml.dump(map);
- assertEquals("{1.0: 2009-01-01}\n", output);
- assertEquals("Float and Date must be escaped.", "{'1.0': '2009-01-01'}\n",
- new Yaml().dump(map));
- }
-
- @SuppressWarnings("unchecked")
- public void testResolverToLoad() {
- Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(),
- new CustomResolver());
- Map<Object, Object> map = (Map<Object, Object>) yaml.load("1.0: 2009-01-01");
- assertEquals(1, map.size());
- assertEquals("2009-01-01", map.get("1.0"));
- // the default Resolver shall create Date and Double from the same YAML
- // document
- Yaml yaml2 = new Yaml();
- Map<Object, Object> map2 = (Map<Object, Object>) yaml2.load("1.0: 2009-01-01");
- assertEquals(1, map2.size());
- assertFalse(map2.containsKey("1.0"));
- assertTrue(map2.toString(), map2.containsKey(new Double(1.0)));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.resolver;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class CustomResolverTest extends TestCase {
+
+ public void testResolverToDump() {
+ Map<Object, Object> map = new HashMap<Object, Object>();
+ map.put("1.0", "2009-01-01");
+ Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(),
+ new CustomResolver());
+ String output = yaml.dump(map);
+ assertEquals("{1.0: 2009-01-01}\n", output);
+ assertEquals("Float and Date must be escaped.", "{'1.0': '2009-01-01'}\n",
+ new Yaml().dump(map));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testResolverToLoad() {
+ Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(),
+ new CustomResolver());
+ Map<Object, Object> map = (Map<Object, Object>) yaml.load("1.0: 2009-01-01");
+ assertEquals(1, map.size());
+ assertEquals("2009-01-01", map.get("1.0"));
+ // the default Resolver shall create Date and Double from the same YAML
+ // document
+ Yaml yaml2 = new Yaml();
+ Map<Object, Object> map2 = (Map<Object, Object>) yaml2.load("1.0: 2009-01-01");
+ assertEquals(1, map2.size());
+ assertFalse(map2.containsKey("1.0"));
+ assertTrue(map2.toString(), map2.containsKey(new Double(1.0)));
+ }
+}
diff --git a/src/test/java/examples/staticstate/JavaBeanWithStaticState.java b/src/test/java/examples/staticstate/JavaBeanWithStaticState.java
index 2f11a88..b28de97 100644
--- a/src/test/java/examples/staticstate/JavaBeanWithStaticState.java
+++ b/src/test/java/examples/staticstate/JavaBeanWithStaticState.java
@@ -1,48 +1,48 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.staticstate;
-
-public class JavaBeanWithStaticState {
- private String name;
- private int age;
- public static String color;// public field
- private static String type;// private field with a getter
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public static String getType() {
- return type;
- }
-
- public static void setType(String type) {
- JavaBeanWithStaticState.type = type;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.staticstate;
+
+public class JavaBeanWithStaticState {
+ private String name;
+ private int age;
+ public static String color;// public field
+ private static String type;// private field with a getter
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public static String getType() {
+ return type;
+ }
+
+ public static void setType(String type) {
+ JavaBeanWithStaticState.type = type;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/examples/staticstate/StaticFieldsTest.java b/src/test/java/examples/staticstate/StaticFieldsTest.java
index 46b0ba4..d92012e 100644
--- a/src/test/java/examples/staticstate/StaticFieldsTest.java
+++ b/src/test/java/examples/staticstate/StaticFieldsTest.java
@@ -1,122 +1,122 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.staticstate;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.introspector.Property;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * Example with static fields
- */
-public class StaticFieldsTest extends TestCase {
- public void testAsJavaBean() {
- JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
- bean.setName("Bahrack");
- bean.setAge(-47);
- JavaBeanWithStaticState.setType("Represent");
- JavaBeanWithStaticState.color = "Black";
- Yaml yaml = new Yaml();
- String output = yaml.dump(bean);
- // System.out.println(output);
- assertEquals("!!examples.staticstate.JavaBeanWithStaticState {age: -47, name: Bahrack}\n",
- output);
- // parse back to instance
- JavaBeanWithStaticState bean2 = (JavaBeanWithStaticState) yaml.load(output);
- assertEquals(-47, bean2.getAge());
- assertEquals("Bahrack", bean2.getName());
- }
-
- public void testCustomDump() {
- JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
- bean.setName("Lui");
- bean.setAge(25);
- JavaBeanWithStaticState.setType("Represent");
- JavaBeanWithStaticState.color = "Black";
- Yaml yaml = new Yaml(new MyRepresenter(), new DumperOptions());
- String output = yaml.dump(bean);
- // System.out.println(output);
- assertEquals(
- "!!examples.staticstate.JavaBeanWithStaticState {age: 25, name: Lui, color: Black,\n type: Represent}\n",
- output);
- }
-
- public void testCustomLoad() {
- Yaml yaml = new Yaml(new MyConstructor());
- String output = "!!examples.staticstate.JavaBeanWithStaticState {age: 25, name: Lui, color: Oranje,\n type: King}\n";
- JavaBeanWithStaticState bean2 = (JavaBeanWithStaticState) yaml.load(output);
- assertEquals(25, bean2.getAge());
- assertEquals("Lui", bean2.getName());
- assertEquals("Oranje", JavaBeanWithStaticState.color);
- assertEquals("King", JavaBeanWithStaticState.getType());
- }
-
- private class MyRepresenter extends Representer {
- @Override
- protected MappingNode representJavaBean(Set<Property> properties, Object javaBean) {
- MappingNode node = super.representJavaBean(properties, javaBean);
- if (javaBean instanceof JavaBeanWithStaticState) {
- List<NodeTuple> value = node.getValue();
- value.add(new NodeTuple(representData("color"),
- representData(JavaBeanWithStaticState.color)));
- value.add(new NodeTuple(representData("type"),
- representData(JavaBeanWithStaticState.getType())));
- }
- return node;
- }
- }
-
- private class MyConstructor extends Constructor {
- protected Object constructObject(Node node) {
- if (node.getType().isAssignableFrom(JavaBeanWithStaticState.class)) {
- MappingNode beanNode = (MappingNode) node;
- List<NodeTuple> value = beanNode.getValue();
- List<NodeTuple> removed = new ArrayList<NodeTuple>();
- for (NodeTuple tuple : value) {
- ScalarNode keyNode = (ScalarNode) tuple.getKeyNode();
- if (keyNode.getValue().equals("color")) {
- ScalarNode valueNode = (ScalarNode) tuple.getValueNode();
- JavaBeanWithStaticState.color = valueNode.getValue();
- } else if (keyNode.getValue().equals("type")) {
- ScalarNode valueNode = (ScalarNode) tuple.getValueNode();
- JavaBeanWithStaticState.setType(valueNode.getValue());
- } else
- removed.add(tuple);
- }
- beanNode.setValue(removed);
- JavaBeanWithStaticState bean = (JavaBeanWithStaticState) super
- .constructObject(beanNode);
-
- return bean;
- } else {
- return super.constructObject(node);
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.staticstate;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.introspector.Property;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * Example with static fields
+ */
+public class StaticFieldsTest extends TestCase {
+ public void testAsJavaBean() {
+ JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
+ bean.setName("Bahrack");
+ bean.setAge(-47);
+ JavaBeanWithStaticState.setType("Represent");
+ JavaBeanWithStaticState.color = "Black";
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(bean);
+ // System.out.println(output);
+ assertEquals("!!examples.staticstate.JavaBeanWithStaticState {age: -47, name: Bahrack}\n",
+ output);
+ // parse back to instance
+ JavaBeanWithStaticState bean2 = (JavaBeanWithStaticState) yaml.load(output);
+ assertEquals(-47, bean2.getAge());
+ assertEquals("Bahrack", bean2.getName());
+ }
+
+ public void testCustomDump() {
+ JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
+ bean.setName("Lui");
+ bean.setAge(25);
+ JavaBeanWithStaticState.setType("Represent");
+ JavaBeanWithStaticState.color = "Black";
+ Yaml yaml = new Yaml(new MyRepresenter(), new DumperOptions());
+ String output = yaml.dump(bean);
+ // System.out.println(output);
+ assertEquals(
+ "!!examples.staticstate.JavaBeanWithStaticState {age: 25, name: Lui, color: Black,\n type: Represent}\n",
+ output);
+ }
+
+ public void testCustomLoad() {
+ Yaml yaml = new Yaml(new MyConstructor());
+ String output = "!!examples.staticstate.JavaBeanWithStaticState {age: 25, name: Lui, color: Oranje,\n type: King}\n";
+ JavaBeanWithStaticState bean2 = (JavaBeanWithStaticState) yaml.load(output);
+ assertEquals(25, bean2.getAge());
+ assertEquals("Lui", bean2.getName());
+ assertEquals("Oranje", JavaBeanWithStaticState.color);
+ assertEquals("King", JavaBeanWithStaticState.getType());
+ }
+
+ private class MyRepresenter extends Representer {
+ @Override
+ protected MappingNode representJavaBean(Set<Property> properties, Object javaBean) {
+ MappingNode node = super.representJavaBean(properties, javaBean);
+ if (javaBean instanceof JavaBeanWithStaticState) {
+ List<NodeTuple> value = node.getValue();
+ value.add(new NodeTuple(representData("color"),
+ representData(JavaBeanWithStaticState.color)));
+ value.add(new NodeTuple(representData("type"),
+ representData(JavaBeanWithStaticState.getType())));
+ }
+ return node;
+ }
+ }
+
+ private class MyConstructor extends Constructor {
+ protected Object constructObject(Node node) {
+ if (node.getType().isAssignableFrom(JavaBeanWithStaticState.class)) {
+ MappingNode beanNode = (MappingNode) node;
+ List<NodeTuple> value = beanNode.getValue();
+ List<NodeTuple> removed = new ArrayList<NodeTuple>();
+ for (NodeTuple tuple : value) {
+ ScalarNode keyNode = (ScalarNode) tuple.getKeyNode();
+ if (keyNode.getValue().equals("color")) {
+ ScalarNode valueNode = (ScalarNode) tuple.getValueNode();
+ JavaBeanWithStaticState.color = valueNode.getValue();
+ } else if (keyNode.getValue().equals("type")) {
+ ScalarNode valueNode = (ScalarNode) tuple.getValueNode();
+ JavaBeanWithStaticState.setType(valueNode.getValue());
+ } else
+ removed.add(tuple);
+ }
+ beanNode.setValue(removed);
+ JavaBeanWithStaticState bean = (JavaBeanWithStaticState) super
+ .constructObject(beanNode);
+
+ return bean;
+ } else {
+ return super.constructObject(node);
+ }
+ }
+ }
+}
diff --git a/src/test/java/examples/staticstate/StaticFieldsWrapperTest.java b/src/test/java/examples/staticstate/StaticFieldsWrapperTest.java
index e1bc63b..a790b98 100644
--- a/src/test/java/examples/staticstate/StaticFieldsWrapperTest.java
+++ b/src/test/java/examples/staticstate/StaticFieldsWrapperTest.java
@@ -1,101 +1,101 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.staticstate;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * Example: using wrapper object for static fields
- */
-public class StaticFieldsWrapperTest extends TestCase {
-
- /**
- * use wrapper with global tag
- */
- public void testWrapper() {
- JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
- bean.setName("Bahrack");
- bean.setAge(-47);
- JavaBeanWithStaticState.setType("Type3");
- JavaBeanWithStaticState.color = "Violet";
- Yaml yaml = new Yaml();
- String output = yaml.dump(new Wrapper(bean));
- // System.out.println(output);
- assertEquals(
- "!!examples.staticstate.Wrapper {age: -47, color: Violet, name: Bahrack, type: Type3}\n",
- output);
- // parse back to instance
- Wrapper wrapper = (Wrapper) yaml.load(output);
- JavaBeanWithStaticState bean2 = wrapper.createBean();
- assertEquals(-47, bean2.getAge());
- assertEquals("Bahrack", bean2.getName());
- }
-
- /**
- * use wrapper with local tag
- */
- public void testLocalTag() {
- JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
- bean.setName("Bahrack");
- bean.setAge(-47);
- JavaBeanWithStaticState.setType("Type3");
- JavaBeanWithStaticState.color = "Violet";
- Representer repr = new Representer();
- repr.addClassTag(Wrapper.class, new Tag("!mybean"));
- Yaml yaml = new Yaml(repr);
- String output = yaml.dump(new Wrapper(bean));
- // System.out.println(output);
- assertEquals("!mybean {age: -47, color: Violet, name: Bahrack, type: Type3}\n", output);
- // parse back to instance
- Constructor constr = new Constructor();
- TypeDescription description = new TypeDescription(Wrapper.class, new Tag("!mybean"));
- constr.addTypeDescription(description);
- yaml = new Yaml(constr);
- Wrapper wrapper = (Wrapper) yaml.load(output);
- JavaBeanWithStaticState bean2 = wrapper.createBean();
- assertEquals(-47, bean2.getAge());
- assertEquals("Bahrack", bean2.getName());
- }
-
- /**
- * use wrapper with no tag
- */
- public void testRootBean() {
- JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
- bean.setName("Bahrack");
- bean.setAge(-47);
- JavaBeanWithStaticState.setType("Type3");
- JavaBeanWithStaticState.color = "Violet";
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(new Wrapper(bean));
- // System.out.println(output);
- assertEquals("age: -47\ncolor: Violet\nname: Bahrack\ntype: Type3\n", output);
- // parse back to instance
- Yaml loader = new Yaml();
- Wrapper wrapper = loader.loadAs(output, Wrapper.class);
- JavaBeanWithStaticState bean2 = wrapper.createBean();
- assertEquals(-47, bean2.getAge());
- assertEquals("Bahrack", bean2.getName());
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.staticstate;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * Example: using wrapper object for static fields
+ */
+public class StaticFieldsWrapperTest extends TestCase {
+
+ /**
+ * use wrapper with global tag
+ */
+ public void testWrapper() {
+ JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
+ bean.setName("Bahrack");
+ bean.setAge(-47);
+ JavaBeanWithStaticState.setType("Type3");
+ JavaBeanWithStaticState.color = "Violet";
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(new Wrapper(bean));
+ // System.out.println(output);
+ assertEquals(
+ "!!examples.staticstate.Wrapper {age: -47, color: Violet, name: Bahrack, type: Type3}\n",
+ output);
+ // parse back to instance
+ Wrapper wrapper = (Wrapper) yaml.load(output);
+ JavaBeanWithStaticState bean2 = wrapper.createBean();
+ assertEquals(-47, bean2.getAge());
+ assertEquals("Bahrack", bean2.getName());
+ }
+
+ /**
+ * use wrapper with local tag
+ */
+ public void testLocalTag() {
+ JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
+ bean.setName("Bahrack");
+ bean.setAge(-47);
+ JavaBeanWithStaticState.setType("Type3");
+ JavaBeanWithStaticState.color = "Violet";
+ Representer repr = new Representer();
+ repr.addClassTag(Wrapper.class, new Tag("!mybean"));
+ Yaml yaml = new Yaml(repr);
+ String output = yaml.dump(new Wrapper(bean));
+ // System.out.println(output);
+ assertEquals("!mybean {age: -47, color: Violet, name: Bahrack, type: Type3}\n", output);
+ // parse back to instance
+ Constructor constr = new Constructor();
+ TypeDescription description = new TypeDescription(Wrapper.class, new Tag("!mybean"));
+ constr.addTypeDescription(description);
+ yaml = new Yaml(constr);
+ Wrapper wrapper = (Wrapper) yaml.load(output);
+ JavaBeanWithStaticState bean2 = wrapper.createBean();
+ assertEquals(-47, bean2.getAge());
+ assertEquals("Bahrack", bean2.getName());
+ }
+
+ /**
+ * use wrapper with no tag
+ */
+ public void testRootBean() {
+ JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
+ bean.setName("Bahrack");
+ bean.setAge(-47);
+ JavaBeanWithStaticState.setType("Type3");
+ JavaBeanWithStaticState.color = "Violet";
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(new Wrapper(bean));
+ // System.out.println(output);
+ assertEquals("age: -47\ncolor: Violet\nname: Bahrack\ntype: Type3\n", output);
+ // parse back to instance
+ Yaml loader = new Yaml();
+ Wrapper wrapper = loader.loadAs(output, Wrapper.class);
+ JavaBeanWithStaticState bean2 = wrapper.createBean();
+ assertEquals(-47, bean2.getAge());
+ assertEquals("Bahrack", bean2.getName());
+ }
+
+}
diff --git a/src/test/java/examples/staticstate/Wrapper.java b/src/test/java/examples/staticstate/Wrapper.java
index e3721b0..51beab9 100644
--- a/src/test/java/examples/staticstate/Wrapper.java
+++ b/src/test/java/examples/staticstate/Wrapper.java
@@ -1,76 +1,76 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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 examples.staticstate;
-
-public class Wrapper {
- private String name;
- private int age;
- private String color;
- private String type;
-
- public JavaBeanWithStaticState createBean() {
- JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
- bean.setAge(age);
- bean.setName(name);
- JavaBeanWithStaticState.color = color;
- JavaBeanWithStaticState.setType(type);
- return bean;
- }
-
- public Wrapper() {
- color = JavaBeanWithStaticState.color;
- type = JavaBeanWithStaticState.getType();
- }
-
- public Wrapper(JavaBeanWithStaticState bean) {
- this();
- name = bean.getName();
- age = bean.getAge();
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- public String getColor() {
- return color;
- }
-
- public void setColor(String color) {
- this.color = color;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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 examples.staticstate;
+
+public class Wrapper {
+ private String name;
+ private int age;
+ private String color;
+ private String type;
+
+ public JavaBeanWithStaticState createBean() {
+ JavaBeanWithStaticState bean = new JavaBeanWithStaticState();
+ bean.setAge(age);
+ bean.setName(name);
+ JavaBeanWithStaticState.color = color;
+ JavaBeanWithStaticState.setType(type);
+ return bean;
+ }
+
+ public Wrapper() {
+ color = JavaBeanWithStaticState.color;
+ type = JavaBeanWithStaticState.getType();
+ }
+
+ public Wrapper(JavaBeanWithStaticState bean) {
+ this();
+ name = bean.getName();
+ age = bean.getAge();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/pyyaml/AnInstance.java b/src/test/java/org/pyyaml/AnInstance.java
index 863434b..4fe4db8 100644
--- a/src/test/java/org/pyyaml/AnInstance.java
+++ b/src/test/java/org/pyyaml/AnInstance.java
@@ -1,46 +1,46 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-public class AnInstance {
- private Object foo;
- private Object bar;
-
- public AnInstance() {
- }
-
- public AnInstance(Object foo, Object bar) {
- this.foo = foo;
- this.bar = bar;
- }
-
- public Object getFoo() {
- return foo;
- }
-
- public void setFoo(Object foo) {
- this.foo = foo;
- }
-
- public Object getBar() {
- return bar;
- }
-
- public void setBar(Object bar) {
- this.bar = bar;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+public class AnInstance {
+ private Object foo;
+ private Object bar;
+
+ public AnInstance() {
+ }
+
+ public AnInstance(Object foo, Object bar) {
+ this.foo = foo;
+ this.bar = bar;
+ }
+
+ public Object getFoo() {
+ return foo;
+ }
+
+ public void setFoo(Object foo) {
+ this.foo = foo;
+ }
+
+ public Object getBar() {
+ return bar;
+ }
+
+ public void setBar(Object bar) {
+ this.bar = bar;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/pyyaml/CanonicalException.java b/src/test/java/org/pyyaml/CanonicalException.java
index 06239f3..06b7c5a 100644
--- a/src/test/java/org/pyyaml/CanonicalException.java
+++ b/src/test/java/org/pyyaml/CanonicalException.java
@@ -1,32 +1,32 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import org.yaml.snakeyaml.error.YAMLException;
-
-public class CanonicalException extends YAMLException {
-
- private static final long serialVersionUID = -6489045150083747626L;
-
- public CanonicalException(String message) {
- super(message);
- }
-
- public CanonicalException(Throwable cause) {
- super(cause);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class CanonicalException extends YAMLException {
+
+ private static final long serialVersionUID = -6489045150083747626L;
+
+ public CanonicalException(String message) {
+ super(message);
+ }
+
+ public CanonicalException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/src/test/java/org/pyyaml/CanonicalLoader.java b/src/test/java/org/pyyaml/CanonicalLoader.java
index b96cf80..83f069b 100644
--- a/src/test/java/org/pyyaml/CanonicalLoader.java
+++ b/src/test/java/org/pyyaml/CanonicalLoader.java
@@ -1,86 +1,86 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.Iterator;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.composer.Composer;
-import org.yaml.snakeyaml.error.YAMLException;
-
-public class CanonicalLoader extends Yaml {
- @Override
- public Object load(Reader yaml) {
- try {
- int ch = yaml.read();
- StringBuilder buffer = new StringBuilder();
- while (ch != -1) {
- buffer.append((char) ch);
- ch = yaml.read();
- }
- Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
- constructor.setComposer(composer);
- return constructor.getSingleData(Object.class);
- } catch (IOException e) {
- throw new YAMLException(e);
- }
- }
-
- public Iterable<Object> loadAll(Reader yaml) {
- try {
- int ch = yaml.read();
- StringBuilder buffer = new StringBuilder();
- while (ch != -1) {
- buffer.append((char) ch);
- ch = yaml.read();
- }
- Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
- this.constructor.setComposer(composer);
- Iterator<Object> result = new Iterator<Object>() {
- public boolean hasNext() {
- return constructor.checkData();
- }
-
- public Object next() {
- return constructor.getData();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- return new YamlIterable(result);
- } catch (IOException e) {
- throw new YAMLException(e);
- }
- }
-
- private class YamlIterable implements Iterable<Object> {
- private Iterator<Object> iterator;
-
- public YamlIterable(Iterator<Object> iterator) {
- this.iterator = iterator;
- }
-
- public Iterator<Object> iterator() {
- return iterator;
- }
-
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.Iterator;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.composer.Composer;
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class CanonicalLoader extends Yaml {
+ @Override
+ public Object load(Reader yaml) {
+ try {
+ int ch = yaml.read();
+ StringBuilder buffer = new StringBuilder();
+ while (ch != -1) {
+ buffer.append((char) ch);
+ ch = yaml.read();
+ }
+ Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
+ constructor.setComposer(composer);
+ return constructor.getSingleData(Object.class);
+ } catch (IOException e) {
+ throw new YAMLException(e);
+ }
+ }
+
+ public Iterable<Object> loadAll(Reader yaml) {
+ try {
+ int ch = yaml.read();
+ StringBuilder buffer = new StringBuilder();
+ while (ch != -1) {
+ buffer.append((char) ch);
+ ch = yaml.read();
+ }
+ Composer composer = new Composer(new CanonicalParser(buffer.toString()), resolver);
+ this.constructor.setComposer(composer);
+ Iterator<Object> result = new Iterator<Object>() {
+ public boolean hasNext() {
+ return constructor.checkData();
+ }
+
+ public Object next() {
+ return constructor.getData();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ return new YamlIterable(result);
+ } catch (IOException e) {
+ throw new YAMLException(e);
+ }
+ }
+
+ private class YamlIterable implements Iterable<Object> {
+ private Iterator<Object> iterator;
+
+ public YamlIterable(Iterator<Object> iterator) {
+ this.iterator = iterator;
+ }
+
+ public Iterator<Object> iterator() {
+ return iterator;
+ }
+
+ }
+}
diff --git a/src/test/java/org/pyyaml/CanonicalParser.java b/src/test/java/org/pyyaml/CanonicalParser.java
index 6fd8f7f..046aebd 100644
--- a/src/test/java/org/pyyaml/CanonicalParser.java
+++ b/src/test/java/org/pyyaml/CanonicalParser.java
@@ -1,190 +1,190 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.util.ArrayList;
-
-import org.yaml.snakeyaml.events.AliasEvent;
-import org.yaml.snakeyaml.events.DocumentEndEvent;
-import org.yaml.snakeyaml.events.DocumentStartEvent;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.ImplicitTuple;
-import org.yaml.snakeyaml.events.MappingEndEvent;
-import org.yaml.snakeyaml.events.MappingStartEvent;
-import org.yaml.snakeyaml.events.ScalarEvent;
-import org.yaml.snakeyaml.events.SequenceEndEvent;
-import org.yaml.snakeyaml.events.SequenceStartEvent;
-import org.yaml.snakeyaml.events.StreamEndEvent;
-import org.yaml.snakeyaml.events.StreamStartEvent;
-import org.yaml.snakeyaml.parser.Parser;
-import org.yaml.snakeyaml.tokens.AliasToken;
-import org.yaml.snakeyaml.tokens.AnchorToken;
-import org.yaml.snakeyaml.tokens.ScalarToken;
-import org.yaml.snakeyaml.tokens.TagToken;
-import org.yaml.snakeyaml.tokens.Token;
-
-public class CanonicalParser implements Parser {
- private ArrayList<Event> events;
- private boolean parsed;
- private CanonicalScanner scanner;
-
- public CanonicalParser(String data) {
- events = new ArrayList<Event>();
- parsed = false;
- scanner = new CanonicalScanner(data);
- }
-
- // stream: STREAM-START document* STREAM-END
- private void parseStream() {
- scanner.getToken(Token.ID.StreamStart);
- events.add(new StreamStartEvent(null, null));
- while (!scanner.checkToken(Token.ID.StreamEnd)) {
- if (scanner.checkToken(Token.ID.Directive, Token.ID.DocumentStart)) {
- parseDocument();
- } else {
- throw new CanonicalException("document is expected, got " + scanner.tokens.get(0));
- }
- }
- scanner.getToken(Token.ID.StreamEnd);
- events.add(new StreamEndEvent(null, null));
- }
-
- // document: DIRECTIVE? DOCUMENT-START node
- private void parseDocument() {
- if (scanner.checkToken(Token.ID.Directive)) {
- scanner.getToken(Token.ID.Directive);
- }
- scanner.getToken(Token.ID.DocumentStart);
- events.add(new DocumentStartEvent(null, null, true, new Integer[] { 1, 1 }, null));
- parseNode();
- events.add(new DocumentEndEvent(null, null, true));
- }
-
- // node: ALIAS | ANCHOR? TAG? (SCALAR|sequence|mapping)
- private void parseNode() {
- if (scanner.checkToken(Token.ID.Alias)) {
- AliasToken token = (AliasToken) scanner.getToken();
- events.add(new AliasEvent(token.getValue(), null, null));
- } else {
- String anchor = null;
- if (scanner.checkToken(Token.ID.Anchor)) {
- AnchorToken token = (AnchorToken) scanner.getToken();
- anchor = token.getValue();
- }
- String tag = null;
- if (scanner.checkToken(Token.ID.Tag)) {
- TagToken token = (TagToken) scanner.getToken();
- tag = token.getValue().getHandle() + token.getValue().getSuffix();
- }
- if (scanner.checkToken(Token.ID.Scalar)) {
- ScalarToken token = (ScalarToken) scanner.getToken();
- events.add(new ScalarEvent(anchor, tag, new ImplicitTuple(false, false), token
- .getValue(), null, null, null));
- } else if (scanner.checkToken(Token.ID.FlowSequenceStart)) {
- events.add(new SequenceStartEvent(anchor, tag, false, null, null, null));
- parseSequence();
- } else if (scanner.checkToken(Token.ID.FlowMappingStart)) {
- events.add(new MappingStartEvent(anchor, tag, false, null, null, null));
- parseMapping();
- } else {
- throw new CanonicalException("SCALAR, '[', or '{' is expected, got "
- + scanner.tokens.get(0));
- }
- }
- }
-
- // sequence: SEQUENCE-START (node (ENTRY node)*)? ENTRY? SEQUENCE-END
- private void parseSequence() {
- scanner.getToken(Token.ID.FlowSequenceStart);
- if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
- parseNode();
- while (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
- scanner.getToken(Token.ID.FlowEntry);
- if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
- parseNode();
- }
- }
- }
- scanner.getToken(Token.ID.FlowSequenceEnd);
- events.add(new SequenceEndEvent(null, null));
- }
-
- // mapping: MAPPING-START (map_entry (ENTRY map_entry)*)? ENTRY? MAPPING-END
- private void parseMapping() {
- scanner.getToken(Token.ID.FlowMappingStart);
- if (!scanner.checkToken(Token.ID.FlowMappingEnd)) {
- parseMapEntry();
- while (!scanner.checkToken(Token.ID.FlowMappingEnd)) {
- scanner.getToken(Token.ID.FlowEntry);
- if (!scanner.checkToken(Token.ID.FlowMappingEnd)) {
- parseMapEntry();
- }
- }
- }
- scanner.getToken(Token.ID.FlowMappingEnd);
- events.add(new MappingEndEvent(null, null));
- }
-
- // map_entry: KEY node VALUE node
- private void parseMapEntry() {
- scanner.getToken(Token.ID.Key);
- parseNode();
- scanner.getToken(Token.ID.Value);
- parseNode();
- }
-
- public void parse() {
- parseStream();
- parsed = true;
- }
-
- public Event getEvent() {
- if (!parsed) {
- parse();
- }
- return events.remove(0);
- }
-
- /**
- * Check the type of the next event.
- */
- public boolean checkEvent(Event.ID choice) {
- if (!parsed) {
- parse();
- }
- if (!events.isEmpty()) {
- if (events.get(0).is(choice)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Get the next event.
- */
- public Event peekEvent() {
- if (!parsed) {
- parse();
- }
- if (events.isEmpty()) {
- return null;
- } else {
- return events.get(0);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.util.ArrayList;
+
+import org.yaml.snakeyaml.events.AliasEvent;
+import org.yaml.snakeyaml.events.DocumentEndEvent;
+import org.yaml.snakeyaml.events.DocumentStartEvent;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.ImplicitTuple;
+import org.yaml.snakeyaml.events.MappingEndEvent;
+import org.yaml.snakeyaml.events.MappingStartEvent;
+import org.yaml.snakeyaml.events.ScalarEvent;
+import org.yaml.snakeyaml.events.SequenceEndEvent;
+import org.yaml.snakeyaml.events.SequenceStartEvent;
+import org.yaml.snakeyaml.events.StreamEndEvent;
+import org.yaml.snakeyaml.events.StreamStartEvent;
+import org.yaml.snakeyaml.parser.Parser;
+import org.yaml.snakeyaml.tokens.AliasToken;
+import org.yaml.snakeyaml.tokens.AnchorToken;
+import org.yaml.snakeyaml.tokens.ScalarToken;
+import org.yaml.snakeyaml.tokens.TagToken;
+import org.yaml.snakeyaml.tokens.Token;
+
+public class CanonicalParser implements Parser {
+ private ArrayList<Event> events;
+ private boolean parsed;
+ private CanonicalScanner scanner;
+
+ public CanonicalParser(String data) {
+ events = new ArrayList<Event>();
+ parsed = false;
+ scanner = new CanonicalScanner(data);
+ }
+
+ // stream: STREAM-START document* STREAM-END
+ private void parseStream() {
+ scanner.getToken(Token.ID.StreamStart);
+ events.add(new StreamStartEvent(null, null));
+ while (!scanner.checkToken(Token.ID.StreamEnd)) {
+ if (scanner.checkToken(Token.ID.Directive, Token.ID.DocumentStart)) {
+ parseDocument();
+ } else {
+ throw new CanonicalException("document is expected, got " + scanner.tokens.get(0));
+ }
+ }
+ scanner.getToken(Token.ID.StreamEnd);
+ events.add(new StreamEndEvent(null, null));
+ }
+
+ // document: DIRECTIVE? DOCUMENT-START node
+ private void parseDocument() {
+ if (scanner.checkToken(Token.ID.Directive)) {
+ scanner.getToken(Token.ID.Directive);
+ }
+ scanner.getToken(Token.ID.DocumentStart);
+ events.add(new DocumentStartEvent(null, null, true, new Integer[] { 1, 1 }, null));
+ parseNode();
+ events.add(new DocumentEndEvent(null, null, true));
+ }
+
+ // node: ALIAS | ANCHOR? TAG? (SCALAR|sequence|mapping)
+ private void parseNode() {
+ if (scanner.checkToken(Token.ID.Alias)) {
+ AliasToken token = (AliasToken) scanner.getToken();
+ events.add(new AliasEvent(token.getValue(), null, null));
+ } else {
+ String anchor = null;
+ if (scanner.checkToken(Token.ID.Anchor)) {
+ AnchorToken token = (AnchorToken) scanner.getToken();
+ anchor = token.getValue();
+ }
+ String tag = null;
+ if (scanner.checkToken(Token.ID.Tag)) {
+ TagToken token = (TagToken) scanner.getToken();
+ tag = token.getValue().getHandle() + token.getValue().getSuffix();
+ }
+ if (scanner.checkToken(Token.ID.Scalar)) {
+ ScalarToken token = (ScalarToken) scanner.getToken();
+ events.add(new ScalarEvent(anchor, tag, new ImplicitTuple(false, false), token
+ .getValue(), null, null, null));
+ } else if (scanner.checkToken(Token.ID.FlowSequenceStart)) {
+ events.add(new SequenceStartEvent(anchor, tag, false, null, null, null));
+ parseSequence();
+ } else if (scanner.checkToken(Token.ID.FlowMappingStart)) {
+ events.add(new MappingStartEvent(anchor, tag, false, null, null, null));
+ parseMapping();
+ } else {
+ throw new CanonicalException("SCALAR, '[', or '{' is expected, got "
+ + scanner.tokens.get(0));
+ }
+ }
+ }
+
+ // sequence: SEQUENCE-START (node (ENTRY node)*)? ENTRY? SEQUENCE-END
+ private void parseSequence() {
+ scanner.getToken(Token.ID.FlowSequenceStart);
+ if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
+ parseNode();
+ while (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
+ scanner.getToken(Token.ID.FlowEntry);
+ if (!scanner.checkToken(Token.ID.FlowSequenceEnd)) {
+ parseNode();
+ }
+ }
+ }
+ scanner.getToken(Token.ID.FlowSequenceEnd);
+ events.add(new SequenceEndEvent(null, null));
+ }
+
+ // mapping: MAPPING-START (map_entry (ENTRY map_entry)*)? ENTRY? MAPPING-END
+ private void parseMapping() {
+ scanner.getToken(Token.ID.FlowMappingStart);
+ if (!scanner.checkToken(Token.ID.FlowMappingEnd)) {
+ parseMapEntry();
+ while (!scanner.checkToken(Token.ID.FlowMappingEnd)) {
+ scanner.getToken(Token.ID.FlowEntry);
+ if (!scanner.checkToken(Token.ID.FlowMappingEnd)) {
+ parseMapEntry();
+ }
+ }
+ }
+ scanner.getToken(Token.ID.FlowMappingEnd);
+ events.add(new MappingEndEvent(null, null));
+ }
+
+ // map_entry: KEY node VALUE node
+ private void parseMapEntry() {
+ scanner.getToken(Token.ID.Key);
+ parseNode();
+ scanner.getToken(Token.ID.Value);
+ parseNode();
+ }
+
+ public void parse() {
+ parseStream();
+ parsed = true;
+ }
+
+ public Event getEvent() {
+ if (!parsed) {
+ parse();
+ }
+ return events.remove(0);
+ }
+
+ /**
+ * Check the type of the next event.
+ */
+ public boolean checkEvent(Event.ID choice) {
+ if (!parsed) {
+ parse();
+ }
+ if (!events.isEmpty()) {
+ if (events.get(0).is(choice)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the next event.
+ */
+ public Event peekEvent() {
+ if (!parsed) {
+ parse();
+ }
+ if (events.isEmpty()) {
+ return null;
+ } else {
+ return events.get(0);
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/CanonicalScanner.java b/src/test/java/org/pyyaml/CanonicalScanner.java
index f6f06a7..d93fc63 100644
--- a/src/test/java/org/pyyaml/CanonicalScanner.java
+++ b/src/test/java/org/pyyaml/CanonicalScanner.java
@@ -1,307 +1,307 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.scanner.Scanner;
-import org.yaml.snakeyaml.scanner.ScannerImpl;
-import org.yaml.snakeyaml.tokens.AliasToken;
-import org.yaml.snakeyaml.tokens.AnchorToken;
-import org.yaml.snakeyaml.tokens.DirectiveToken;
-import org.yaml.snakeyaml.tokens.DocumentStartToken;
-import org.yaml.snakeyaml.tokens.FlowEntryToken;
-import org.yaml.snakeyaml.tokens.FlowMappingEndToken;
-import org.yaml.snakeyaml.tokens.FlowMappingStartToken;
-import org.yaml.snakeyaml.tokens.FlowSequenceEndToken;
-import org.yaml.snakeyaml.tokens.FlowSequenceStartToken;
-import org.yaml.snakeyaml.tokens.KeyToken;
-import org.yaml.snakeyaml.tokens.ScalarToken;
-import org.yaml.snakeyaml.tokens.StreamEndToken;
-import org.yaml.snakeyaml.tokens.StreamStartToken;
-import org.yaml.snakeyaml.tokens.TagToken;
-import org.yaml.snakeyaml.tokens.TagTuple;
-import org.yaml.snakeyaml.tokens.Token;
-import org.yaml.snakeyaml.tokens.ValueToken;
-
-public class CanonicalScanner implements Scanner {
- private static final String DIRECTIVE = "%YAML 1.1";
- private final static Map<Character, Integer> QUOTE_CODES = ScannerImpl.ESCAPE_CODES;
-
- private final static Map<Character, String> QUOTE_REPLACES = ScannerImpl.ESCAPE_REPLACEMENTS;
-
- private String data;
- private int index;
- public ArrayList<Token> tokens;
- private boolean scanned;
- private Mark mark;
-
- public CanonicalScanner(String data) {
- this.data = data + "\0";
- this.index = 0;
- this.tokens = new ArrayList<Token>();
- this.scanned = false;
- this.mark = new Mark("test", 0, 0, 0, data, 0);
- }
-
- public boolean checkToken(Token.ID... choices) {
- if (!scanned) {
- scan();
- }
- if (!tokens.isEmpty()) {
- if (choices.length == 0) {
- return true;
- }
- Token first = this.tokens.get(0);
- for (Token.ID choice : choices) {
- if (first.getTokenId() == choice) {
- return true;
- }
- }
- }
- return false;
- }
-
- public Token peekToken() {
- if (!scanned) {
- scan();
- }
- if (!tokens.isEmpty()) {
- return this.tokens.get(0);
- }
- return null;
- }
-
- public Token getToken() {
- if (!scanned) {
- scan();
- }
- return this.tokens.remove(0);
- }
-
- public Token getToken(Token.ID choice) {
- Token token = getToken();
- if (choice != null && token.getTokenId() != choice) {
- throw new CanonicalException("unexpected token " + token);
- }
- return token;
- }
-
- private void scan() {
- this.tokens.add(new StreamStartToken(mark, mark));
- boolean stop = false;
- while (!stop) {
- findToken();
- char ch = data.charAt(index);
- switch (ch) {
- case '\0':
- tokens.add(new StreamEndToken(mark, mark));
- stop = true;
- break;
-
- case '%':
- tokens.add(scanDirective());
- break;
-
- case '-':
- if ("---".equals(data.substring(index, index + 3))) {
- index += 3;
- tokens.add(new DocumentStartToken(mark, mark));
- }
- break;
-
- case '[':
- index++;
- tokens.add(new FlowSequenceStartToken(mark, mark));
- break;
-
- case '{':
- index++;
- tokens.add(new FlowMappingStartToken(mark, mark));
- break;
-
- case ']':
- index++;
- tokens.add(new FlowSequenceEndToken(mark, mark));
- break;
-
- case '}':
- index++;
- tokens.add(new FlowMappingEndToken(mark, mark));
- break;
-
- case '?':
- index++;
- tokens.add(new KeyToken(mark, mark));
- break;
-
- case ':':
- index++;
- tokens.add(new ValueToken(mark, mark));
- break;
-
- case ',':
- index++;
- tokens.add(new FlowEntryToken(mark, mark));
- break;
-
- case '*':
- tokens.add(scanAlias());
- break;
-
- case '&':
- tokens.add(scanAlias());
- break;
-
- case '!':
- tokens.add(scanTag());
- break;
-
- case '"':
- tokens.add(scanScalar());
- break;
-
- default:
- throw new CanonicalException("invalid token");
- }
- }
- scanned = true;
- }
-
- private Token scanDirective() {
- String chunk1 = data.substring(index, index + DIRECTIVE.length());
- char chunk2 = data.charAt(index + DIRECTIVE.length());
- if (DIRECTIVE.equals(chunk1) && "\n\0".indexOf(chunk2) != -1) {
- index += DIRECTIVE.length();
- List<Integer> implicit = new ArrayList<Integer>(2);
- implicit.add(new Integer(1));
- implicit.add(new Integer(1));
- return new DirectiveToken<Integer>("YAML", implicit, mark, mark);
- } else {
- throw new CanonicalException("invalid directive");
- }
- }
-
- private Token scanAlias() {
- boolean isTokenClassAlias;
- if (data.charAt(index) == '*') {
- isTokenClassAlias = true;
- } else {
- isTokenClassAlias = false;
- }
- index++;
- int start = index;
- while (", \n\0".indexOf(data.charAt(index)) == -1) {
- index++;
- }
- String value = data.substring(start, index);
- Token token;
- if (isTokenClassAlias) {
- token = new AliasToken(value, mark, mark);
- } else {
- token = new AnchorToken(value, mark, mark);
- }
- return token;
- }
-
- private Token scanTag() {
- index++;
- int start = index;
- while (" \n\0".indexOf(data.charAt(index)) == -1) {
- index++;
- }
- String value = data.substring(start, index);
- if (value.length() == 0) {
- value = "!";
- } else if (value.charAt(0) == '!') {
- value = Tag.PREFIX + value.substring(1);
- } else if (value.charAt(0) == '<' && value.charAt(value.length() - 1) == '>') {
- value = value.substring(1, value.length() - 1);
- } else {
- value = "!" + value;
- }
- return new TagToken(new TagTuple("", value), mark, mark);
- }
-
- private Token scanScalar() {
- index++;
- StringBuilder chunks = new StringBuilder();
- int start = index;
- boolean ignoreSpaces = false;
- while (data.charAt(index) != '"') {
- if (data.charAt(index) == '\\') {
- ignoreSpaces = false;
- chunks.append(data.substring(start, index));
- index++;
- char ch = data.charAt(index);
- index++;
- if (ch == '\n') {
- ignoreSpaces = true;
- } else if (QUOTE_CODES.keySet().contains(ch)) {
- int length = QUOTE_CODES.get(ch);
- int code = Integer.parseInt(data.substring(index, index + length), 16);
- chunks.append(String.valueOf((char) code));
- index += length;
- } else {
- if (!QUOTE_REPLACES.keySet().contains(ch)) {
- throw new CanonicalException("invalid escape code");
- }
- chunks.append(QUOTE_REPLACES.get(ch));
- }
- start = index;
- } else if (data.charAt(index) == '\n') {
- chunks.append(data.substring(start, index));
- chunks.append(" ");
- index++;
- start = index;
- ignoreSpaces = true;
- } else if (ignoreSpaces && data.charAt(index) == ' ') {
- index++;
- start = index;
- } else {
- ignoreSpaces = false;
- index++;
- }
- }
- chunks.append(data.substring(start, index));
- index++;
- return new ScalarToken(chunks.toString(), mark, mark, false);
- }
-
- private void findToken() {
- boolean found = false;
- while (!found) {
- while (" \t".indexOf(data.charAt(index)) != -1) {
- index++;
- }
- if (data.charAt(index) == '#') {
- while (data.charAt(index) != '\n') {
- index++;
- }
- }
- if (data.charAt(index) == '\n') {
- index++;
- } else {
- found = true;
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.scanner.Scanner;
+import org.yaml.snakeyaml.scanner.ScannerImpl;
+import org.yaml.snakeyaml.tokens.AliasToken;
+import org.yaml.snakeyaml.tokens.AnchorToken;
+import org.yaml.snakeyaml.tokens.DirectiveToken;
+import org.yaml.snakeyaml.tokens.DocumentStartToken;
+import org.yaml.snakeyaml.tokens.FlowEntryToken;
+import org.yaml.snakeyaml.tokens.FlowMappingEndToken;
+import org.yaml.snakeyaml.tokens.FlowMappingStartToken;
+import org.yaml.snakeyaml.tokens.FlowSequenceEndToken;
+import org.yaml.snakeyaml.tokens.FlowSequenceStartToken;
+import org.yaml.snakeyaml.tokens.KeyToken;
+import org.yaml.snakeyaml.tokens.ScalarToken;
+import org.yaml.snakeyaml.tokens.StreamEndToken;
+import org.yaml.snakeyaml.tokens.StreamStartToken;
+import org.yaml.snakeyaml.tokens.TagToken;
+import org.yaml.snakeyaml.tokens.TagTuple;
+import org.yaml.snakeyaml.tokens.Token;
+import org.yaml.snakeyaml.tokens.ValueToken;
+
+public class CanonicalScanner implements Scanner {
+ private static final String DIRECTIVE = "%YAML 1.1";
+ private final static Map<Character, Integer> QUOTE_CODES = ScannerImpl.ESCAPE_CODES;
+
+ private final static Map<Character, String> QUOTE_REPLACES = ScannerImpl.ESCAPE_REPLACEMENTS;
+
+ private String data;
+ private int index;
+ public ArrayList<Token> tokens;
+ private boolean scanned;
+ private Mark mark;
+
+ public CanonicalScanner(String data) {
+ this.data = data + "\0";
+ this.index = 0;
+ this.tokens = new ArrayList<Token>();
+ this.scanned = false;
+ this.mark = new Mark("test", 0, 0, 0, data, 0);
+ }
+
+ public boolean checkToken(Token.ID... choices) {
+ if (!scanned) {
+ scan();
+ }
+ if (!tokens.isEmpty()) {
+ if (choices.length == 0) {
+ return true;
+ }
+ Token first = this.tokens.get(0);
+ for (Token.ID choice : choices) {
+ if (first.getTokenId() == choice) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public Token peekToken() {
+ if (!scanned) {
+ scan();
+ }
+ if (!tokens.isEmpty()) {
+ return this.tokens.get(0);
+ }
+ return null;
+ }
+
+ public Token getToken() {
+ if (!scanned) {
+ scan();
+ }
+ return this.tokens.remove(0);
+ }
+
+ public Token getToken(Token.ID choice) {
+ Token token = getToken();
+ if (choice != null && token.getTokenId() != choice) {
+ throw new CanonicalException("unexpected token " + token);
+ }
+ return token;
+ }
+
+ private void scan() {
+ this.tokens.add(new StreamStartToken(mark, mark));
+ boolean stop = false;
+ while (!stop) {
+ findToken();
+ char ch = data.charAt(index);
+ switch (ch) {
+ case '\0':
+ tokens.add(new StreamEndToken(mark, mark));
+ stop = true;
+ break;
+
+ case '%':
+ tokens.add(scanDirective());
+ break;
+
+ case '-':
+ if ("---".equals(data.substring(index, index + 3))) {
+ index += 3;
+ tokens.add(new DocumentStartToken(mark, mark));
+ }
+ break;
+
+ case '[':
+ index++;
+ tokens.add(new FlowSequenceStartToken(mark, mark));
+ break;
+
+ case '{':
+ index++;
+ tokens.add(new FlowMappingStartToken(mark, mark));
+ break;
+
+ case ']':
+ index++;
+ tokens.add(new FlowSequenceEndToken(mark, mark));
+ break;
+
+ case '}':
+ index++;
+ tokens.add(new FlowMappingEndToken(mark, mark));
+ break;
+
+ case '?':
+ index++;
+ tokens.add(new KeyToken(mark, mark));
+ break;
+
+ case ':':
+ index++;
+ tokens.add(new ValueToken(mark, mark));
+ break;
+
+ case ',':
+ index++;
+ tokens.add(new FlowEntryToken(mark, mark));
+ break;
+
+ case '*':
+ tokens.add(scanAlias());
+ break;
+
+ case '&':
+ tokens.add(scanAlias());
+ break;
+
+ case '!':
+ tokens.add(scanTag());
+ break;
+
+ case '"':
+ tokens.add(scanScalar());
+ break;
+
+ default:
+ throw new CanonicalException("invalid token");
+ }
+ }
+ scanned = true;
+ }
+
+ private Token scanDirective() {
+ String chunk1 = data.substring(index, index + DIRECTIVE.length());
+ char chunk2 = data.charAt(index + DIRECTIVE.length());
+ if (DIRECTIVE.equals(chunk1) && "\n\0".indexOf(chunk2) != -1) {
+ index += DIRECTIVE.length();
+ List<Integer> implicit = new ArrayList<Integer>(2);
+ implicit.add(new Integer(1));
+ implicit.add(new Integer(1));
+ return new DirectiveToken<Integer>("YAML", implicit, mark, mark);
+ } else {
+ throw new CanonicalException("invalid directive");
+ }
+ }
+
+ private Token scanAlias() {
+ boolean isTokenClassAlias;
+ if (data.charAt(index) == '*') {
+ isTokenClassAlias = true;
+ } else {
+ isTokenClassAlias = false;
+ }
+ index++;
+ int start = index;
+ while (", \n\0".indexOf(data.charAt(index)) == -1) {
+ index++;
+ }
+ String value = data.substring(start, index);
+ Token token;
+ if (isTokenClassAlias) {
+ token = new AliasToken(value, mark, mark);
+ } else {
+ token = new AnchorToken(value, mark, mark);
+ }
+ return token;
+ }
+
+ private Token scanTag() {
+ index++;
+ int start = index;
+ while (" \n\0".indexOf(data.charAt(index)) == -1) {
+ index++;
+ }
+ String value = data.substring(start, index);
+ if (value.length() == 0) {
+ value = "!";
+ } else if (value.charAt(0) == '!') {
+ value = Tag.PREFIX + value.substring(1);
+ } else if (value.charAt(0) == '<' && value.charAt(value.length() - 1) == '>') {
+ value = value.substring(1, value.length() - 1);
+ } else {
+ value = "!" + value;
+ }
+ return new TagToken(new TagTuple("", value), mark, mark);
+ }
+
+ private Token scanScalar() {
+ index++;
+ StringBuilder chunks = new StringBuilder();
+ int start = index;
+ boolean ignoreSpaces = false;
+ while (data.charAt(index) != '"') {
+ if (data.charAt(index) == '\\') {
+ ignoreSpaces = false;
+ chunks.append(data.substring(start, index));
+ index++;
+ char ch = data.charAt(index);
+ index++;
+ if (ch == '\n') {
+ ignoreSpaces = true;
+ } else if (QUOTE_CODES.keySet().contains(ch)) {
+ int length = QUOTE_CODES.get(ch);
+ int code = Integer.parseInt(data.substring(index, index + length), 16);
+ chunks.append(String.valueOf((char) code));
+ index += length;
+ } else {
+ if (!QUOTE_REPLACES.keySet().contains(ch)) {
+ throw new CanonicalException("invalid escape code");
+ }
+ chunks.append(QUOTE_REPLACES.get(ch));
+ }
+ start = index;
+ } else if (data.charAt(index) == '\n') {
+ chunks.append(data.substring(start, index));
+ chunks.append(" ");
+ index++;
+ start = index;
+ ignoreSpaces = true;
+ } else if (ignoreSpaces && data.charAt(index) == ' ') {
+ index++;
+ start = index;
+ } else {
+ ignoreSpaces = false;
+ index++;
+ }
+ }
+ chunks.append(data.substring(start, index));
+ index++;
+ return new ScalarToken(chunks.toString(), mark, mark, false);
+ }
+
+ private void findToken() {
+ boolean found = false;
+ while (!found) {
+ while (" \t".indexOf(data.charAt(index)) != -1) {
+ index++;
+ }
+ if (data.charAt(index) == '#') {
+ while (data.charAt(index) != '\n') {
+ index++;
+ }
+ }
+ if (data.charAt(index) == '\n') {
+ index++;
+ } else {
+ found = true;
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyCanonicalTest.java b/src/test/java/org/pyyaml/PyCanonicalTest.java
index 21e7f10..0e1edd7 100644
--- a/src/test/java/org/pyyaml/PyCanonicalTest.java
+++ b/src/test/java/org/pyyaml/PyCanonicalTest.java
@@ -1,70 +1,70 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.tokens.Token;
-
-/**
- * @see imported from PyYAML
- */
-public class PyCanonicalTest extends PyImportTest {
-
- public void testCanonicalScanner() throws IOException {
- File[] files = getStreamsByExtension(".canonical");
- assertTrue("No test files found.", files.length > 0);
- for (int i = 0; i < files.length; i++) {
- InputStream input = new FileInputStream(files[i]);
- List<Token> tokens = canonicalScan(input);
- input.close();
- assertFalse(tokens.isEmpty());
- }
- }
-
- private List<Token> canonicalScan(InputStream input) throws IOException {
- int ch = input.read();
- StringBuilder buffer = new StringBuilder();
- while (ch != -1) {
- buffer.append((char) ch);
- ch = input.read();
- }
- CanonicalScanner scanner = new CanonicalScanner(buffer.toString());
- List<Token> result = new ArrayList<Token>();
- while (scanner.peekToken() != null) {
- result.add(scanner.getToken());
- }
- return result;
- }
-
- public void testCanonicalParser() throws IOException {
- File[] files = getStreamsByExtension(".canonical");
- assertTrue("No test files found.", files.length > 0);
- for (int i = 0; i < files.length; i++) {
- InputStream input = new FileInputStream(files[i]);
- List<Event> tokens = canonicalParse(input);
- input.close();
- assertFalse(tokens.isEmpty());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.tokens.Token;
+
+/**
+ * @see imported from PyYAML
+ */
+public class PyCanonicalTest extends PyImportTest {
+
+ public void testCanonicalScanner() throws IOException {
+ File[] files = getStreamsByExtension(".canonical");
+ assertTrue("No test files found.", files.length > 0);
+ for (int i = 0; i < files.length; i++) {
+ InputStream input = new FileInputStream(files[i]);
+ List<Token> tokens = canonicalScan(input);
+ input.close();
+ assertFalse(tokens.isEmpty());
+ }
+ }
+
+ private List<Token> canonicalScan(InputStream input) throws IOException {
+ int ch = input.read();
+ StringBuilder buffer = new StringBuilder();
+ while (ch != -1) {
+ buffer.append((char) ch);
+ ch = input.read();
+ }
+ CanonicalScanner scanner = new CanonicalScanner(buffer.toString());
+ List<Token> result = new ArrayList<Token>();
+ while (scanner.peekToken() != null) {
+ result.add(scanner.getToken());
+ }
+ return result;
+ }
+
+ public void testCanonicalParser() throws IOException {
+ File[] files = getStreamsByExtension(".canonical");
+ assertTrue("No test files found.", files.length > 0);
+ for (int i = 0; i < files.length; i++) {
+ InputStream input = new FileInputStream(files[i]);
+ List<Event> tokens = canonicalParse(input);
+ input.close();
+ assertFalse(tokens.isEmpty());
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyEmitterTest.java b/src/test/java/org/pyyaml/PyEmitterTest.java
index 1318e78..da44756 100644
--- a/src/test/java/org/pyyaml/PyEmitterTest.java
+++ b/src/test/java/org/pyyaml/PyEmitterTest.java
@@ -1,293 +1,293 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.emitter.Emitter;
-import org.yaml.snakeyaml.emitter.EventConstructor;
-import org.yaml.snakeyaml.events.CollectionStartEvent;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.MappingStartEvent;
-import org.yaml.snakeyaml.events.NodeEvent;
-import org.yaml.snakeyaml.events.ScalarEvent;
-import org.yaml.snakeyaml.events.SequenceStartEvent;
-import org.yaml.snakeyaml.parser.Parser;
-import org.yaml.snakeyaml.parser.ParserImpl;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.reader.UnicodeReader;
-
-/**
- * @see imported from PyYAML
- */
-public class PyEmitterTest extends PyImportTest {
- public void testEmitterOnData() {
- _testEmitter(".data", false);
- }
-
- public void testEmitterOnCanonicalNormally() {
- _testEmitter(".canonical", false);
- }
-
- public void testEmitterOnCanonicalCanonically() {
- _testEmitter(".canonical", true);
- }
-
- private void _testEmitter(String mask, boolean canonical) {
- File[] files = getStreamsByExtension(mask, true);
- assertTrue("No test files found.", files.length > 0);
- for (File file : files) {
- // if (!file.getName().contains("spec-06-01.canonical")) {
- // continue;
- // }
- try {
- InputStream input = new FileInputStream(file);
- List<Event> events = parse(input);
- input.close();
- //
- StringWriter stream = new StringWriter();
- DumperOptions options = new DumperOptions();
- options.setCanonical(canonical);
- Emitter emitter = new Emitter(stream, options);
- for (Event event : events) {
- emitter.emit(event);
- }
- //
- String data = stream.toString();
- List<Event> newEvents = new ArrayList<Event>();
- StreamReader reader = new StreamReader(data);
- Parser parser = new ParserImpl(reader);
- while (parser.peekEvent() != null) {
- Event event = parser.getEvent();
- newEvents.add(event);
- }
- // check
- assertEquals(events.size(), newEvents.size());
- Iterator<Event> iter1 = events.iterator();
- Iterator<Event> iter2 = newEvents.iterator();
- while (iter1.hasNext()) {
- Event event = iter1.next();
- Event newEvent = iter2.next();
- assertEquals(event.getClass().getName(), newEvent.getClass().getName());
- if (event instanceof NodeEvent) {
- NodeEvent e1 = (NodeEvent) event;
- NodeEvent e2 = (NodeEvent) newEvent;
- assertEquals(e1.getAnchor(), e2.getAnchor());
- }
- if (event instanceof CollectionStartEvent) {
- CollectionStartEvent e1 = (CollectionStartEvent) event;
- CollectionStartEvent e2 = (CollectionStartEvent) newEvent;
- assertEquals(e1.getTag(), e2.getTag());
- }
- if (event instanceof ScalarEvent) {
- ScalarEvent e1 = (ScalarEvent) event;
- ScalarEvent e2 = (ScalarEvent) newEvent;
- if (e1.getImplicit().bothFalse() && e2.getImplicit().bothFalse()) {
- assertEquals(e1.getTag(), e2.getTag());
- }
- assertEquals(e1.getValue(), e2.getValue());
- }
- }
- } catch (Exception e) {
- System.out.println("Failed File: " + file);
- // fail("Failed File: " + file + "; " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
- }
-
- public void testEmitterStyles() {
- File[] canonicalFiles = getStreamsByExtension(".canonical", false);
- assertTrue("No test files found.", canonicalFiles.length > 0);
- File[] dataFiles = getStreamsByExtension(".data", true);
- assertTrue("No test files found.", dataFiles.length > 0);
- List<File> allFiles = new ArrayList<File>(Arrays.asList(canonicalFiles));
- allFiles.addAll(Arrays.asList(dataFiles));
- for (File file : allFiles) {
- try {
- List<Event> events = new ArrayList<Event>();
- InputStream input = new FileInputStream(file);
- StreamReader reader = new StreamReader(new UnicodeReader(input));
- Parser parser = new ParserImpl(reader);
- while (parser.peekEvent() != null) {
- Event event = parser.getEvent();
- events.add(event);
- }
- input.close();
- //
- for (Boolean flowStyle : new Boolean[] { Boolean.FALSE, Boolean.TRUE }) {
- for (DumperOptions.ScalarStyle style : DumperOptions.ScalarStyle.values()) {
- List<Event> styledEvents = new ArrayList<Event>();
- for (Event event : events) {
- if (event instanceof ScalarEvent) {
- ScalarEvent scalar = (ScalarEvent) event;
- event = new ScalarEvent(scalar.getAnchor(), scalar.getTag(),
- scalar.getImplicit(), scalar.getValue(),
- scalar.getStartMark(), scalar.getEndMark(), style.getChar());
- } else if (event instanceof SequenceStartEvent) {
- SequenceStartEvent seqStart = (SequenceStartEvent) event;
- event = new SequenceStartEvent(seqStart.getAnchor(),
- seqStart.getTag(), seqStart.getImplicit(),
- seqStart.getStartMark(), seqStart.getEndMark(), flowStyle);
- } else if (event instanceof MappingStartEvent) {
- MappingStartEvent mapStart = (MappingStartEvent) event;
- event = new MappingStartEvent(mapStart.getAnchor(),
- mapStart.getTag(), mapStart.getImplicit(),
- mapStart.getStartMark(), mapStart.getEndMark(), flowStyle);
- }
- styledEvents.add(event);
- }
- // emit
- String data = emit(styledEvents);
- List<Event> newEvents = parse(data);
- assertEquals("Events must not change. File: " + file, events.size(),
- newEvents.size());
- Iterator<Event> oldIter = events.iterator();
- Iterator<Event> newIter = newEvents.iterator();
- while (oldIter.hasNext()) {
- Event event = oldIter.next();
- Event newEvent = newIter.next();
- assertEquals(event.getClass(), newEvent.getClass());
- if (event instanceof NodeEvent) {
- assertEquals(((NodeEvent) event).getAnchor(),
- ((NodeEvent) newEvent).getAnchor());
- }
- if (event instanceof CollectionStartEvent) {
- assertEquals(((CollectionStartEvent) event).getTag(),
- ((CollectionStartEvent) newEvent).getTag());
- }
- if (event instanceof ScalarEvent) {
- ScalarEvent scalarOld = (ScalarEvent) event;
- ScalarEvent scalarNew = (ScalarEvent) newEvent;
- if (scalarOld.getImplicit().bothFalse()
- && scalarNew.getImplicit().bothFalse()) {
- assertEquals(scalarOld.getTag(), scalarNew.getTag());
- }
- assertEquals(scalarOld.getValue(), scalarNew.getValue());
- }
- }
- }
- }
-
- } catch (Exception e) {
- System.out.println("Failed File: " + file);
- // fail("Failed File: " + file + "; " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
- }
-
- private String emit(List<Event> events) throws IOException {
- StringWriter writer = new StringWriter();
- Emitter emitter = new Emitter(writer, new DumperOptions());
- for (Event event : events) {
- emitter.emit(event);
- }
- return writer.toString();
- }
-
- private List<Event> parse(String data) {
- ParserImpl parser = new ParserImpl(new StreamReader(data));
- List<Event> newEvents = new ArrayList<Event>();
- while (parser.peekEvent() != null) {
- newEvents.add(parser.getEvent());
- }
- return newEvents;
- }
-
- @SuppressWarnings("unchecked")
- public void testEmitterEvents() {
- File[] files = getStreamsByExtension(".events", false);
- assertTrue("No test files found.", files.length > 0);
- for (File file : files) {
- // if (!file.getName().contains("spec-06-01.canonical")) {
- // continue;
- // }
- try {
- List<Event> events = new ArrayList<Event>();
- String content = getResource(file.getName());
- events = (List<Event>) load(new EventConstructor(), content);
- //
- StringWriter stream = new StringWriter();
- Emitter emitter = new Emitter(stream, new DumperOptions());
- for (Event event : events) {
- emitter.emit(event);
- }
- //
- String data = stream.toString();
- List<Event> newEvents = new ArrayList<Event>();
- StreamReader reader = new StreamReader(data);
- Parser parser = new ParserImpl(reader);
- while (parser.peekEvent() != null) {
- Event event = parser.getEvent();
- newEvents.add(event);
- }
- // check
- assertEquals(events.size(), newEvents.size());
- Iterator<Event> iter1 = events.iterator();
- Iterator<Event> iter2 = newEvents.iterator();
- while (iter1.hasNext()) {
- Event event = iter1.next();
- Event newEvent = iter2.next();
- assertEquals(event.getClass().getName(), newEvent.getClass().getName());
- if (event instanceof NodeEvent) {
- NodeEvent e1 = (NodeEvent) event;
- NodeEvent e2 = (NodeEvent) newEvent;
- assertEquals(e1.getAnchor(), e2.getAnchor());
- }
- if (event instanceof CollectionStartEvent) {
- CollectionStartEvent e1 = (CollectionStartEvent) event;
- CollectionStartEvent e2 = (CollectionStartEvent) newEvent;
- assertEquals(e1.getTag(), e2.getTag());
- }
- if (event instanceof ScalarEvent) {
- ScalarEvent e1 = (ScalarEvent) event;
- ScalarEvent e2 = (ScalarEvent) newEvent;
- if (e1.getImplicit().canOmitTagInPlainScalar() == e2.getImplicit()
- .canOmitTagInPlainScalar()
- && e1.getImplicit().canOmitTagInNonPlainScalar() == e2
- .getImplicit().canOmitTagInNonPlainScalar()) {
-
- } else {
- if ((e1.getTag() == null || e2.getTag() == null)
- || e1.getTag().equals(e2.getTag())) {
- } else {
- System.out.println("tag1: " + e1.getTag());
- System.out.println("tag2: " + e2.getTag());
- fail("in file: " + file);
- }
- }
- assertEquals(e1.getValue(), e2.getValue());
- }
- }
- } catch (Exception e) {
- System.out.println("Failed File: " + file);
- // fail("Failed File: " + file + "; " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.emitter.Emitter;
+import org.yaml.snakeyaml.emitter.EventConstructor;
+import org.yaml.snakeyaml.events.CollectionStartEvent;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.MappingStartEvent;
+import org.yaml.snakeyaml.events.NodeEvent;
+import org.yaml.snakeyaml.events.ScalarEvent;
+import org.yaml.snakeyaml.events.SequenceStartEvent;
+import org.yaml.snakeyaml.parser.Parser;
+import org.yaml.snakeyaml.parser.ParserImpl;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+
+/**
+ * @see imported from PyYAML
+ */
+public class PyEmitterTest extends PyImportTest {
+ public void testEmitterOnData() {
+ _testEmitter(".data", false);
+ }
+
+ public void testEmitterOnCanonicalNormally() {
+ _testEmitter(".canonical", false);
+ }
+
+ public void testEmitterOnCanonicalCanonically() {
+ _testEmitter(".canonical", true);
+ }
+
+ private void _testEmitter(String mask, boolean canonical) {
+ File[] files = getStreamsByExtension(mask, true);
+ assertTrue("No test files found.", files.length > 0);
+ for (File file : files) {
+ // if (!file.getName().contains("spec-06-01.canonical")) {
+ // continue;
+ // }
+ try {
+ InputStream input = new FileInputStream(file);
+ List<Event> events = parse(input);
+ input.close();
+ //
+ StringWriter stream = new StringWriter();
+ DumperOptions options = new DumperOptions();
+ options.setCanonical(canonical);
+ Emitter emitter = new Emitter(stream, options);
+ for (Event event : events) {
+ emitter.emit(event);
+ }
+ //
+ String data = stream.toString();
+ List<Event> newEvents = new ArrayList<Event>();
+ StreamReader reader = new StreamReader(data);
+ Parser parser = new ParserImpl(reader);
+ while (parser.peekEvent() != null) {
+ Event event = parser.getEvent();
+ newEvents.add(event);
+ }
+ // check
+ assertEquals(events.size(), newEvents.size());
+ Iterator<Event> iter1 = events.iterator();
+ Iterator<Event> iter2 = newEvents.iterator();
+ while (iter1.hasNext()) {
+ Event event = iter1.next();
+ Event newEvent = iter2.next();
+ assertEquals(event.getClass().getName(), newEvent.getClass().getName());
+ if (event instanceof NodeEvent) {
+ NodeEvent e1 = (NodeEvent) event;
+ NodeEvent e2 = (NodeEvent) newEvent;
+ assertEquals(e1.getAnchor(), e2.getAnchor());
+ }
+ if (event instanceof CollectionStartEvent) {
+ CollectionStartEvent e1 = (CollectionStartEvent) event;
+ CollectionStartEvent e2 = (CollectionStartEvent) newEvent;
+ assertEquals(e1.getTag(), e2.getTag());
+ }
+ if (event instanceof ScalarEvent) {
+ ScalarEvent e1 = (ScalarEvent) event;
+ ScalarEvent e2 = (ScalarEvent) newEvent;
+ if (e1.getImplicit().bothFalse() && e2.getImplicit().bothFalse()) {
+ assertEquals(e1.getTag(), e2.getTag());
+ }
+ assertEquals(e1.getValue(), e2.getValue());
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("Failed File: " + file);
+ // fail("Failed File: " + file + "; " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public void testEmitterStyles() {
+ File[] canonicalFiles = getStreamsByExtension(".canonical", false);
+ assertTrue("No test files found.", canonicalFiles.length > 0);
+ File[] dataFiles = getStreamsByExtension(".data", true);
+ assertTrue("No test files found.", dataFiles.length > 0);
+ List<File> allFiles = new ArrayList<File>(Arrays.asList(canonicalFiles));
+ allFiles.addAll(Arrays.asList(dataFiles));
+ for (File file : allFiles) {
+ try {
+ List<Event> events = new ArrayList<Event>();
+ InputStream input = new FileInputStream(file);
+ StreamReader reader = new StreamReader(new UnicodeReader(input));
+ Parser parser = new ParserImpl(reader);
+ while (parser.peekEvent() != null) {
+ Event event = parser.getEvent();
+ events.add(event);
+ }
+ input.close();
+ //
+ for (Boolean flowStyle : new Boolean[] { Boolean.FALSE, Boolean.TRUE }) {
+ for (DumperOptions.ScalarStyle style : DumperOptions.ScalarStyle.values()) {
+ List<Event> styledEvents = new ArrayList<Event>();
+ for (Event event : events) {
+ if (event instanceof ScalarEvent) {
+ ScalarEvent scalar = (ScalarEvent) event;
+ event = new ScalarEvent(scalar.getAnchor(), scalar.getTag(),
+ scalar.getImplicit(), scalar.getValue(),
+ scalar.getStartMark(), scalar.getEndMark(), style.getChar());
+ } else if (event instanceof SequenceStartEvent) {
+ SequenceStartEvent seqStart = (SequenceStartEvent) event;
+ event = new SequenceStartEvent(seqStart.getAnchor(),
+ seqStart.getTag(), seqStart.getImplicit(),
+ seqStart.getStartMark(), seqStart.getEndMark(), flowStyle);
+ } else if (event instanceof MappingStartEvent) {
+ MappingStartEvent mapStart = (MappingStartEvent) event;
+ event = new MappingStartEvent(mapStart.getAnchor(),
+ mapStart.getTag(), mapStart.getImplicit(),
+ mapStart.getStartMark(), mapStart.getEndMark(), flowStyle);
+ }
+ styledEvents.add(event);
+ }
+ // emit
+ String data = emit(styledEvents);
+ List<Event> newEvents = parse(data);
+ assertEquals("Events must not change. File: " + file, events.size(),
+ newEvents.size());
+ Iterator<Event> oldIter = events.iterator();
+ Iterator<Event> newIter = newEvents.iterator();
+ while (oldIter.hasNext()) {
+ Event event = oldIter.next();
+ Event newEvent = newIter.next();
+ assertEquals(event.getClass(), newEvent.getClass());
+ if (event instanceof NodeEvent) {
+ assertEquals(((NodeEvent) event).getAnchor(),
+ ((NodeEvent) newEvent).getAnchor());
+ }
+ if (event instanceof CollectionStartEvent) {
+ assertEquals(((CollectionStartEvent) event).getTag(),
+ ((CollectionStartEvent) newEvent).getTag());
+ }
+ if (event instanceof ScalarEvent) {
+ ScalarEvent scalarOld = (ScalarEvent) event;
+ ScalarEvent scalarNew = (ScalarEvent) newEvent;
+ if (scalarOld.getImplicit().bothFalse()
+ && scalarNew.getImplicit().bothFalse()) {
+ assertEquals(scalarOld.getTag(), scalarNew.getTag());
+ }
+ assertEquals(scalarOld.getValue(), scalarNew.getValue());
+ }
+ }
+ }
+ }
+
+ } catch (Exception e) {
+ System.out.println("Failed File: " + file);
+ // fail("Failed File: " + file + "; " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private String emit(List<Event> events) throws IOException {
+ StringWriter writer = new StringWriter();
+ Emitter emitter = new Emitter(writer, new DumperOptions());
+ for (Event event : events) {
+ emitter.emit(event);
+ }
+ return writer.toString();
+ }
+
+ private List<Event> parse(String data) {
+ ParserImpl parser = new ParserImpl(new StreamReader(data));
+ List<Event> newEvents = new ArrayList<Event>();
+ while (parser.peekEvent() != null) {
+ newEvents.add(parser.getEvent());
+ }
+ return newEvents;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testEmitterEvents() {
+ File[] files = getStreamsByExtension(".events", false);
+ assertTrue("No test files found.", files.length > 0);
+ for (File file : files) {
+ // if (!file.getName().contains("spec-06-01.canonical")) {
+ // continue;
+ // }
+ try {
+ List<Event> events = new ArrayList<Event>();
+ String content = getResource(file.getName());
+ events = (List<Event>) load(new EventConstructor(), content);
+ //
+ StringWriter stream = new StringWriter();
+ Emitter emitter = new Emitter(stream, new DumperOptions());
+ for (Event event : events) {
+ emitter.emit(event);
+ }
+ //
+ String data = stream.toString();
+ List<Event> newEvents = new ArrayList<Event>();
+ StreamReader reader = new StreamReader(data);
+ Parser parser = new ParserImpl(reader);
+ while (parser.peekEvent() != null) {
+ Event event = parser.getEvent();
+ newEvents.add(event);
+ }
+ // check
+ assertEquals(events.size(), newEvents.size());
+ Iterator<Event> iter1 = events.iterator();
+ Iterator<Event> iter2 = newEvents.iterator();
+ while (iter1.hasNext()) {
+ Event event = iter1.next();
+ Event newEvent = iter2.next();
+ assertEquals(event.getClass().getName(), newEvent.getClass().getName());
+ if (event instanceof NodeEvent) {
+ NodeEvent e1 = (NodeEvent) event;
+ NodeEvent e2 = (NodeEvent) newEvent;
+ assertEquals(e1.getAnchor(), e2.getAnchor());
+ }
+ if (event instanceof CollectionStartEvent) {
+ CollectionStartEvent e1 = (CollectionStartEvent) event;
+ CollectionStartEvent e2 = (CollectionStartEvent) newEvent;
+ assertEquals(e1.getTag(), e2.getTag());
+ }
+ if (event instanceof ScalarEvent) {
+ ScalarEvent e1 = (ScalarEvent) event;
+ ScalarEvent e2 = (ScalarEvent) newEvent;
+ if (e1.getImplicit().canOmitTagInPlainScalar() == e2.getImplicit()
+ .canOmitTagInPlainScalar()
+ && e1.getImplicit().canOmitTagInNonPlainScalar() == e2
+ .getImplicit().canOmitTagInNonPlainScalar()) {
+
+ } else {
+ if ((e1.getTag() == null || e2.getTag() == null)
+ || e1.getTag().equals(e2.getTag())) {
+ } else {
+ System.out.println("tag1: " + e1.getTag());
+ System.out.println("tag2: " + e2.getTag());
+ fail("in file: " + file);
+ }
+ }
+ assertEquals(e1.getValue(), e2.getValue());
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("Failed File: " + file);
+ // fail("Failed File: " + file + "; " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyErrorsTest.java b/src/test/java/org/pyyaml/PyErrorsTest.java
index 0bad7fa..7ae480f 100644
--- a/src/test/java/org/pyyaml/PyErrorsTest.java
+++ b/src/test/java/org/pyyaml/PyErrorsTest.java
@@ -1,132 +1,132 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.emitter.Emitter;
-import org.yaml.snakeyaml.emitter.EventConstructor;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.events.Event;
-
-/**
- * @see imported from PyYAML
- */
-public class PyErrorsTest extends PyImportTest {
- private boolean skip(String filename) {
- List<String> failures = new ArrayList<String>();
- // in python list cannot be a key in a dictionary.
- failures.add("unacceptable-key.loader-error");
- for (String name : failures) {
- if (name.equals(filename)) {
- return true;
- }
- }
- return false;
- }
-
- public void testLoaderErrors() throws FileNotFoundException {
- File[] files = getStreamsByExtension(".loader-error");
- assertTrue("No test files found.", files.length > 0);
- for (int i = 0; i < files.length; i++) {
- if (skip(files[i].getName())) {
- continue;
- }
- try {
- InputStream input = new FileInputStream(files[i]);
- for (Object document : loadAll(input)) {
- assertNotNull("File " + files[i], document);
- }
- input.close();
- fail("Loading must fail for " + files[i].getAbsolutePath());
- // System.err.println("Loading must fail for " +
- // files[i].getAbsolutePath());
- } catch (Exception e) {
- assertTrue(true);
- }
- }
- }
-
- public void testLoaderStringErrors() throws FileNotFoundException {
- File[] files = getStreamsByExtension(".loader-error");
- assertTrue("No test files found.", files.length > 0);
- for (int i = 0; i < files.length; i++) {
- if (skip(files[i].getName())) {
- continue;
- }
- try {
- String content = getResource(files[i].getName());
- for (Object document : loadAll(content.trim())) {
- assertNotNull(document);
- }
- fail("Loading must fail for " + files[i].getAbsolutePath());
- // System.err.println("Loading must fail for " +
- // files[i].getAbsolutePath());
- } catch (Exception e) {
- assertTrue(true);
- }
- }
- }
-
- public void testLoaderSingleErrors() throws FileNotFoundException {
- File[] files = getStreamsByExtension(".single-loader-error");
- assertTrue("No test files found.", files.length > 0);
- for (int i = 0; i < files.length; i++) {
- try {
- String content = getResource(files[i].getName());
- load(content.trim());
- fail("Loading must fail for " + files[i].getAbsolutePath());
- // multiple documents must not be accepted
- System.err.println("Loading must fail for " + files[i].getAbsolutePath());
- } catch (YAMLException e) {
- assertTrue(true);
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testEmitterErrors() {
- File[] files = getStreamsByExtension(".emitter-error");
- assertTrue("No test files found.", files.length > 0);
- for (int i = 0; i < files.length; i++) {
- String content = getResource(files[i].getName());
- List<Event> document = (List<Event>) load(new EventConstructor(), content.trim());
- Writer writer = new StringWriter();
- Emitter emitter = new Emitter(writer, new DumperOptions());
- try {
- for (Event event : document) {
- emitter.emit(event);
- }
- fail("Loading must fail for " + files[i].getAbsolutePath());
- // System.err.println("Loading must fail for " +
- // files[i].getAbsolutePath());
- } catch (Exception e) {
- assertTrue(true);
- }
- }
- }
-
- // testDumperErrors() is implemented in SerializerTest.java
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.emitter.Emitter;
+import org.yaml.snakeyaml.emitter.EventConstructor;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.events.Event;
+
+/**
+ * @see imported from PyYAML
+ */
+public class PyErrorsTest extends PyImportTest {
+ private boolean skip(String filename) {
+ List<String> failures = new ArrayList<String>();
+ // in python list cannot be a key in a dictionary.
+ failures.add("unacceptable-key.loader-error");
+ for (String name : failures) {
+ if (name.equals(filename)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void testLoaderErrors() throws FileNotFoundException {
+ File[] files = getStreamsByExtension(".loader-error");
+ assertTrue("No test files found.", files.length > 0);
+ for (int i = 0; i < files.length; i++) {
+ if (skip(files[i].getName())) {
+ continue;
+ }
+ try {
+ InputStream input = new FileInputStream(files[i]);
+ for (Object document : loadAll(input)) {
+ assertNotNull("File " + files[i], document);
+ }
+ input.close();
+ fail("Loading must fail for " + files[i].getAbsolutePath());
+ // System.err.println("Loading must fail for " +
+ // files[i].getAbsolutePath());
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+ }
+
+ public void testLoaderStringErrors() throws FileNotFoundException {
+ File[] files = getStreamsByExtension(".loader-error");
+ assertTrue("No test files found.", files.length > 0);
+ for (int i = 0; i < files.length; i++) {
+ if (skip(files[i].getName())) {
+ continue;
+ }
+ try {
+ String content = getResource(files[i].getName());
+ for (Object document : loadAll(content.trim())) {
+ assertNotNull(document);
+ }
+ fail("Loading must fail for " + files[i].getAbsolutePath());
+ // System.err.println("Loading must fail for " +
+ // files[i].getAbsolutePath());
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+ }
+
+ public void testLoaderSingleErrors() throws FileNotFoundException {
+ File[] files = getStreamsByExtension(".single-loader-error");
+ assertTrue("No test files found.", files.length > 0);
+ for (int i = 0; i < files.length; i++) {
+ try {
+ String content = getResource(files[i].getName());
+ load(content.trim());
+ fail("Loading must fail for " + files[i].getAbsolutePath());
+ // multiple documents must not be accepted
+ System.err.println("Loading must fail for " + files[i].getAbsolutePath());
+ } catch (YAMLException e) {
+ assertTrue(true);
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testEmitterErrors() {
+ File[] files = getStreamsByExtension(".emitter-error");
+ assertTrue("No test files found.", files.length > 0);
+ for (int i = 0; i < files.length; i++) {
+ String content = getResource(files[i].getName());
+ List<Event> document = (List<Event>) load(new EventConstructor(), content.trim());
+ Writer writer = new StringWriter();
+ Emitter emitter = new Emitter(writer, new DumperOptions());
+ try {
+ for (Event event : document) {
+ emitter.emit(event);
+ }
+ fail("Loading must fail for " + files[i].getAbsolutePath());
+ // System.err.println("Loading must fail for " +
+ // files[i].getAbsolutePath());
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ }
+ }
+
+ // testDumperErrors() is implemented in SerializerTest.java
+}
diff --git a/src/test/java/org/pyyaml/PyImportTest.java b/src/test/java/org/pyyaml/PyImportTest.java
index a1b185c..3a308e4 100644
--- a/src/test/java/org/pyyaml/PyImportTest.java
+++ b/src/test/java/org/pyyaml/PyImportTest.java
@@ -1,136 +1,136 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.parser.Parser;
-import org.yaml.snakeyaml.parser.ParserImpl;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.reader.UnicodeReader;
-
-public abstract class PyImportTest extends TestCase {
- public static final String PATH = "pyyaml";
-
- protected Object load(String data) {
- Yaml yaml = new Yaml();
- return yaml.load(data);
- }
-
- protected Object load(Constructor loader, String data) {
- Yaml yaml = new Yaml(loader);
- return yaml.load(data);
- }
-
- protected Iterable<Object> loadAll(InputStream data) {
- Yaml yaml = new Yaml();
- return yaml.loadAll(data);
- }
-
- protected Iterable<Object> loadAll(String data) {
- Yaml yaml = new Yaml();
- return yaml.loadAll(data);
- }
-
- protected Iterable<Object> loadAll(Constructor loader, String data) {
- Yaml yaml = new Yaml(loader);
- return yaml.loadAll(data);
- }
-
- protected String getResource(String theName) {
- String content;
- content = Util.getLocalResource(PATH + File.separator + theName);
- return content;
- }
-
- protected File[] getStreamsByExtension(String extention) {
- return getStreamsByExtension(extention, false);
- }
-
- protected File[] getStreamsByExtension(String extention, boolean onlyIfCanonicalPresent) {
- File file = new File("src/test/resources/pyyaml");
- assertTrue("Folder not found: " + file.getAbsolutePath(), file.exists());
- assertTrue(file.isDirectory());
- return file.listFiles(new PyFilenameFilter(extention, onlyIfCanonicalPresent));
- }
-
- protected File getFileByName(String name) {
- File file = new File("src/test/resources/pyyaml/" + name);
- assertTrue("Folder not found: " + file.getAbsolutePath(), file.exists());
- assertTrue(file.isFile());
- return file;
- }
-
- protected List<Event> canonicalParse(InputStream input2) throws IOException {
- StreamReader reader = new StreamReader(new UnicodeReader(input2));
- StringBuilder buffer = new StringBuilder();
- while (reader.peek() != '\0') {
- buffer.append(reader.peek());
- reader.forward();
- }
- CanonicalParser parser = new CanonicalParser(buffer.toString());
- List<Event> result = new ArrayList<Event>();
- while (parser.peekEvent() != null) {
- result.add(parser.getEvent());
- }
- input2.close();
- return result;
- }
-
- protected List<Event> parse(InputStream input) throws IOException {
- StreamReader reader = new StreamReader(new UnicodeReader(input));
- Parser parser = new ParserImpl(reader);
- List<Event> result = new ArrayList<Event>();
- while (parser.peekEvent() != null) {
- result.add(parser.getEvent());
- }
- input.close();
- return result;
- }
-
- private class PyFilenameFilter implements FilenameFilter {
- private String extension;
- private boolean onlyIfCanonicalPresent;
-
- public PyFilenameFilter(String extension, boolean onlyIfCanonicalPresent) {
- this.extension = extension;
- this.onlyIfCanonicalPresent = onlyIfCanonicalPresent;
- }
-
- public boolean accept(File dir, String name) {
- int position = name.lastIndexOf('.');
- String canonicalFileName = name.substring(0, position) + ".canonical";
- File canonicalFile = new File(dir, canonicalFileName);
- if (onlyIfCanonicalPresent && !canonicalFile.exists()) {
- return false;
- } else {
- return name.endsWith(extension);
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.parser.Parser;
+import org.yaml.snakeyaml.parser.ParserImpl;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+
+public abstract class PyImportTest extends TestCase {
+ public static final String PATH = "pyyaml";
+
+ protected Object load(String data) {
+ Yaml yaml = new Yaml();
+ return yaml.load(data);
+ }
+
+ protected Object load(Constructor loader, String data) {
+ Yaml yaml = new Yaml(loader);
+ return yaml.load(data);
+ }
+
+ protected Iterable<Object> loadAll(InputStream data) {
+ Yaml yaml = new Yaml();
+ return yaml.loadAll(data);
+ }
+
+ protected Iterable<Object> loadAll(String data) {
+ Yaml yaml = new Yaml();
+ return yaml.loadAll(data);
+ }
+
+ protected Iterable<Object> loadAll(Constructor loader, String data) {
+ Yaml yaml = new Yaml(loader);
+ return yaml.loadAll(data);
+ }
+
+ protected String getResource(String theName) {
+ String content;
+ content = Util.getLocalResource(PATH + File.separator + theName);
+ return content;
+ }
+
+ protected File[] getStreamsByExtension(String extention) {
+ return getStreamsByExtension(extention, false);
+ }
+
+ protected File[] getStreamsByExtension(String extention, boolean onlyIfCanonicalPresent) {
+ File file = new File("src/test/resources/pyyaml");
+ assertTrue("Folder not found: " + file.getAbsolutePath(), file.exists());
+ assertTrue(file.isDirectory());
+ return file.listFiles(new PyFilenameFilter(extention, onlyIfCanonicalPresent));
+ }
+
+ protected File getFileByName(String name) {
+ File file = new File("src/test/resources/pyyaml/" + name);
+ assertTrue("Folder not found: " + file.getAbsolutePath(), file.exists());
+ assertTrue(file.isFile());
+ return file;
+ }
+
+ protected List<Event> canonicalParse(InputStream input2) throws IOException {
+ StreamReader reader = new StreamReader(new UnicodeReader(input2));
+ StringBuilder buffer = new StringBuilder();
+ while (reader.peek() != '\0') {
+ buffer.append(reader.peek());
+ reader.forward();
+ }
+ CanonicalParser parser = new CanonicalParser(buffer.toString());
+ List<Event> result = new ArrayList<Event>();
+ while (parser.peekEvent() != null) {
+ result.add(parser.getEvent());
+ }
+ input2.close();
+ return result;
+ }
+
+ protected List<Event> parse(InputStream input) throws IOException {
+ StreamReader reader = new StreamReader(new UnicodeReader(input));
+ Parser parser = new ParserImpl(reader);
+ List<Event> result = new ArrayList<Event>();
+ while (parser.peekEvent() != null) {
+ result.add(parser.getEvent());
+ }
+ input.close();
+ return result;
+ }
+
+ private class PyFilenameFilter implements FilenameFilter {
+ private String extension;
+ private boolean onlyIfCanonicalPresent;
+
+ public PyFilenameFilter(String extension, boolean onlyIfCanonicalPresent) {
+ this.extension = extension;
+ this.onlyIfCanonicalPresent = onlyIfCanonicalPresent;
+ }
+
+ public boolean accept(File dir, String name) {
+ int position = name.lastIndexOf('.');
+ String canonicalFileName = name.substring(0, position) + ".canonical";
+ File canonicalFile = new File(dir, canonicalFileName);
+ if (onlyIfCanonicalPresent && !canonicalFile.exists()) {
+ return false;
+ } else {
+ return name.endsWith(extension);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyMarkTest.java b/src/test/java/org/pyyaml/PyMarkTest.java
index 6e61ace..b8df836 100644
--- a/src/test/java/org/pyyaml/PyMarkTest.java
+++ b/src/test/java/org/pyyaml/PyMarkTest.java
@@ -1,58 +1,58 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import org.yaml.snakeyaml.error.Mark;
-
-/**
- * @see imported from PyYAML
- */
-public class PyMarkTest extends PyImportTest {
-
- public void testMarks() {
- String content = getResource("test_mark.marks");
- String[] inputs = content.split("---\n");
- for (int i = 1; i < inputs.length; i++) {
- String input = inputs[i];
- int index = 0;
- int line = 0;
- int column = 0;
- while (input.charAt(index) != '*') {
- if (input.charAt(index) != '\n') {
- line += 1;
- column = 0;
- } else {
- column += 1;
- }
- index += 1;
- }
- Mark mark = new Mark("testMarks", index, line, column, input, index);
- String snippet = mark.get_snippet(2, 79);
- assertTrue("Must only have one '\n'.", snippet.indexOf("\n") > -1);
- assertEquals("Must only have only one '\n'.", snippet.indexOf("\n"),
- snippet.lastIndexOf("\n"));
- String[] lines = snippet.split("\n");
- String data = lines[0];
- String pointer = lines[1];
- assertTrue("Mark must be restricted: " + data, data.length() < 82);
- int dataPosition = data.indexOf("*");
- int pointerPosition = pointer.indexOf("^");
- assertEquals("Pointer should coincide with '*':\n " + snippet, dataPosition,
- pointerPosition);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import org.yaml.snakeyaml.error.Mark;
+
+/**
+ * @see imported from PyYAML
+ */
+public class PyMarkTest extends PyImportTest {
+
+ public void testMarks() {
+ String content = getResource("test_mark.marks");
+ String[] inputs = content.split("---\n");
+ for (int i = 1; i < inputs.length; i++) {
+ String input = inputs[i];
+ int index = 0;
+ int line = 0;
+ int column = 0;
+ while (input.charAt(index) != '*') {
+ if (input.charAt(index) != '\n') {
+ line += 1;
+ column = 0;
+ } else {
+ column += 1;
+ }
+ index += 1;
+ }
+ Mark mark = new Mark("testMarks", index, line, column, input, index);
+ String snippet = mark.get_snippet(2, 79);
+ assertTrue("Must only have one '\n'.", snippet.indexOf("\n") > -1);
+ assertEquals("Must only have only one '\n'.", snippet.indexOf("\n"),
+ snippet.lastIndexOf("\n"));
+ String[] lines = snippet.split("\n");
+ String data = lines[0];
+ String pointer = lines[1];
+ assertTrue("Mark must be restricted: " + data, data.length() < 82);
+ int dataPosition = data.indexOf("*");
+ int pointerPosition = pointer.indexOf("^");
+ assertEquals("Pointer should coincide with '*':\n " + snippet, dataPosition,
+ pointerPosition);
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyReaderTest.java b/src/test/java/org/pyyaml/PyReaderTest.java
index 4a325ed..d9a929c 100644
--- a/src/test/java/org/pyyaml/PyReaderTest.java
+++ b/src/test/java/org/pyyaml/PyReaderTest.java
@@ -1,52 +1,52 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.yaml.snakeyaml.reader.ReaderException;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.reader.UnicodeReader;
-
-/**
- * @see imported from PyYAML
- */
-public class PyReaderTest extends PyImportTest {
-
- public void testReaderUnicodeErrors() throws IOException {
- File[] inputs = getStreamsByExtension(".stream-error");
- for (int i = 0; i < inputs.length; i++) {
- InputStream input = new FileInputStream(inputs[i]);
- StreamReader stream = new StreamReader(new UnicodeReader(input));
- try {
- while (stream.peek() != '\u0000') {
- stream.forward();
- }
- fail("Invalid stream must not be accepted: " + inputs[i].getAbsolutePath()
- + "; encoding=" + stream.getEncoding());
- } catch (ReaderException e) {
- assertTrue(e.toString(),
- e.toString().contains(" special characters are not allowed"));
- } finally {
- input.close();
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.yaml.snakeyaml.reader.ReaderException;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+
+/**
+ * @see imported from PyYAML
+ */
+public class PyReaderTest extends PyImportTest {
+
+ public void testReaderUnicodeErrors() throws IOException {
+ File[] inputs = getStreamsByExtension(".stream-error");
+ for (int i = 0; i < inputs.length; i++) {
+ InputStream input = new FileInputStream(inputs[i]);
+ StreamReader stream = new StreamReader(new UnicodeReader(input));
+ try {
+ while (stream.peek() != '\u0000') {
+ stream.forward();
+ }
+ fail("Invalid stream must not be accepted: " + inputs[i].getAbsolutePath()
+ + "; encoding=" + stream.getEncoding());
+ } catch (ReaderException e) {
+ assertTrue(e.toString(),
+ e.toString().contains(" special characters are not allowed"));
+ } finally {
+ input.close();
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyRecursiveTest.java b/src/test/java/org/pyyaml/PyRecursiveTest.java
index 82970e4..80a298a 100644
--- a/src/test/java/org/pyyaml/PyRecursiveTest.java
+++ b/src/test/java/org/pyyaml/PyRecursiveTest.java
@@ -1,145 +1,145 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-
-public class PyRecursiveTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testDict() {
- Map<AnInstance, AnInstance> value = new HashMap<AnInstance, AnInstance>();
- AnInstance instance = new AnInstance(value, value);
- value.put(instance, instance);
- Yaml yaml = new Yaml();
- String output1 = yaml.dump(value);
- assertTrue(output1.contains("!!org.pyyaml.AnInstance"));
- assertTrue(output1.contains("&id001"));
- assertTrue(output1.contains("&id002"));
- assertTrue(output1.contains("*id001"));
- assertTrue(output1.contains("*id002"));
- assertTrue(output1.contains("foo"));
- assertTrue(output1.contains("bar"));
- Map<AnInstance, AnInstance> value2 = (Map<AnInstance, AnInstance>) yaml.load(output1);
- assertEquals(value.size(), value2.size());
- for (AnInstance tmpInstance : value2.values()) {
- assertSame(tmpInstance.getBar(), tmpInstance.getFoo());
- assertSame(tmpInstance.getBar(), value2);
- assertSame(tmpInstance, value2.get(tmpInstance));
- }
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void testDictSafeConstructor() {
- Map value = new TreeMap();
- value.put("abc", "www");
- value.put("qwerty", value);
- Yaml yaml = new Yaml(new SafeConstructor());
- String output1 = yaml.dump(value);
- assertEquals("&id001\nabc: www\nqwerty: *id001\n", output1);
- Map value2 = (Map) yaml.load(output1);
- assertEquals(2, value2.size());
- assertEquals("www", value2.get("abc"));
- assertTrue(value2.get("qwerty") instanceof Map);
- Map value3 = (Map) value2.get("qwerty");
- assertTrue(value3.get("qwerty") instanceof Map);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void testList() {
- List value = new ArrayList();
- value.add(value);
- value.add("test");
- value.add(new Integer(1));
-
- Yaml yaml = new Yaml();
- String output1 = yaml.dump(value);
- assertEquals("&id001\n- *id001\n- test\n- 1\n", output1);
- List value2 = (List) yaml.load(output1);
- assertEquals(3, value2.size());
- assertEquals(value.size(), value2.size());
- assertSame(value2, value2.get(0));
- // we expect self-reference as 1st element of the list
- // let's remove self-reference and check other "simple" members of the
- // list. otherwise assertEquals will lead us to StackOverflow
- value.remove(0);
- value2.remove(0);
- assertEquals(value, value2);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void testListSafeConstructor() {
- List value = new ArrayList();
- value.add(value);
- value.add("test");
- value.add(new Integer(1));
-
- Yaml yaml = new Yaml(new SafeConstructor());
- String output1 = yaml.dump(value);
- assertEquals("&id001\n- *id001\n- test\n- 1\n", output1);
- List value2 = (List) yaml.load(output1);
- assertEquals(3, value2.size());
- assertEquals(value.size(), value2.size());
- assertSame(value2, value2.get(0));
- // we expect self-reference as 1st element of the list
- // let's remove self-reference and check other "simple" members of the
- // list. otherwise assertEquals will lead us to StackOverflow
- value.remove(0);
- value2.remove(0);
- assertEquals(value, value2);
- }
-
- @SuppressWarnings({ "unchecked", "rawtypes" })
- public void testSet() {
- Set value = new HashSet();
- value.add(new AnInstance(value, value));
- Yaml yaml = new Yaml();
- String output1 = yaml.dump(value);
- Set<AnInstance> value2 = (Set<AnInstance>) yaml.load(output1);
-
- assertEquals(value.size(), value2.size());
- for (AnInstance tmpInstance : value2) {
- assertSame(tmpInstance.getBar(), tmpInstance.getFoo());
- assertSame(tmpInstance.getBar(), value2);
- }
- }
-
- public void testSet2() {
- Set<Object> set = new HashSet<Object>(3);
- set.add("aaa");
- set.add(111);
- set.add(set);
- Yaml yaml = new Yaml();
- try {
- yaml.dump(set);
- fail("Java does not allow a recursive set to be a key for a map.");
- } catch (StackOverflowError e) {
- // ignore
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
+
+public class PyRecursiveTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testDict() {
+ Map<AnInstance, AnInstance> value = new HashMap<AnInstance, AnInstance>();
+ AnInstance instance = new AnInstance(value, value);
+ value.put(instance, instance);
+ Yaml yaml = new Yaml();
+ String output1 = yaml.dump(value);
+ assertTrue(output1.contains("!!org.pyyaml.AnInstance"));
+ assertTrue(output1.contains("&id001"));
+ assertTrue(output1.contains("&id002"));
+ assertTrue(output1.contains("*id001"));
+ assertTrue(output1.contains("*id002"));
+ assertTrue(output1.contains("foo"));
+ assertTrue(output1.contains("bar"));
+ Map<AnInstance, AnInstance> value2 = (Map<AnInstance, AnInstance>) yaml.load(output1);
+ assertEquals(value.size(), value2.size());
+ for (AnInstance tmpInstance : value2.values()) {
+ assertSame(tmpInstance.getBar(), tmpInstance.getFoo());
+ assertSame(tmpInstance.getBar(), value2);
+ assertSame(tmpInstance, value2.get(tmpInstance));
+ }
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testDictSafeConstructor() {
+ Map value = new TreeMap();
+ value.put("abc", "www");
+ value.put("qwerty", value);
+ Yaml yaml = new Yaml(new SafeConstructor());
+ String output1 = yaml.dump(value);
+ assertEquals("&id001\nabc: www\nqwerty: *id001\n", output1);
+ Map value2 = (Map) yaml.load(output1);
+ assertEquals(2, value2.size());
+ assertEquals("www", value2.get("abc"));
+ assertTrue(value2.get("qwerty") instanceof Map);
+ Map value3 = (Map) value2.get("qwerty");
+ assertTrue(value3.get("qwerty") instanceof Map);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testList() {
+ List value = new ArrayList();
+ value.add(value);
+ value.add("test");
+ value.add(new Integer(1));
+
+ Yaml yaml = new Yaml();
+ String output1 = yaml.dump(value);
+ assertEquals("&id001\n- *id001\n- test\n- 1\n", output1);
+ List value2 = (List) yaml.load(output1);
+ assertEquals(3, value2.size());
+ assertEquals(value.size(), value2.size());
+ assertSame(value2, value2.get(0));
+ // we expect self-reference as 1st element of the list
+ // let's remove self-reference and check other "simple" members of the
+ // list. otherwise assertEquals will lead us to StackOverflow
+ value.remove(0);
+ value2.remove(0);
+ assertEquals(value, value2);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testListSafeConstructor() {
+ List value = new ArrayList();
+ value.add(value);
+ value.add("test");
+ value.add(new Integer(1));
+
+ Yaml yaml = new Yaml(new SafeConstructor());
+ String output1 = yaml.dump(value);
+ assertEquals("&id001\n- *id001\n- test\n- 1\n", output1);
+ List value2 = (List) yaml.load(output1);
+ assertEquals(3, value2.size());
+ assertEquals(value.size(), value2.size());
+ assertSame(value2, value2.get(0));
+ // we expect self-reference as 1st element of the list
+ // let's remove self-reference and check other "simple" members of the
+ // list. otherwise assertEquals will lead us to StackOverflow
+ value.remove(0);
+ value2.remove(0);
+ assertEquals(value, value2);
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void testSet() {
+ Set value = new HashSet();
+ value.add(new AnInstance(value, value));
+ Yaml yaml = new Yaml();
+ String output1 = yaml.dump(value);
+ Set<AnInstance> value2 = (Set<AnInstance>) yaml.load(output1);
+
+ assertEquals(value.size(), value2.size());
+ for (AnInstance tmpInstance : value2) {
+ assertSame(tmpInstance.getBar(), tmpInstance.getFoo());
+ assertSame(tmpInstance.getBar(), value2);
+ }
+ }
+
+ public void testSet2() {
+ Set<Object> set = new HashSet<Object>(3);
+ set.add("aaa");
+ set.add(111);
+ set.add(set);
+ Yaml yaml = new Yaml();
+ try {
+ yaml.dump(set);
+ fail("Java does not allow a recursive set to be a key for a map.");
+ } catch (StackOverflowError e) {
+ // ignore
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyStructureTest.java b/src/test/java/org/pyyaml/PyStructureTest.java
index 66a9653..01dc201 100644
--- a/src/test/java/org/pyyaml/PyStructureTest.java
+++ b/src/test/java/org/pyyaml/PyStructureTest.java
@@ -1,303 +1,303 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.composer.Composer;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.events.AliasEvent;
-import org.yaml.snakeyaml.events.CollectionStartEvent;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.ScalarEvent;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.parser.ParserImpl;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.reader.UnicodeReader;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-/**
- * @see imported from PyYAML
- */
-public class PyStructureTest extends PyImportTest {
-
- private void compareEvents(List<Event> events1, List<Event> events2, boolean full) {
- assertEquals(events1.size(), events2.size());
- Iterator<Event> iter1 = events1.iterator();
- Iterator<Event> iter2 = events2.iterator();
- while (iter1.hasNext()) {
- Event event1 = iter1.next();
- Event event2 = iter2.next();
- assertEquals(event1.getClass(), event2.getClass());
- if (event1 instanceof AliasEvent && full) {
- assertEquals(((AliasEvent) event1).getAnchor(), ((AliasEvent) event2).getAnchor());
- }
- if (event1 instanceof CollectionStartEvent) {
- String tag1 = ((CollectionStartEvent) event1).getTag();
- String tag2 = ((CollectionStartEvent) event1).getTag();
- if (tag1 != null && !"!".equals(tag1) && tag2 != null && !"!".equals(tag1)) {
- assertEquals(tag1, tag2);
- }
- }
- if (event1 instanceof ScalarEvent) {
- ScalarEvent scalar1 = (ScalarEvent) event1;
- ScalarEvent scalar2 = (ScalarEvent) event2;
- if (scalar1.getImplicit().bothFalse() && scalar2.getImplicit().bothFalse()) {
- assertEquals(scalar1.getTag(), scalar2.getTag());
- }
- assertEquals(scalar1.getValue(), scalar2.getValue());
- }
- }
- }
-
- public void testParser() {
- File[] files = getStreamsByExtension(".data", true);
- assertTrue("No test files found.", files.length > 0);
- for (File file : files) {
- if (!file.getName().contains("scan-line-b")) {
- continue;
- }
- try {
- InputStream input = new FileInputStream(file);
- List<Event> events1 = parse(input);
- input.close();
- assertFalse(events1.isEmpty());
- int index = file.getAbsolutePath().lastIndexOf('.');
- String canonicalName = file.getAbsolutePath().substring(0, index) + ".canonical";
- File canonical = new File(canonicalName);
- List<Event> events2 = canonicalParse(new FileInputStream(canonical));
- assertFalse(events2.isEmpty());
- compareEvents(events1, events2, false);
- } catch (Exception e) {
- System.out.println("Failed File: " + file);
- // fail("Failed File: " + file + "; " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
- }
-
- public void testParserOnCanonical() {
- File[] canonicalFiles = getStreamsByExtension(".canonical", false);
- assertTrue("No test files found.", canonicalFiles.length > 0);
- for (File file : canonicalFiles) {
- try {
- InputStream input = new FileInputStream(file);
- List<Event> events1 = parse(input);
- input.close();
- assertFalse(events1.isEmpty());
- List<Event> events2 = canonicalParse(new FileInputStream(file));
- assertFalse(events2.isEmpty());
- compareEvents(events1, events2, true);
- } catch (Exception e) {
- System.out.println("Failed File: " + file);
- // fail("Failed File: " + file + "; " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
- }
-
- private void compareNodes(Node node1, Node node2) {
- assertEquals(node1.getClass(), node2.getClass());
- if (node1 instanceof ScalarNode) {
- ScalarNode scalar1 = (ScalarNode) node1;
- ScalarNode scalar2 = (ScalarNode) node2;
- assertEquals(scalar1.getTag(), scalar2.getTag());
- assertEquals(scalar1.getValue(), scalar2.getValue());
- } else {
- if (node1 instanceof SequenceNode) {
- SequenceNode seq1 = (SequenceNode) node1;
- SequenceNode seq2 = (SequenceNode) node2;
- assertEquals(seq1.getTag(), seq2.getTag());
- assertEquals(seq1.getValue().size(), seq2.getValue().size());
- Iterator<Node> iter2 = seq2.getValue().iterator();
- for (Node child1 : seq1.getValue()) {
- Node child2 = iter2.next();
- compareNodes(child1, child2);
- }
- } else {
- MappingNode seq1 = (MappingNode) node1;
- MappingNode seq2 = (MappingNode) node2;
- assertEquals(seq1.getTag(), seq2.getTag());
- assertEquals(seq1.getValue().size(), seq2.getValue().size());
- Iterator<NodeTuple> iter2 = seq2.getValue().iterator();
- for (NodeTuple child1 : seq1.getValue()) {
- NodeTuple child2 = iter2.next();
- compareNodes(child1.getKeyNode(), child2.getKeyNode());
- compareNodes(child1.getValueNode(), child2.getValueNode());
- }
- }
- }
- }
-
- public void testComposer() {
- File[] files = getStreamsByExtension(".data", true);
- assertTrue("No test files found.", files.length > 0);
- for (File file : files) {
- try {
- InputStream input = new FileInputStream(file);
- List<Node> events1 = compose_all(input);
- input.close();
- int index = file.getAbsolutePath().lastIndexOf('.');
- String canonicalName = file.getAbsolutePath().substring(0, index) + ".canonical";
- File canonical = new File(canonicalName);
- InputStream input2 = new FileInputStream(canonical);
- List<Node> events2 = canonical_compose_all(input2);
- input2.close();
- assertEquals(events1.size(), events2.size());
- Iterator<Node> iter1 = events1.iterator();
- Iterator<Node> iter2 = events2.iterator();
- while (iter1.hasNext()) {
- compareNodes(iter1.next(), iter2.next());
- }
- } catch (Exception e) {
- System.out.println("Failed File: " + file);
- // fail("Failed File: " + file + "; " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
- }
-
- private List<Node> compose_all(InputStream file) {
- Composer composer = new Composer(new ParserImpl(new StreamReader(new UnicodeReader(file))),
- new Resolver());
- List<Node> documents = new ArrayList<Node>();
- while (composer.checkNode()) {
- documents.add(composer.getNode());
- }
- return documents;
- }
-
- private List<Node> canonical_compose_all(InputStream file) {
- StreamReader reader = new StreamReader(new UnicodeReader(file));
- StringBuilder buffer = new StringBuilder();
- while (reader.peek() != '\0') {
- buffer.append(reader.peek());
- reader.forward();
- }
- CanonicalParser parser = new CanonicalParser(buffer.toString());
- Composer composer = new Composer(parser, new Resolver());
- List<Node> documents = new ArrayList<Node>();
- while (composer.checkNode()) {
- documents.add(composer.getNode());
- }
- return documents;
- }
-
- class CanonicalLoader extends Yaml {
- public CanonicalLoader() {
- super(new MyConstructor());
- }
-
- @Override
- public Iterable<Object> loadAll(Reader yaml) {
- StreamReader reader = new StreamReader(yaml);
- StringBuilder buffer = new StringBuilder();
- while (reader.peek() != '\0') {
- buffer.append(reader.peek());
- reader.forward();
- }
- CanonicalParser parser = new CanonicalParser(buffer.toString());
- Composer composer = new Composer(parser, resolver);
- this.constructor.setComposer(composer);
- Iterator<Object> result = new Iterator<Object>() {
- public boolean hasNext() {
- return constructor.checkData();
- }
-
- public Object next() {
- return constructor.getData();
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- return new YamlIterable(result);
- }
-
- private class YamlIterable implements Iterable<Object> {
- private Iterator<Object> iterator;
-
- public YamlIterable(Iterator<Object> iterator) {
- this.iterator = iterator;
- }
-
- public Iterator<Object> iterator() {
- return iterator;
- }
-
- }
-
- }
-
- private class MyConstructor extends Constructor {
- public MyConstructor() {
- this.yamlConstructors.put(null, new ConstructUndefined());
- }
-
- private class ConstructUndefined extends AbstractConstruct {
- public Object construct(Node node) {
- return constructScalar((ScalarNode) node);
- }
- }
- }
-
- public void testConstructor() {
- File[] files = getStreamsByExtension(".data", true);
- assertTrue("No test files found.", files.length > 0);
- Yaml myYaml = new Yaml(new MyConstructor());
- Yaml canonicalYaml = new CanonicalLoader();
- for (File file : files) {
- try {
- InputStream input = new FileInputStream(file);
- Iterable<Object> documents1 = myYaml.loadAll(input);
- int index = file.getAbsolutePath().lastIndexOf('.');
- String canonicalName = file.getAbsolutePath().substring(0, index) + ".canonical";
- File canonical = new File(canonicalName);
- InputStream input2 = new FileInputStream(canonical);
- Iterable<Object> documents2 = canonicalYaml.loadAll(input2);
- input2.close();
- Iterator<Object> iter2 = documents2.iterator();
- for (Object object1 : documents1) {
- Object object2 = iter2.next();
- if (object2 != null) {
- assertFalse(System.identityHashCode(object1) == System
- .identityHashCode(object2));
- }
- assertEquals("" + object1, object1, object2);
- }
- input.close();
- } catch (Exception e) {
- System.out.println("Failed File: " + file);
- // fail("Failed File: " + file + "; " + e.getMessage());
- throw new RuntimeException(e);
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.composer.Composer;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.events.AliasEvent;
+import org.yaml.snakeyaml.events.CollectionStartEvent;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.ScalarEvent;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.parser.ParserImpl;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+/**
+ * @see imported from PyYAML
+ */
+public class PyStructureTest extends PyImportTest {
+
+ private void compareEvents(List<Event> events1, List<Event> events2, boolean full) {
+ assertEquals(events1.size(), events2.size());
+ Iterator<Event> iter1 = events1.iterator();
+ Iterator<Event> iter2 = events2.iterator();
+ while (iter1.hasNext()) {
+ Event event1 = iter1.next();
+ Event event2 = iter2.next();
+ assertEquals(event1.getClass(), event2.getClass());
+ if (event1 instanceof AliasEvent && full) {
+ assertEquals(((AliasEvent) event1).getAnchor(), ((AliasEvent) event2).getAnchor());
+ }
+ if (event1 instanceof CollectionStartEvent) {
+ String tag1 = ((CollectionStartEvent) event1).getTag();
+ String tag2 = ((CollectionStartEvent) event1).getTag();
+ if (tag1 != null && !"!".equals(tag1) && tag2 != null && !"!".equals(tag1)) {
+ assertEquals(tag1, tag2);
+ }
+ }
+ if (event1 instanceof ScalarEvent) {
+ ScalarEvent scalar1 = (ScalarEvent) event1;
+ ScalarEvent scalar2 = (ScalarEvent) event2;
+ if (scalar1.getImplicit().bothFalse() && scalar2.getImplicit().bothFalse()) {
+ assertEquals(scalar1.getTag(), scalar2.getTag());
+ }
+ assertEquals(scalar1.getValue(), scalar2.getValue());
+ }
+ }
+ }
+
+ public void testParser() {
+ File[] files = getStreamsByExtension(".data", true);
+ assertTrue("No test files found.", files.length > 0);
+ for (File file : files) {
+ if (!file.getName().contains("scan-line-b")) {
+ continue;
+ }
+ try {
+ InputStream input = new FileInputStream(file);
+ List<Event> events1 = parse(input);
+ input.close();
+ assertFalse(events1.isEmpty());
+ int index = file.getAbsolutePath().lastIndexOf('.');
+ String canonicalName = file.getAbsolutePath().substring(0, index) + ".canonical";
+ File canonical = new File(canonicalName);
+ List<Event> events2 = canonicalParse(new FileInputStream(canonical));
+ assertFalse(events2.isEmpty());
+ compareEvents(events1, events2, false);
+ } catch (Exception e) {
+ System.out.println("Failed File: " + file);
+ // fail("Failed File: " + file + "; " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ public void testParserOnCanonical() {
+ File[] canonicalFiles = getStreamsByExtension(".canonical", false);
+ assertTrue("No test files found.", canonicalFiles.length > 0);
+ for (File file : canonicalFiles) {
+ try {
+ InputStream input = new FileInputStream(file);
+ List<Event> events1 = parse(input);
+ input.close();
+ assertFalse(events1.isEmpty());
+ List<Event> events2 = canonicalParse(new FileInputStream(file));
+ assertFalse(events2.isEmpty());
+ compareEvents(events1, events2, true);
+ } catch (Exception e) {
+ System.out.println("Failed File: " + file);
+ // fail("Failed File: " + file + "; " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private void compareNodes(Node node1, Node node2) {
+ assertEquals(node1.getClass(), node2.getClass());
+ if (node1 instanceof ScalarNode) {
+ ScalarNode scalar1 = (ScalarNode) node1;
+ ScalarNode scalar2 = (ScalarNode) node2;
+ assertEquals(scalar1.getTag(), scalar2.getTag());
+ assertEquals(scalar1.getValue(), scalar2.getValue());
+ } else {
+ if (node1 instanceof SequenceNode) {
+ SequenceNode seq1 = (SequenceNode) node1;
+ SequenceNode seq2 = (SequenceNode) node2;
+ assertEquals(seq1.getTag(), seq2.getTag());
+ assertEquals(seq1.getValue().size(), seq2.getValue().size());
+ Iterator<Node> iter2 = seq2.getValue().iterator();
+ for (Node child1 : seq1.getValue()) {
+ Node child2 = iter2.next();
+ compareNodes(child1, child2);
+ }
+ } else {
+ MappingNode seq1 = (MappingNode) node1;
+ MappingNode seq2 = (MappingNode) node2;
+ assertEquals(seq1.getTag(), seq2.getTag());
+ assertEquals(seq1.getValue().size(), seq2.getValue().size());
+ Iterator<NodeTuple> iter2 = seq2.getValue().iterator();
+ for (NodeTuple child1 : seq1.getValue()) {
+ NodeTuple child2 = iter2.next();
+ compareNodes(child1.getKeyNode(), child2.getKeyNode());
+ compareNodes(child1.getValueNode(), child2.getValueNode());
+ }
+ }
+ }
+ }
+
+ public void testComposer() {
+ File[] files = getStreamsByExtension(".data", true);
+ assertTrue("No test files found.", files.length > 0);
+ for (File file : files) {
+ try {
+ InputStream input = new FileInputStream(file);
+ List<Node> events1 = compose_all(input);
+ input.close();
+ int index = file.getAbsolutePath().lastIndexOf('.');
+ String canonicalName = file.getAbsolutePath().substring(0, index) + ".canonical";
+ File canonical = new File(canonicalName);
+ InputStream input2 = new FileInputStream(canonical);
+ List<Node> events2 = canonical_compose_all(input2);
+ input2.close();
+ assertEquals(events1.size(), events2.size());
+ Iterator<Node> iter1 = events1.iterator();
+ Iterator<Node> iter2 = events2.iterator();
+ while (iter1.hasNext()) {
+ compareNodes(iter1.next(), iter2.next());
+ }
+ } catch (Exception e) {
+ System.out.println("Failed File: " + file);
+ // fail("Failed File: " + file + "; " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ private List<Node> compose_all(InputStream file) {
+ Composer composer = new Composer(new ParserImpl(new StreamReader(new UnicodeReader(file))),
+ new Resolver());
+ List<Node> documents = new ArrayList<Node>();
+ while (composer.checkNode()) {
+ documents.add(composer.getNode());
+ }
+ return documents;
+ }
+
+ private List<Node> canonical_compose_all(InputStream file) {
+ StreamReader reader = new StreamReader(new UnicodeReader(file));
+ StringBuilder buffer = new StringBuilder();
+ while (reader.peek() != '\0') {
+ buffer.append(reader.peek());
+ reader.forward();
+ }
+ CanonicalParser parser = new CanonicalParser(buffer.toString());
+ Composer composer = new Composer(parser, new Resolver());
+ List<Node> documents = new ArrayList<Node>();
+ while (composer.checkNode()) {
+ documents.add(composer.getNode());
+ }
+ return documents;
+ }
+
+ class CanonicalLoader extends Yaml {
+ public CanonicalLoader() {
+ super(new MyConstructor());
+ }
+
+ @Override
+ public Iterable<Object> loadAll(Reader yaml) {
+ StreamReader reader = new StreamReader(yaml);
+ StringBuilder buffer = new StringBuilder();
+ while (reader.peek() != '\0') {
+ buffer.append(reader.peek());
+ reader.forward();
+ }
+ CanonicalParser parser = new CanonicalParser(buffer.toString());
+ Composer composer = new Composer(parser, resolver);
+ this.constructor.setComposer(composer);
+ Iterator<Object> result = new Iterator<Object>() {
+ public boolean hasNext() {
+ return constructor.checkData();
+ }
+
+ public Object next() {
+ return constructor.getData();
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ return new YamlIterable(result);
+ }
+
+ private class YamlIterable implements Iterable<Object> {
+ private Iterator<Object> iterator;
+
+ public YamlIterable(Iterator<Object> iterator) {
+ this.iterator = iterator;
+ }
+
+ public Iterator<Object> iterator() {
+ return iterator;
+ }
+
+ }
+
+ }
+
+ private class MyConstructor extends Constructor {
+ public MyConstructor() {
+ this.yamlConstructors.put(null, new ConstructUndefined());
+ }
+
+ private class ConstructUndefined extends AbstractConstruct {
+ public Object construct(Node node) {
+ return constructScalar((ScalarNode) node);
+ }
+ }
+ }
+
+ public void testConstructor() {
+ File[] files = getStreamsByExtension(".data", true);
+ assertTrue("No test files found.", files.length > 0);
+ Yaml myYaml = new Yaml(new MyConstructor());
+ Yaml canonicalYaml = new CanonicalLoader();
+ for (File file : files) {
+ try {
+ InputStream input = new FileInputStream(file);
+ Iterable<Object> documents1 = myYaml.loadAll(input);
+ int index = file.getAbsolutePath().lastIndexOf('.');
+ String canonicalName = file.getAbsolutePath().substring(0, index) + ".canonical";
+ File canonical = new File(canonicalName);
+ InputStream input2 = new FileInputStream(canonical);
+ Iterable<Object> documents2 = canonicalYaml.loadAll(input2);
+ input2.close();
+ Iterator<Object> iter2 = documents2.iterator();
+ for (Object object1 : documents1) {
+ Object object2 = iter2.next();
+ if (object2 != null) {
+ assertFalse(System.identityHashCode(object1) == System
+ .identityHashCode(object2));
+ }
+ assertEquals("" + object1, object1, object2);
+ }
+ input.close();
+ } catch (Exception e) {
+ System.out.println("Failed File: " + file);
+ // fail("Failed File: " + file + "; " + e.getMessage());
+ throw new RuntimeException(e);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/pyyaml/PyTokensTest.java b/src/test/java/org/pyyaml/PyTokensTest.java
index 982b5ac..e2dd3fe 100644
--- a/src/test/java/org/pyyaml/PyTokensTest.java
+++ b/src/test/java/org/pyyaml/PyTokensTest.java
@@ -1,149 +1,149 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.pyyaml;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.reader.UnicodeReader;
-import org.yaml.snakeyaml.scanner.Scanner;
-import org.yaml.snakeyaml.scanner.ScannerImpl;
-import org.yaml.snakeyaml.tokens.AliasToken;
-import org.yaml.snakeyaml.tokens.AnchorToken;
-import org.yaml.snakeyaml.tokens.BlockEndToken;
-import org.yaml.snakeyaml.tokens.BlockEntryToken;
-import org.yaml.snakeyaml.tokens.BlockMappingStartToken;
-import org.yaml.snakeyaml.tokens.BlockSequenceStartToken;
-import org.yaml.snakeyaml.tokens.DirectiveToken;
-import org.yaml.snakeyaml.tokens.DocumentEndToken;
-import org.yaml.snakeyaml.tokens.DocumentStartToken;
-import org.yaml.snakeyaml.tokens.FlowEntryToken;
-import org.yaml.snakeyaml.tokens.FlowMappingEndToken;
-import org.yaml.snakeyaml.tokens.FlowMappingStartToken;
-import org.yaml.snakeyaml.tokens.FlowSequenceEndToken;
-import org.yaml.snakeyaml.tokens.FlowSequenceStartToken;
-import org.yaml.snakeyaml.tokens.KeyToken;
-import org.yaml.snakeyaml.tokens.ScalarToken;
-import org.yaml.snakeyaml.tokens.StreamEndToken;
-import org.yaml.snakeyaml.tokens.StreamStartToken;
-import org.yaml.snakeyaml.tokens.TagToken;
-import org.yaml.snakeyaml.tokens.Token;
-import org.yaml.snakeyaml.tokens.ValueToken;
-
-/**
- * @see imported from PyYAML
- */
-public class PyTokensTest extends PyImportTest {
-
- public void testTokens() throws FileNotFoundException {
- Map<Class<?>, String> replaces = new HashMap<Class<?>, String>();
- replaces.put(DirectiveToken.class, "%");
- replaces.put(DocumentStartToken.class, "---");
- replaces.put(DocumentEndToken.class, "...");
- replaces.put(AliasToken.class, "*");
- replaces.put(AnchorToken.class, "&");
- replaces.put(TagToken.class, "!");
- replaces.put(ScalarToken.class, "_");
- replaces.put(BlockSequenceStartToken.class, "[[");
- replaces.put(BlockMappingStartToken.class, "{{");
- replaces.put(BlockEndToken.class, "]}");
- replaces.put(FlowSequenceStartToken.class, "[");
- replaces.put(FlowSequenceEndToken.class, "]");
- replaces.put(FlowMappingStartToken.class, "{");
- replaces.put(FlowMappingEndToken.class, "}");
- replaces.put(BlockEntryToken.class, ",");
- replaces.put(FlowEntryToken.class, ",");
- replaces.put(KeyToken.class, "?");
- replaces.put(ValueToken.class, ":");
- //
- File[] tokensFiles = getStreamsByExtension(".tokens");
- assertTrue("No test files found.", tokensFiles.length > 0);
- for (int i = 0; i < tokensFiles.length; i++) {
- String name = tokensFiles[i].getName();
- int position = name.lastIndexOf('.');
- String dataName = name.substring(0, position) + ".data";
- //
- String tokenFileData = getResource(name);
- String[] split = tokenFileData.split("\\s+");
- List<String> tokens2 = new ArrayList<String>();
- for (int j = 0; j < split.length; j++) {
- tokens2.add(split[j]);
- }
- //
- List<String> tokens1 = new ArrayList<String>();
- StreamReader reader = new StreamReader(new UnicodeReader(new FileInputStream(
- getFileByName(dataName))));
- Scanner scanner = new ScannerImpl(reader);
- try {
- while (scanner.checkToken(new Token.ID[0])) {
- Token token = scanner.getToken();
- if (!(token instanceof StreamStartToken || token instanceof StreamEndToken)) {
- String replacement = replaces.get(token.getClass());
- tokens1.add(replacement);
- }
- }
- assertEquals(tokenFileData, tokens1.size(), tokens2.size());
- assertEquals(tokens1, tokens2);
- } catch (RuntimeException e) {
- System.out.println("File name: \n" + tokensFiles[i].getName());
- String data = getResource(tokensFiles[i].getName());
- System.out.println("Data: \n" + data);
- System.out.println("Tokens:");
- for (String token : tokens1) {
- System.out.println(token);
- }
- fail("Cannot scan: " + tokensFiles[i]);
- }
- }
- }
-
- public void testScanner() throws IOException {
- File[] files = getStreamsByExtension(".data", true);
- assertTrue("No test files found.", files.length > 0);
- for (File file : files) {
- List<String> tokens = new ArrayList<String>();
- InputStream input = new FileInputStream(file);
- StreamReader reader = new StreamReader(new UnicodeReader(input));
- Scanner scanner = new ScannerImpl(reader);
- try {
- while (scanner.checkToken(new Token.ID[0])) {
- Token token = scanner.getToken();
- tokens.add(token.getClass().getName());
- }
- } catch (RuntimeException e) {
- System.out.println("File name: \n" + file.getName());
- String data = getResource(file.getName());
- System.out.println("Data: \n" + data);
- System.out.println("Tokens:");
- for (String token : tokens) {
- System.out.println(token);
- }
- fail("Cannot scan: " + file + "; " + e.getMessage());
- } finally {
- input.close();
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.pyyaml;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.reader.UnicodeReader;
+import org.yaml.snakeyaml.scanner.Scanner;
+import org.yaml.snakeyaml.scanner.ScannerImpl;
+import org.yaml.snakeyaml.tokens.AliasToken;
+import org.yaml.snakeyaml.tokens.AnchorToken;
+import org.yaml.snakeyaml.tokens.BlockEndToken;
+import org.yaml.snakeyaml.tokens.BlockEntryToken;
+import org.yaml.snakeyaml.tokens.BlockMappingStartToken;
+import org.yaml.snakeyaml.tokens.BlockSequenceStartToken;
+import org.yaml.snakeyaml.tokens.DirectiveToken;
+import org.yaml.snakeyaml.tokens.DocumentEndToken;
+import org.yaml.snakeyaml.tokens.DocumentStartToken;
+import org.yaml.snakeyaml.tokens.FlowEntryToken;
+import org.yaml.snakeyaml.tokens.FlowMappingEndToken;
+import org.yaml.snakeyaml.tokens.FlowMappingStartToken;
+import org.yaml.snakeyaml.tokens.FlowSequenceEndToken;
+import org.yaml.snakeyaml.tokens.FlowSequenceStartToken;
+import org.yaml.snakeyaml.tokens.KeyToken;
+import org.yaml.snakeyaml.tokens.ScalarToken;
+import org.yaml.snakeyaml.tokens.StreamEndToken;
+import org.yaml.snakeyaml.tokens.StreamStartToken;
+import org.yaml.snakeyaml.tokens.TagToken;
+import org.yaml.snakeyaml.tokens.Token;
+import org.yaml.snakeyaml.tokens.ValueToken;
+
+/**
+ * @see imported from PyYAML
+ */
+public class PyTokensTest extends PyImportTest {
+
+ public void testTokens() throws FileNotFoundException {
+ Map<Class<?>, String> replaces = new HashMap<Class<?>, String>();
+ replaces.put(DirectiveToken.class, "%");
+ replaces.put(DocumentStartToken.class, "---");
+ replaces.put(DocumentEndToken.class, "...");
+ replaces.put(AliasToken.class, "*");
+ replaces.put(AnchorToken.class, "&");
+ replaces.put(TagToken.class, "!");
+ replaces.put(ScalarToken.class, "_");
+ replaces.put(BlockSequenceStartToken.class, "[[");
+ replaces.put(BlockMappingStartToken.class, "{{");
+ replaces.put(BlockEndToken.class, "]}");
+ replaces.put(FlowSequenceStartToken.class, "[");
+ replaces.put(FlowSequenceEndToken.class, "]");
+ replaces.put(FlowMappingStartToken.class, "{");
+ replaces.put(FlowMappingEndToken.class, "}");
+ replaces.put(BlockEntryToken.class, ",");
+ replaces.put(FlowEntryToken.class, ",");
+ replaces.put(KeyToken.class, "?");
+ replaces.put(ValueToken.class, ":");
+ //
+ File[] tokensFiles = getStreamsByExtension(".tokens");
+ assertTrue("No test files found.", tokensFiles.length > 0);
+ for (int i = 0; i < tokensFiles.length; i++) {
+ String name = tokensFiles[i].getName();
+ int position = name.lastIndexOf('.');
+ String dataName = name.substring(0, position) + ".data";
+ //
+ String tokenFileData = getResource(name);
+ String[] split = tokenFileData.split("\\s+");
+ List<String> tokens2 = new ArrayList<String>();
+ for (int j = 0; j < split.length; j++) {
+ tokens2.add(split[j]);
+ }
+ //
+ List<String> tokens1 = new ArrayList<String>();
+ StreamReader reader = new StreamReader(new UnicodeReader(new FileInputStream(
+ getFileByName(dataName))));
+ Scanner scanner = new ScannerImpl(reader);
+ try {
+ while (scanner.checkToken(new Token.ID[0])) {
+ Token token = scanner.getToken();
+ if (!(token instanceof StreamStartToken || token instanceof StreamEndToken)) {
+ String replacement = replaces.get(token.getClass());
+ tokens1.add(replacement);
+ }
+ }
+ assertEquals(tokenFileData, tokens1.size(), tokens2.size());
+ assertEquals(tokens1, tokens2);
+ } catch (RuntimeException e) {
+ System.out.println("File name: \n" + tokensFiles[i].getName());
+ String data = getResource(tokensFiles[i].getName());
+ System.out.println("Data: \n" + data);
+ System.out.println("Tokens:");
+ for (String token : tokens1) {
+ System.out.println(token);
+ }
+ fail("Cannot scan: " + tokensFiles[i]);
+ }
+ }
+ }
+
+ public void testScanner() throws IOException {
+ File[] files = getStreamsByExtension(".data", true);
+ assertTrue("No test files found.", files.length > 0);
+ for (File file : files) {
+ List<String> tokens = new ArrayList<String>();
+ InputStream input = new FileInputStream(file);
+ StreamReader reader = new StreamReader(new UnicodeReader(input));
+ Scanner scanner = new ScannerImpl(reader);
+ try {
+ while (scanner.checkToken(new Token.ID[0])) {
+ Token token = scanner.getToken();
+ tokens.add(token.getClass().getName());
+ }
+ } catch (RuntimeException e) {
+ System.out.println("File name: \n" + file.getName());
+ String data = getResource(file.getName());
+ System.out.println("Data: \n" + data);
+ System.out.println("Tokens:");
+ for (String token : tokens) {
+ System.out.println(token);
+ }
+ fail("Cannot scan: " + file + "; " + e.getMessage());
+ } finally {
+ input.close();
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Address.java b/src/test/java/org/yaml/snakeyaml/Address.java
index 01a4edb..2c78a10 100644
--- a/src/test/java/org/yaml/snakeyaml/Address.java
+++ b/src/test/java/org/yaml/snakeyaml/Address.java
@@ -1,24 +1,24 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-public class Address {
- public String lines;
- public String city;
- public String state;
- public String postal;
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+public class Address {
+ public String lines;
+ public String city;
+ public String state;
+ public String postal;
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/BinaryBean.java b/src/test/java/org/yaml/snakeyaml/BinaryBean.java
index 26ccb11..fc893a5 100644
--- a/src/test/java/org/yaml/snakeyaml/BinaryBean.java
+++ b/src/test/java/org/yaml/snakeyaml/BinaryBean.java
@@ -1,39 +1,39 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-public class BinaryBean {
- byte[] data;
- int id;
-
- public byte[] getData() {
- return data;
- }
-
- public void setData(byte[] data) {
- this.data = data;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+public class BinaryBean {
+ byte[] data;
+ int id;
+
+ public byte[] getData() {
+ return data;
+ }
+
+ public void setData(byte[] data) {
+ this.data = data;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/BinaryJavaBeanTest.java b/src/test/java/org/yaml/snakeyaml/BinaryJavaBeanTest.java
index 4536cd7..f31a95f 100644
--- a/src/test/java/org/yaml/snakeyaml/BinaryJavaBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/BinaryJavaBeanTest.java
@@ -1,36 +1,36 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import junit.framework.TestCase;
-
-public class BinaryJavaBeanTest extends TestCase {
- public void testBeanTest() {
- BinaryBean bean = new BinaryBean();
- bean.setId(1);
- byte[] bytes = new byte[] { 1, 7, 9, 31, 65 };
- bean.setData(bytes);
- Yaml yaml = new Yaml();
- String output = yaml.dump(bean);
- String etalon = "!!org.yaml.snakeyaml.BinaryBean\ndata: !!binary |-\n AQcJH0E=\nid: 1\n";
- assertEquals(etalon, output);
- // load
- BinaryBean bean2 = (BinaryBean) yaml.load(output);
- assertEquals(1, bean2.getId());
- assertEquals(new String(bytes), new String(bean2.getData()));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import junit.framework.TestCase;
+
+public class BinaryJavaBeanTest extends TestCase {
+ public void testBeanTest() {
+ BinaryBean bean = new BinaryBean();
+ bean.setId(1);
+ byte[] bytes = new byte[] { 1, 7, 9, 31, 65 };
+ bean.setData(bytes);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(bean);
+ String etalon = "!!org.yaml.snakeyaml.BinaryBean\ndata: !!binary |-\n AQcJH0E=\nid: 1\n";
+ assertEquals(etalon, output);
+ // load
+ BinaryBean bean2 = (BinaryBean) yaml.load(output);
+ assertEquals(1, bean2.getId());
+ assertEquals(new String(bytes), new String(bean2.getData()));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Chapter2_1Test.java b/src/test/java/org/yaml/snakeyaml/Chapter2_1Test.java
index 123238f..47be540 100644
--- a/src/test/java/org/yaml/snakeyaml/Chapter2_1Test.java
+++ b/src/test/java/org/yaml/snakeyaml/Chapter2_1Test.java
@@ -1,109 +1,109 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-/**
- * Test Chapter 2.1 from the YAML specification
- *
- * @author py4fun
- * @see http://yaml.org/spec/1.1/
- */
-public class Chapter2_1Test extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testExample_2_1() {
- YamlDocument document = new YamlDocument("example2_1.yaml");
- List<String> list = (List<String>) document.getNativeData();
- assertEquals(3, list.size());
- assertEquals("Mark McGwire", list.get(0));
- assertEquals("Sammy Sosa", list.get(1));
- assertEquals("Ken Griffey", list.get(2));
- assertEquals("[Mark McGwire, Sammy Sosa, Ken Griffey]\n", document.getPresentation());
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_2() {
- YamlDocument document = new YamlDocument("example2_2.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(3, map.size());
- assertEquals("Expect 65 to be a Integer", Integer.class, map.get("hr").getClass());
- assertEquals(new Integer(65), map.get("hr"));
- assertEquals(new Float(0.278), new Float("0.278"));
- assertEquals("Expect 0.278 to be a Float", Double.class, map.get("avg").getClass());
- assertEquals(new Double(0.278), map.get("avg"));
- assertEquals("Expect 147 to be an Integer", Integer.class, map.get("rbi").getClass());
- assertEquals(new Integer(147), map.get("rbi"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_3() {
- YamlDocument document = new YamlDocument("example2_3.yaml");
- Map<String, List<String>> map = (Map<String, List<String>>) document.getNativeData();
- assertEquals(2, map.size());
- List<String> list1 = map.get("american");
- assertEquals(3, list1.size());
- assertEquals("Boston Red Sox", list1.get(0));
- assertEquals("Detroit Tigers", list1.get(1));
- assertEquals("New York Yankees", list1.get(2));
- List<String> list2 = map.get("national");
- assertEquals(3, list2.size());
- assertEquals("New York Mets", list2.get(0));
- assertEquals("Chicago Cubs", list2.get(1));
- assertEquals("Atlanta Braves", list2.get(2));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_4() {
- YamlDocument document = new YamlDocument("example2_4.yaml");
- List<Map<String, Object>> list = (List<Map<String, Object>>) document.getNativeData();
- assertEquals(2, list.size());
- Map<String, Object> map1 = list.get(0);
- assertEquals(3, map1.size());
- assertEquals("Mark McGwire", map1.get("name"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_5() {
- YamlDocument document = new YamlDocument("example2_5.yaml");
- List<List<Object>> list = (List<List<Object>>) document.getNativeData();
- assertEquals(3, list.size());
- List<Object> list1 = list.get(0);
- assertEquals(3, list1.size());
- assertEquals("name", list1.get(0));
- assertEquals("hr", list1.get(1));
- assertEquals("avg", list1.get(2));
- assertEquals(3, list.get(1).size());
- assertEquals(3, list.get(2).size());
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_6() {
- YamlDocument document = new YamlDocument("example2_6.yaml");
- Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) document
- .getNativeData();
- assertEquals(2, map.size());
- Map<String, Object> map1 = map.get("Mark McGwire");
- assertEquals(2, map1.size());
- Map<String, Object> map2 = map.get("Sammy Sosa");
- assertEquals(2, map2.size());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Test Chapter 2.1 from the YAML specification
+ *
+ * @author py4fun
+ * @see http://yaml.org/spec/1.1/
+ */
+public class Chapter2_1Test extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_1() {
+ YamlDocument document = new YamlDocument("example2_1.yaml");
+ List<String> list = (List<String>) document.getNativeData();
+ assertEquals(3, list.size());
+ assertEquals("Mark McGwire", list.get(0));
+ assertEquals("Sammy Sosa", list.get(1));
+ assertEquals("Ken Griffey", list.get(2));
+ assertEquals("[Mark McGwire, Sammy Sosa, Ken Griffey]\n", document.getPresentation());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_2() {
+ YamlDocument document = new YamlDocument("example2_2.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(3, map.size());
+ assertEquals("Expect 65 to be a Integer", Integer.class, map.get("hr").getClass());
+ assertEquals(new Integer(65), map.get("hr"));
+ assertEquals(new Float(0.278), new Float("0.278"));
+ assertEquals("Expect 0.278 to be a Float", Double.class, map.get("avg").getClass());
+ assertEquals(new Double(0.278), map.get("avg"));
+ assertEquals("Expect 147 to be an Integer", Integer.class, map.get("rbi").getClass());
+ assertEquals(new Integer(147), map.get("rbi"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_3() {
+ YamlDocument document = new YamlDocument("example2_3.yaml");
+ Map<String, List<String>> map = (Map<String, List<String>>) document.getNativeData();
+ assertEquals(2, map.size());
+ List<String> list1 = map.get("american");
+ assertEquals(3, list1.size());
+ assertEquals("Boston Red Sox", list1.get(0));
+ assertEquals("Detroit Tigers", list1.get(1));
+ assertEquals("New York Yankees", list1.get(2));
+ List<String> list2 = map.get("national");
+ assertEquals(3, list2.size());
+ assertEquals("New York Mets", list2.get(0));
+ assertEquals("Chicago Cubs", list2.get(1));
+ assertEquals("Atlanta Braves", list2.get(2));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_4() {
+ YamlDocument document = new YamlDocument("example2_4.yaml");
+ List<Map<String, Object>> list = (List<Map<String, Object>>) document.getNativeData();
+ assertEquals(2, list.size());
+ Map<String, Object> map1 = list.get(0);
+ assertEquals(3, map1.size());
+ assertEquals("Mark McGwire", map1.get("name"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_5() {
+ YamlDocument document = new YamlDocument("example2_5.yaml");
+ List<List<Object>> list = (List<List<Object>>) document.getNativeData();
+ assertEquals(3, list.size());
+ List<Object> list1 = list.get(0);
+ assertEquals(3, list1.size());
+ assertEquals("name", list1.get(0));
+ assertEquals("hr", list1.get(1));
+ assertEquals("avg", list1.get(2));
+ assertEquals(3, list.get(1).size());
+ assertEquals(3, list.get(2).size());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_6() {
+ YamlDocument document = new YamlDocument("example2_6.yaml");
+ Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) document
+ .getNativeData();
+ assertEquals(2, map.size());
+ Map<String, Object> map1 = map.get("Mark McGwire");
+ assertEquals(2, map1.size());
+ Map<String, Object> map2 = map.get("Sammy Sosa");
+ assertEquals(2, map2.size());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Chapter2_2Test.java b/src/test/java/org/yaml/snakeyaml/Chapter2_2Test.java
index 5f277c4..39fd5d9 100644
--- a/src/test/java/org/yaml/snakeyaml/Chapter2_2Test.java
+++ b/src/test/java/org/yaml/snakeyaml/Chapter2_2Test.java
@@ -1,114 +1,114 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-/**
- * Test Chapter 2.2 from the YAML specification
- *
- * @author py4fun
- * @see http://yaml.org/spec/1.1/
- */
-public class Chapter2_2Test extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testExample_2_7() {
- YamlStream resource = new YamlStream("example2_7.yaml");
- List<Object> list = (List<Object>) resource.getNativeData();
- assertEquals(2, list.size());
- List<String> list1 = (List<String>) list.get(0);
- assertEquals(3, list1.size());
- assertEquals("Mark McGwire", list1.get(0));
- assertEquals("Sammy Sosa", list1.get(1));
- assertEquals("Ken Griffey", list1.get(2));
- List<String> list2 = (List<String>) list.get(1);
- assertEquals(2, list2.size());
- assertEquals("Chicago Cubs", list2.get(0));
- assertEquals("St Louis Cardinals", list2.get(1));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_8() {
- YamlStream resource = new YamlStream("example2_8.yaml");
- List<Object> list = (List<Object>) resource.getNativeData();
- assertEquals(2, list.size());
- Map<String, String> map1 = (Map<String, String>) list.get(0);
- assertEquals(3, map1.size());
- assertEquals(new Integer(72200), map1.get("time"));
- assertEquals("Sammy Sosa", map1.get("player"));
- assertEquals("strike (miss)", map1.get("action"));
- Map<String, String> map2 = (Map<String, String>) list.get(1);
- assertEquals(3, map2.size());
- assertEquals(new Integer(72227), map2.get("time"));
- assertEquals("Sammy Sosa", map2.get("player"));
- assertEquals("grand slam", map2.get("action"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_9() {
- YamlDocument document = new YamlDocument("example2_9.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(map.toString(), 2, map.size());
- List<String> list1 = (List<String>) map.get("hr");
- assertEquals(2, list1.size());
- assertEquals("Mark McGwire", list1.get(0));
- assertEquals("Sammy Sosa", list1.get(1));
- List<String> list2 = (List<String>) map.get("rbi");
- assertEquals(2, list2.size());
- assertEquals("Sammy Sosa", list2.get(0));
- assertEquals("Ken Griffey", list2.get(1));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_10() {
- YamlDocument document = new YamlDocument("example2_10.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals("Examples 2.9 and 2.10 must be identical.",
- new YamlDocument("example2_9.yaml").getNativeData(), map);
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_11() {
- YamlDocument document = new YamlDocument("example2_11.yaml");
- Map<Object, Object> map = (Map<Object, Object>) document.getNativeData();
- assertEquals(2, map.size());
- for (Object key : map.keySet()) {
- List<String> list = (List<String>) key;
- assertEquals(2, list.size());
- }
- }
-
- public void testExample_2_12() {
- YamlDocument document = new YamlDocument("example2_12.yaml");
- @SuppressWarnings("unchecked")
- List<Map<Object, Object>> list = (List<Map<Object, Object>>) document.getNativeData();
- assertEquals(3, list.size());
- Map<Object, Object> map1 = (Map<Object, Object>) list.get(0);
- assertEquals(2, map1.size());
- assertEquals("Super Hoop", map1.get("item"));
- Map<Object, Object> map2 = (Map<Object, Object>) list.get(1);
- assertEquals(2, map2.size());
- assertEquals("Basketball", map2.get("item"));
- Map<Object, Object> map3 = (Map<Object, Object>) list.get(2);
- assertEquals(2, map3.size());
- assertEquals("Big Shoes", map3.get("item"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Test Chapter 2.2 from the YAML specification
+ *
+ * @author py4fun
+ * @see http://yaml.org/spec/1.1/
+ */
+public class Chapter2_2Test extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_7() {
+ YamlStream resource = new YamlStream("example2_7.yaml");
+ List<Object> list = (List<Object>) resource.getNativeData();
+ assertEquals(2, list.size());
+ List<String> list1 = (List<String>) list.get(0);
+ assertEquals(3, list1.size());
+ assertEquals("Mark McGwire", list1.get(0));
+ assertEquals("Sammy Sosa", list1.get(1));
+ assertEquals("Ken Griffey", list1.get(2));
+ List<String> list2 = (List<String>) list.get(1);
+ assertEquals(2, list2.size());
+ assertEquals("Chicago Cubs", list2.get(0));
+ assertEquals("St Louis Cardinals", list2.get(1));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_8() {
+ YamlStream resource = new YamlStream("example2_8.yaml");
+ List<Object> list = (List<Object>) resource.getNativeData();
+ assertEquals(2, list.size());
+ Map<String, String> map1 = (Map<String, String>) list.get(0);
+ assertEquals(3, map1.size());
+ assertEquals(new Integer(72200), map1.get("time"));
+ assertEquals("Sammy Sosa", map1.get("player"));
+ assertEquals("strike (miss)", map1.get("action"));
+ Map<String, String> map2 = (Map<String, String>) list.get(1);
+ assertEquals(3, map2.size());
+ assertEquals(new Integer(72227), map2.get("time"));
+ assertEquals("Sammy Sosa", map2.get("player"));
+ assertEquals("grand slam", map2.get("action"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_9() {
+ YamlDocument document = new YamlDocument("example2_9.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(map.toString(), 2, map.size());
+ List<String> list1 = (List<String>) map.get("hr");
+ assertEquals(2, list1.size());
+ assertEquals("Mark McGwire", list1.get(0));
+ assertEquals("Sammy Sosa", list1.get(1));
+ List<String> list2 = (List<String>) map.get("rbi");
+ assertEquals(2, list2.size());
+ assertEquals("Sammy Sosa", list2.get(0));
+ assertEquals("Ken Griffey", list2.get(1));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_10() {
+ YamlDocument document = new YamlDocument("example2_10.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals("Examples 2.9 and 2.10 must be identical.",
+ new YamlDocument("example2_9.yaml").getNativeData(), map);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_11() {
+ YamlDocument document = new YamlDocument("example2_11.yaml");
+ Map<Object, Object> map = (Map<Object, Object>) document.getNativeData();
+ assertEquals(2, map.size());
+ for (Object key : map.keySet()) {
+ List<String> list = (List<String>) key;
+ assertEquals(2, list.size());
+ }
+ }
+
+ public void testExample_2_12() {
+ YamlDocument document = new YamlDocument("example2_12.yaml");
+ @SuppressWarnings("unchecked")
+ List<Map<Object, Object>> list = (List<Map<Object, Object>>) document.getNativeData();
+ assertEquals(3, list.size());
+ Map<Object, Object> map1 = (Map<Object, Object>) list.get(0);
+ assertEquals(2, map1.size());
+ assertEquals("Super Hoop", map1.get("item"));
+ Map<Object, Object> map2 = (Map<Object, Object>) list.get(1);
+ assertEquals(2, map2.size());
+ assertEquals("Basketball", map2.get("item"));
+ Map<Object, Object> map3 = (Map<Object, Object>) list.get(2);
+ assertEquals(2, map3.size());
+ assertEquals("Big Shoes", map3.get("item"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Chapter2_3Test.java b/src/test/java/org/yaml/snakeyaml/Chapter2_3Test.java
index 5d19e08..3d08b9b 100644
--- a/src/test/java/org/yaml/snakeyaml/Chapter2_3Test.java
+++ b/src/test/java/org/yaml/snakeyaml/Chapter2_3Test.java
@@ -1,136 +1,136 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.InputStream;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
-
-/**
- * Test Chapter 2.3 from the YAML specification
- *
- * @author py4fun
- * @see http://yaml.org/spec/1.1/
- */
-public class Chapter2_3Test extends TestCase {
-
- public void testExample_2_13() {
- YamlDocument document = new YamlDocument("example2_13.yaml");
- String data = (String) document.getNativeData();
- assertEquals("\\//||\\/||\n// || ||__\n", data);
- }
-
- public void testExample_2_14() {
- YamlDocument document = new YamlDocument("example2_14.yaml");
- String data = (String) document.getNativeData();
- assertEquals("Mark McGwire's year was crippled by a knee injury.", data);
- }
-
- public void testExample_2_15() {
- String etalon = "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n";
- InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
- YamlDocument.ROOT + "example2_15.yaml");
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.FOLDED);
- Yaml yaml = new Yaml(options);
- String data = (String) yaml.load(input);
- assertEquals(etalon, data);
- //
- String dumped = yaml.dump(data);
- String etalonDumped = Util.getLocalResource("specification/example2_15_dumped.yaml");
- assertEquals(etalonDumped, dumped);
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_16() {
- YamlDocument document = new YamlDocument("example2_16.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals(map.toString(), 3, map.size());
- assertEquals("Mark McGwire", map.get("name"));
- assertEquals("Mark set a major league home run record in 1998.\n",
- map.get("accomplishment"));
- assertEquals("65 Home Runs\n0.278 Batting Average\n", map.get("stats"));
-
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_17() {
- YamlDocument document = new YamlDocument("example2_17.yaml", false);
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals(map.toString(), 6, map.size());
- assertEquals("Sosa did fine.\u263A", map.get("unicode"));
- assertEquals("\b1998\t1999\t2000\n", map.get("control"));
- assertEquals("\r\n is \r\n", map.get("hexesc"));
- assertEquals("\"Howdy!\" he cried.", map.get("single"));
- assertEquals(" # not a 'comment'.", map.get("quoted"));
- assertEquals("|\\-*-/|", map.get("tie-fighter"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_17_unicode() {
- YamlDocument document = new YamlDocument("example2_17_unicode.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals("Sosa did fine.\u263A", map.get("unicode"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_17_control() {
- YamlDocument document = new YamlDocument("example2_17_control.yaml", false);
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals("\b1998\t1999\t2000\n", map.get("control"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_17_hexesc() {
- YamlDocument document = new YamlDocument("example2_17_hexesc.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals("\r\n is \r\n", map.get("hexesc"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_17_single() {
- YamlDocument document = new YamlDocument("example2_17_single.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals("\"Howdy!\" he cried.", map.get("single"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_17_quoted() {
- YamlDocument document = new YamlDocument("example2_17_quoted.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals(" # not a 'comment'.", map.get("quoted"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_17_tie_fighter() {
- YamlDocument document = new YamlDocument("example2_17_tie_fighter.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals("|\\-*-/|", map.get("tie-fighter"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_18() {
- YamlDocument document = new YamlDocument("example2_18.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals(map.toString(), 2, map.size());
- assertEquals("This unquoted scalar spans many lines.", map.get("plain"));
- assertEquals("So does this quoted scalar.\n", map.get("quoted"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
+
+/**
+ * Test Chapter 2.3 from the YAML specification
+ *
+ * @author py4fun
+ * @see http://yaml.org/spec/1.1/
+ */
+public class Chapter2_3Test extends TestCase {
+
+ public void testExample_2_13() {
+ YamlDocument document = new YamlDocument("example2_13.yaml");
+ String data = (String) document.getNativeData();
+ assertEquals("\\//||\\/||\n// || ||__\n", data);
+ }
+
+ public void testExample_2_14() {
+ YamlDocument document = new YamlDocument("example2_14.yaml");
+ String data = (String) document.getNativeData();
+ assertEquals("Mark McGwire's year was crippled by a knee injury.", data);
+ }
+
+ public void testExample_2_15() {
+ String etalon = "Sammy Sosa completed another fine season with great stats.\n\n 63 Home Runs\n 0.288 Batting Average\n\nWhat a year!\n";
+ InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
+ YamlDocument.ROOT + "example2_15.yaml");
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.FOLDED);
+ Yaml yaml = new Yaml(options);
+ String data = (String) yaml.load(input);
+ assertEquals(etalon, data);
+ //
+ String dumped = yaml.dump(data);
+ String etalonDumped = Util.getLocalResource("specification/example2_15_dumped.yaml");
+ assertEquals(etalonDumped, dumped);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_16() {
+ YamlDocument document = new YamlDocument("example2_16.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals(map.toString(), 3, map.size());
+ assertEquals("Mark McGwire", map.get("name"));
+ assertEquals("Mark set a major league home run record in 1998.\n",
+ map.get("accomplishment"));
+ assertEquals("65 Home Runs\n0.278 Batting Average\n", map.get("stats"));
+
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_17() {
+ YamlDocument document = new YamlDocument("example2_17.yaml", false);
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals(map.toString(), 6, map.size());
+ assertEquals("Sosa did fine.\u263A", map.get("unicode"));
+ assertEquals("\b1998\t1999\t2000\n", map.get("control"));
+ assertEquals("\r\n is \r\n", map.get("hexesc"));
+ assertEquals("\"Howdy!\" he cried.", map.get("single"));
+ assertEquals(" # not a 'comment'.", map.get("quoted"));
+ assertEquals("|\\-*-/|", map.get("tie-fighter"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_17_unicode() {
+ YamlDocument document = new YamlDocument("example2_17_unicode.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals("Sosa did fine.\u263A", map.get("unicode"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_17_control() {
+ YamlDocument document = new YamlDocument("example2_17_control.yaml", false);
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals("\b1998\t1999\t2000\n", map.get("control"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_17_hexesc() {
+ YamlDocument document = new YamlDocument("example2_17_hexesc.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals("\r\n is \r\n", map.get("hexesc"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_17_single() {
+ YamlDocument document = new YamlDocument("example2_17_single.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals("\"Howdy!\" he cried.", map.get("single"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_17_quoted() {
+ YamlDocument document = new YamlDocument("example2_17_quoted.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals(" # not a 'comment'.", map.get("quoted"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_17_tie_fighter() {
+ YamlDocument document = new YamlDocument("example2_17_tie_fighter.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals("|\\-*-/|", map.get("tie-fighter"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_18() {
+ YamlDocument document = new YamlDocument("example2_18.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals(map.toString(), 2, map.size());
+ assertEquals("This unquoted scalar spans many lines.", map.get("plain"));
+ assertEquals("So does this quoted scalar.\n", map.get("quoted"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Chapter2_4Test.java b/src/test/java/org/yaml/snakeyaml/Chapter2_4Test.java
index 0d817ef..b03d9f6 100644
--- a/src/test/java/org/yaml/snakeyaml/Chapter2_4Test.java
+++ b/src/test/java/org/yaml/snakeyaml/Chapter2_4Test.java
@@ -1,184 +1,184 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Test Chapter 2.4 from the YAML specification
- *
- * @author py4fun
- * @see http://yaml.org/spec/1.1/
- */
-public class Chapter2_4Test extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testExample_2_19() {
- YamlDocument document = new YamlDocument("example2_19.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(5, map.size());
- assertEquals("Expect 12345 to be an Integer.", Integer.class, map.get("canonical")
- .getClass());
- assertEquals(new Integer(12345), map.get("canonical"));
- assertEquals(new Integer(12345), map.get("decimal"));
- assertEquals(new Integer(3 * 3600 + 25 * 60 + 45), map.get("sexagesimal"));
- assertEquals(new Integer(014), map.get("octal"));
- assertEquals(new Integer(0xC), map.get("hexadecimal"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_20() {
- YamlDocument document = new YamlDocument("example2_20.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(6, map.size());
- assertEquals("Expect '1.23015e+3' to be a Double.", Double.class, map.get("canonical")
- .getClass());
- assertEquals(new Double(1230.15), map.get("canonical"));
- assertEquals(new Double(12.3015e+02), map.get("exponential"));
- assertEquals(new Double(20 * 60 + 30.15), map.get("sexagesimal"));
- assertEquals(new Double(1230.15), map.get("fixed"));
- assertEquals(Double.NEGATIVE_INFINITY, map.get("negative infinity"));
- assertEquals(Double.NaN, map.get("not a number"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_21() {
- YamlDocument document = new YamlDocument("example2_21.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(4, map.size());
- assertNull("'~' must be parsed as 'null': " + map.get(null), map.get(null));
- assertTrue((Boolean) map.get(Boolean.TRUE));
- assertFalse((Boolean) map.get(Boolean.FALSE));
- assertEquals("12345", map.get("string"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_22() {
- YamlDocument document = new YamlDocument("example2_22.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(4, map.size());
- assertEquals("Expect '2001-12-15T02:59:43.1Z' to be a Date.", Date.class,
- map.get("canonical").getClass());
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.clear();
- cal.set(Calendar.YEAR, 2001);
- cal.set(Calendar.MONTH, 11); // Java's months are zero-based...
- cal.set(Calendar.DAY_OF_MONTH, 15);
- cal.set(Calendar.HOUR_OF_DAY, 2);
- cal.set(Calendar.MINUTE, 59);
- cal.set(Calendar.SECOND, 43);
- cal.set(Calendar.MILLISECOND, 100);
- Date date = cal.getTime();
- assertEquals(date, map.get("canonical"));
- assertEquals("Expect '2001-12-14t21:59:43.10-05:00' to be a Date.", Date.class,
- map.get("iso8601").getClass());
- assertEquals("Expect '2001-12-14 21:59:43.10 -5' to be a Date.", Date.class,
- map.get("spaced").getClass());
- assertEquals("Expect '2002-12-14' to be a Date.", Date.class, map.get("date").getClass());
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_23_non_date() {
- try {
- YamlDocument document = new YamlDocument("example2_23_non_date.yaml");
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(1, map.size());
- assertEquals("2002-04-28", map.get("not-date"));
- } catch (RuntimeException e) {
- fail("Cannot parse '!!str': 'not-date: !!str 2002-04-28'");
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_23_picture() {
- YamlDocument document = new YamlDocument("example2_23_picture.yaml", false);
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(1, map.size());
- byte[] picture = (byte[]) map.get("picture");
- assertEquals((byte) 'G', picture[0]);
- assertEquals((byte) 'I', picture[1]);
- assertEquals((byte) 'F', picture[2]);
- }
-
- class SomethingConstructor extends Constructor {
- public SomethingConstructor() {
- this.yamlConstructors.put(new Tag("!something"), new ConstructSomething());
- }
-
- private class ConstructSomething extends AbstractConstruct {
- public Object construct(Node node) {
- // convert to upper case
- String val = (String) constructScalar((ScalarNode) node);
- return val.toUpperCase().replace('\n', ' ').trim();
- }
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_23() {
- YamlDocument document = new YamlDocument("example2_23.yaml", false,
- new SomethingConstructor());
- Map<String, Object> map = (Map<String, Object>) document.getNativeData();
- assertEquals(3, map.size());
- String special = (String) map.get("application specific tag");
- assertEquals("THE SEMANTICS OF THE TAG ABOVE MAY BE DIFFERENT FOR DIFFERENT DOCUMENTS.",
- special);
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_25() {
- YamlDocument document = new YamlDocument("example2_25.yaml");
- Set<String> set = (Set<String>) document.getNativeData();
- assertEquals(3, set.size());
- assertTrue(set.contains("Mark McGwire"));
- assertTrue(set.contains("Sammy Sosa"));
- assertTrue(set.contains("Ken Griff"));
- }
-
- @SuppressWarnings("unchecked")
- public void testExample_2_26() {
- YamlDocument document = new YamlDocument("example2_26.yaml");
- Map<String, String> map = (Map<String, String>) document.getNativeData();
- assertEquals(3, map.size());
- assertTrue(map instanceof LinkedHashMap);
- assertEquals(new Integer(65), map.get("Mark McGwire"));
- assertEquals(new Integer(63), map.get("Sammy Sosa"));
- assertEquals(new Integer(58), map.get("Ken Griffy"));
- List<String> list = new ArrayList<String>();
- for (String key : map.keySet()) {
- list.add(key);
- }
- assertEquals("Mark McGwire", list.get(0));
- assertEquals("Sammy Sosa", list.get(1));
- assertEquals("Ken Griffy", list.get(2));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TimeZone;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Test Chapter 2.4 from the YAML specification
+ *
+ * @author py4fun
+ * @see http://yaml.org/spec/1.1/
+ */
+public class Chapter2_4Test extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_19() {
+ YamlDocument document = new YamlDocument("example2_19.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(5, map.size());
+ assertEquals("Expect 12345 to be an Integer.", Integer.class, map.get("canonical")
+ .getClass());
+ assertEquals(new Integer(12345), map.get("canonical"));
+ assertEquals(new Integer(12345), map.get("decimal"));
+ assertEquals(new Integer(3 * 3600 + 25 * 60 + 45), map.get("sexagesimal"));
+ assertEquals(new Integer(014), map.get("octal"));
+ assertEquals(new Integer(0xC), map.get("hexadecimal"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_20() {
+ YamlDocument document = new YamlDocument("example2_20.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(6, map.size());
+ assertEquals("Expect '1.23015e+3' to be a Double.", Double.class, map.get("canonical")
+ .getClass());
+ assertEquals(new Double(1230.15), map.get("canonical"));
+ assertEquals(new Double(12.3015e+02), map.get("exponential"));
+ assertEquals(new Double(20 * 60 + 30.15), map.get("sexagesimal"));
+ assertEquals(new Double(1230.15), map.get("fixed"));
+ assertEquals(Double.NEGATIVE_INFINITY, map.get("negative infinity"));
+ assertEquals(Double.NaN, map.get("not a number"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_21() {
+ YamlDocument document = new YamlDocument("example2_21.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(4, map.size());
+ assertNull("'~' must be parsed as 'null': " + map.get(null), map.get(null));
+ assertTrue((Boolean) map.get(Boolean.TRUE));
+ assertFalse((Boolean) map.get(Boolean.FALSE));
+ assertEquals("12345", map.get("string"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_22() {
+ YamlDocument document = new YamlDocument("example2_22.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(4, map.size());
+ assertEquals("Expect '2001-12-15T02:59:43.1Z' to be a Date.", Date.class,
+ map.get("canonical").getClass());
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ cal.clear();
+ cal.set(Calendar.YEAR, 2001);
+ cal.set(Calendar.MONTH, 11); // Java's months are zero-based...
+ cal.set(Calendar.DAY_OF_MONTH, 15);
+ cal.set(Calendar.HOUR_OF_DAY, 2);
+ cal.set(Calendar.MINUTE, 59);
+ cal.set(Calendar.SECOND, 43);
+ cal.set(Calendar.MILLISECOND, 100);
+ Date date = cal.getTime();
+ assertEquals(date, map.get("canonical"));
+ assertEquals("Expect '2001-12-14t21:59:43.10-05:00' to be a Date.", Date.class,
+ map.get("iso8601").getClass());
+ assertEquals("Expect '2001-12-14 21:59:43.10 -5' to be a Date.", Date.class,
+ map.get("spaced").getClass());
+ assertEquals("Expect '2002-12-14' to be a Date.", Date.class, map.get("date").getClass());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_23_non_date() {
+ try {
+ YamlDocument document = new YamlDocument("example2_23_non_date.yaml");
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(1, map.size());
+ assertEquals("2002-04-28", map.get("not-date"));
+ } catch (RuntimeException e) {
+ fail("Cannot parse '!!str': 'not-date: !!str 2002-04-28'");
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_23_picture() {
+ YamlDocument document = new YamlDocument("example2_23_picture.yaml", false);
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(1, map.size());
+ byte[] picture = (byte[]) map.get("picture");
+ assertEquals((byte) 'G', picture[0]);
+ assertEquals((byte) 'I', picture[1]);
+ assertEquals((byte) 'F', picture[2]);
+ }
+
+ class SomethingConstructor extends Constructor {
+ public SomethingConstructor() {
+ this.yamlConstructors.put(new Tag("!something"), new ConstructSomething());
+ }
+
+ private class ConstructSomething extends AbstractConstruct {
+ public Object construct(Node node) {
+ // convert to upper case
+ String val = (String) constructScalar((ScalarNode) node);
+ return val.toUpperCase().replace('\n', ' ').trim();
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_23() {
+ YamlDocument document = new YamlDocument("example2_23.yaml", false,
+ new SomethingConstructor());
+ Map<String, Object> map = (Map<String, Object>) document.getNativeData();
+ assertEquals(3, map.size());
+ String special = (String) map.get("application specific tag");
+ assertEquals("THE SEMANTICS OF THE TAG ABOVE MAY BE DIFFERENT FOR DIFFERENT DOCUMENTS.",
+ special);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_25() {
+ YamlDocument document = new YamlDocument("example2_25.yaml");
+ Set<String> set = (Set<String>) document.getNativeData();
+ assertEquals(3, set.size());
+ assertTrue(set.contains("Mark McGwire"));
+ assertTrue(set.contains("Sammy Sosa"));
+ assertTrue(set.contains("Ken Griff"));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_26() {
+ YamlDocument document = new YamlDocument("example2_26.yaml");
+ Map<String, String> map = (Map<String, String>) document.getNativeData();
+ assertEquals(3, map.size());
+ assertTrue(map instanceof LinkedHashMap);
+ assertEquals(new Integer(65), map.get("Mark McGwire"));
+ assertEquals(new Integer(63), map.get("Sammy Sosa"));
+ assertEquals(new Integer(58), map.get("Ken Griffy"));
+ List<String> list = new ArrayList<String>();
+ for (String key : map.keySet()) {
+ list.add(key);
+ }
+ assertEquals("Mark McGwire", list.get(0));
+ assertEquals("Sammy Sosa", list.get(1));
+ assertEquals("Ken Griffy", list.get(2));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Chapter2_5Test.java b/src/test/java/org/yaml/snakeyaml/Chapter2_5Test.java
index 9fe0021..5cd1d15 100644
--- a/src/test/java/org/yaml/snakeyaml/Chapter2_5Test.java
+++ b/src/test/java/org/yaml/snakeyaml/Chapter2_5Test.java
@@ -1,65 +1,65 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-/**
- * Test Chapter 2.5 from the YAML specification
- *
- * @author py4fun
- * @see http://yaml.org/spec/1.1/
- */
-public class Chapter2_5Test extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testExample_2_28() {
- YamlStream resource = new YamlStream("example2_28.yaml");
- List<Object> list = (List<Object>) resource.getNativeData();
- assertEquals(3, list.size());
- Map<String, Object> data0 = (Map<String, Object>) list.get(0);
- Date date = (Date) data0.get("Time");
- assertEquals("Date: " + date, 1006545702000L, date.getTime());
- assertEquals("ed", data0.get("User"));
- assertEquals("This is an error message for the log file", data0.get("Warning"));
- //
- Map<String, Object> data1 = (Map<String, Object>) list.get(1);
- Date date1 = (Date) data1.get("Time");
- assertTrue("Date: " + date1, date1.after(date));
- assertEquals("ed", data1.get("User"));
- assertEquals("A slightly different error message.", data1.get("Warning"));
- //
- Map<String, Object> data3 = (Map<String, Object>) list.get(2);
- Date date3 = (Date) data3.get("Date");
- assertTrue("Date: " + date3, date3.after(date1));
- assertEquals("ed", data3.get("User"));
- assertEquals("Unknown variable \"bar\"", data3.get("Fatal"));
- List<Map<String, String>> list3 = (List<Map<String, String>>) data3.get("Stack");
- Map<String, String> map1 = list3.get(0);
- assertEquals("TopClass.py", map1.get("file"));
- assertEquals(new Integer(23), map1.get("line"));
- assertEquals("x = MoreObject(\"345\\n\")\n", map1.get("code"));
- Map<String, String> map2 = list3.get(1);
- assertEquals("MoreClass.py", map2.get("file"));
- assertEquals(new Integer(58), map2.get("line"));
- assertEquals("foo = bar", map2.get("code"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+/**
+ * Test Chapter 2.5 from the YAML specification
+ *
+ * @author py4fun
+ * @see http://yaml.org/spec/1.1/
+ */
+public class Chapter2_5Test extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testExample_2_28() {
+ YamlStream resource = new YamlStream("example2_28.yaml");
+ List<Object> list = (List<Object>) resource.getNativeData();
+ assertEquals(3, list.size());
+ Map<String, Object> data0 = (Map<String, Object>) list.get(0);
+ Date date = (Date) data0.get("Time");
+ assertEquals("Date: " + date, 1006545702000L, date.getTime());
+ assertEquals("ed", data0.get("User"));
+ assertEquals("This is an error message for the log file", data0.get("Warning"));
+ //
+ Map<String, Object> data1 = (Map<String, Object>) list.get(1);
+ Date date1 = (Date) data1.get("Time");
+ assertTrue("Date: " + date1, date1.after(date));
+ assertEquals("ed", data1.get("User"));
+ assertEquals("A slightly different error message.", data1.get("Warning"));
+ //
+ Map<String, Object> data3 = (Map<String, Object>) list.get(2);
+ Date date3 = (Date) data3.get("Date");
+ assertTrue("Date: " + date3, date3.after(date1));
+ assertEquals("ed", data3.get("User"));
+ assertEquals("Unknown variable \"bar\"", data3.get("Fatal"));
+ List<Map<String, String>> list3 = (List<Map<String, String>>) data3.get("Stack");
+ Map<String, String> map1 = list3.get(0);
+ assertEquals("TopClass.py", map1.get("file"));
+ assertEquals(new Integer(23), map1.get("line"));
+ assertEquals("x = MoreObject(\"345\\n\")\n", map1.get("code"));
+ Map<String, String> map2 = list3.get(1);
+ assertEquals("MoreClass.py", map2.get("file"));
+ assertEquals(new Integer(58), map2.get("line"));
+ assertEquals("foo = bar", map2.get("code"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/CollectionWithBeanYamlTest.java b/src/test/java/org/yaml/snakeyaml/CollectionWithBeanYamlTest.java
index ec5afd3..57d740a 100644
--- a/src/test/java/org/yaml/snakeyaml/CollectionWithBeanYamlTest.java
+++ b/src/test/java/org/yaml/snakeyaml/CollectionWithBeanYamlTest.java
@@ -1,86 +1,86 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-public class CollectionWithBeanYamlTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testYamlMap() {
- Map<String, Bean> data = new TreeMap<String, Bean>();
- data.put("gold1", new Bean());
- data.put("gold2", new Bean());
-
- Yaml yaml = new Yaml();
- String output = yaml.dump(data);
- assertEquals(
- "gold1: !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: ''}\ngold2: !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: ''}\n",
- output);
- Object o = yaml.load(output);
-
- assertTrue(o instanceof Map);
- Map<String, Bean> m = (Map<String, Bean>) o;
- assertTrue(m.get("gold1") instanceof Bean);
- assertTrue("" + m.get("gold2").getClass(), m.get("gold2") instanceof Bean);
- }
-
- @SuppressWarnings("unchecked")
- public void testYamlList() {
- List<Bean> data = new ArrayList<Bean>();
- data.add(new Bean("1"));
- data.add(new Bean("2"));
-
- Yaml yaml = new Yaml();
- String output = yaml.dump(data);
- assertEquals(
- "- !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: '1'}\n- !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: '2'}\n",
- output);
- Object o = yaml.load(output);
-
- assertTrue(o instanceof List);
- List<Bean> m = (List<Bean>) o;
- assertEquals(2, m.size());
- assertTrue(m.get(0) instanceof Bean);
- assertTrue(m.get(1) instanceof Bean);
- }
-
- public static class Bean {
- private String a;
-
- public Bean() {
- a = "";
- }
-
- public Bean(String value) {
- a = value;
- }
-
- public String getA() {
- return a;
- }
-
- public void setA(String s) {
- a = s;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+public class CollectionWithBeanYamlTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testYamlMap() {
+ Map<String, Bean> data = new TreeMap<String, Bean>();
+ data.put("gold1", new Bean());
+ data.put("gold2", new Bean());
+
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(data);
+ assertEquals(
+ "gold1: !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: ''}\ngold2: !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: ''}\n",
+ output);
+ Object o = yaml.load(output);
+
+ assertTrue(o instanceof Map);
+ Map<String, Bean> m = (Map<String, Bean>) o;
+ assertTrue(m.get("gold1") instanceof Bean);
+ assertTrue("" + m.get("gold2").getClass(), m.get("gold2") instanceof Bean);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testYamlList() {
+ List<Bean> data = new ArrayList<Bean>();
+ data.add(new Bean("1"));
+ data.add(new Bean("2"));
+
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(data);
+ assertEquals(
+ "- !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: '1'}\n- !!org.yaml.snakeyaml.CollectionWithBeanYamlTest$Bean {a: '2'}\n",
+ output);
+ Object o = yaml.load(output);
+
+ assertTrue(o instanceof List);
+ List<Bean> m = (List<Bean>) o;
+ assertEquals(2, m.size());
+ assertTrue(m.get(0) instanceof Bean);
+ assertTrue(m.get(1) instanceof Bean);
+ }
+
+ public static class Bean {
+ private String a;
+
+ public Bean() {
+ a = "";
+ }
+
+ public Bean(String value) {
+ a = value;
+ }
+
+ public String getA() {
+ return a;
+ }
+
+ public void setA(String s) {
+ a = s;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/DumperTest.java b/src/test/java/org/yaml/snakeyaml/DumperTest.java
index 2489dbf..d1e55a6 100644
--- a/src/test/java/org/yaml/snakeyaml/DumperTest.java
+++ b/src/test/java/org/yaml/snakeyaml/DumperTest.java
@@ -1,113 +1,113 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.resolver.Resolver;
-
-public class DumperTest extends TestCase {
-
- public void testDump1() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
- options.setExplicitStart(true);
- options.setExplicitEnd(true);
- List<Integer> list = new ArrayList<Integer>();
- for (int i = 0; i < 3; i++) {
- list.add(i);
- }
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(list);
- assertEquals("---\n- !!int \"0\"\n- !!int \"1\"\n- !!int \"2\"\n...\n", output);
- }
-
- public void testDump2() {
- DumperOptions options = new DumperOptions();
- options.setExplicitStart(true);
- List<Integer> list = new ArrayList<Integer>();
- for (int i = 0; i < 3; i++) {
- list.add(i);
- }
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(list);
- assertEquals("--- [0, 1, 2]\n", output);
- }
-
- public void testDump3() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
- List<Integer> list = new ArrayList<Integer>();
- for (int i = 0; i < 3; i++) {
- list.add(i);
- }
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(list);
- assertEquals("- !!int '0'\n- !!int '1'\n- !!int '2'\n", output);
- }
-
- public void testDumpException() {
- Yaml yaml = new Yaml();
- Writer writer = new ExceptionWriter1();
- try {
- yaml.dump("aaa1234567890", writer);
- fail("Exception must be thrown.");
- } catch (Exception e) {
- assertEquals("java.io.IOException: write test failure.", e.getMessage());
- }
- }
-
- private class ExceptionWriter1 extends Writer {
- @Override
- public void write(String str) throws IOException {
- throw new IOException("write test failure.");
- }
-
- @Override
- public void close() throws IOException {
- }
-
- @Override
- public void flush() throws IOException {
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- throw new IOException("write test failure.");
- }
- }
-
- @SuppressWarnings("deprecation")
- public void testDeprecated1() {
- Yaml yaml = new Yaml(new Dumper());
- yaml.dump("aaa1234567890");
- }
-
- @SuppressWarnings("deprecation")
- public void testDeprecated2() {
- DumperOptions options = new DumperOptions();
- options.setCanonical(true);
- Yaml yaml = new Yaml(new Loader(), new Dumper(options), new Resolver());
- String doc = yaml.dump("aaa1234567890");
- assertEquals("---\n!!str \"aaa1234567890\"\n", doc);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.resolver.Resolver;
+
+public class DumperTest extends TestCase {
+
+ public void testDump1() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
+ options.setExplicitStart(true);
+ options.setExplicitEnd(true);
+ List<Integer> list = new ArrayList<Integer>();
+ for (int i = 0; i < 3; i++) {
+ list.add(i);
+ }
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(list);
+ assertEquals("---\n- !!int \"0\"\n- !!int \"1\"\n- !!int \"2\"\n...\n", output);
+ }
+
+ public void testDump2() {
+ DumperOptions options = new DumperOptions();
+ options.setExplicitStart(true);
+ List<Integer> list = new ArrayList<Integer>();
+ for (int i = 0; i < 3; i++) {
+ list.add(i);
+ }
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(list);
+ assertEquals("--- [0, 1, 2]\n", output);
+ }
+
+ public void testDump3() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
+ List<Integer> list = new ArrayList<Integer>();
+ for (int i = 0; i < 3; i++) {
+ list.add(i);
+ }
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(list);
+ assertEquals("- !!int '0'\n- !!int '1'\n- !!int '2'\n", output);
+ }
+
+ public void testDumpException() {
+ Yaml yaml = new Yaml();
+ Writer writer = new ExceptionWriter1();
+ try {
+ yaml.dump("aaa1234567890", writer);
+ fail("Exception must be thrown.");
+ } catch (Exception e) {
+ assertEquals("java.io.IOException: write test failure.", e.getMessage());
+ }
+ }
+
+ private class ExceptionWriter1 extends Writer {
+ @Override
+ public void write(String str) throws IOException {
+ throw new IOException("write test failure.");
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public void flush() throws IOException {
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ throw new IOException("write test failure.");
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testDeprecated1() {
+ Yaml yaml = new Yaml(new Dumper());
+ yaml.dump("aaa1234567890");
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testDeprecated2() {
+ DumperOptions options = new DumperOptions();
+ options.setCanonical(true);
+ Yaml yaml = new Yaml(new Loader(), new Dumper(options), new Resolver());
+ String doc = yaml.dump("aaa1234567890");
+ assertEquals("---\n!!str \"aaa1234567890\"\n", doc);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Example2_24Test.java b/src/test/java/org/yaml/snakeyaml/Example2_24Test.java
index 4a3de65..360afff 100644
--- a/src/test/java/org/yaml/snakeyaml/Example2_24Test.java
+++ b/src/test/java/org/yaml/snakeyaml/Example2_24Test.java
@@ -1,249 +1,249 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Represent;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * Test Example 2.24 from the YAML specification
- *
- * @author py4fun
- * @see http://yaml.org/spec/1.1/
- */
-public class Example2_24Test extends TestCase {
- class MyConstructor extends Constructor {
- public MyConstructor() {
- this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:shape"),
- new ConstructShape());
- this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:circle"),
- new ConstructCircle());
- this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:line"), new ConstructLine());
- this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:label"),
- new ConstructLabel());
- }
-
- private class ConstructShape extends AbstractConstruct {
- @SuppressWarnings("unchecked")
- public Object construct(Node node) {
- SequenceNode snode = (SequenceNode) node;
- List<Entity> values = (List<Entity>) constructSequence(snode);
- Shape shape = new Shape(values);
- return shape;
- }
- }
-
- private class ConstructCircle extends AbstractConstruct {
- @SuppressWarnings("unchecked")
- public Object construct(Node node) {
- MappingNode mnode = (MappingNode) node;
- Map<Object, Object> values = constructMapping(mnode);
- Circle circle = new Circle((Map<String, Integer>) values.get("center"),
- (Integer) values.get("radius"));
- return circle;
- }
- }
-
- private class ConstructLine extends AbstractConstruct {
- @SuppressWarnings("unchecked")
- public Object construct(Node node) {
- MappingNode mnode = (MappingNode) node;
- Map<Object, Object> values = constructMapping(mnode);
- Line line = new Line((Map<String, Integer>) values.get("start"),
- (Map<String, Integer>) values.get("finish"));
- return line;
- }
- }
-
- private class ConstructLabel extends AbstractConstruct {
- @SuppressWarnings("unchecked")
- public Object construct(Node node) {
- MappingNode mnode = (MappingNode) node;
- Map<Object, Object> values = constructMapping(mnode);
- Label label = new Label((Map<String, Integer>) values.get("start"),
- (Integer) values.get("color"), (String) values.get("text"));
- return label;
- }
- }
- }
-
- class MyRepresenter extends Representer {
- public MyRepresenter() {
- this.representers.put(Shape.class, new RepresentShape());
- this.representers.put(Circle.class, new RepresentCircle());
- this.representers.put(Line.class, new RepresentLine());
- this.representers.put(Label.class, new RepresentLabel());
- this.representers.put(HexInteger.class, new RepresentHex());
- }
-
- private class RepresentShape implements Represent {
- public Node representData(Object data) {
- Shape shape = (Shape) data;
- List<Entity> value = shape.getEntities();
- return representSequence(new Tag("!shape"), value, Boolean.FALSE);
- }
- }
-
- private class RepresentCircle implements Represent {
- public Node representData(Object data) {
- Circle circle = (Circle) data;
- Map<String, Object> map = new TreeMap<String, Object>();
- map.put("center", circle.getCenter());
- map.put("radius", circle.getRadius());
- return representMapping(new Tag("!circle"), map, Boolean.FALSE);
- }
- }
-
- private class RepresentLine implements Represent {
- public Node representData(Object data) {
- Line line = (Line) data;
- Map<String, Object> map = new TreeMap<String, Object>();
- map.put("start", line.getStart());
- map.put("finish", line.getFinish());
- return representMapping(new Tag("!line"), map, Boolean.FALSE);
- }
- }
-
- private class RepresentLabel implements Represent {
- public Node representData(Object data) {
- Label label = (Label) data;
- Map<String, Object> map = new TreeMap<String, Object>();
- map.put("start", label.getStart());
- map.put("color", new HexInteger(label.getColor()));
- map.put("text", label.getText());
- return representMapping(new Tag("!label"), map, Boolean.FALSE);
- }
- }
-
- private class RepresentHex implements Represent {
- public Node representData(Object data) {
- HexInteger hex = (HexInteger) data;
- return representScalar(Tag.INT, "0x"
- + Integer.toHexString(hex.getColor()).toUpperCase(), null);
- }
- }
- }
-
- private class HexInteger {
- private Integer color;
-
- public HexInteger(Integer color) {
- this.color = color;
- }
-
- public Integer getColor() {
- return color;
- }
- }
-
- private class Shape {
- private List<Entity> entities;
-
- public List<Entity> getEntities() {
- return entities;
- }
-
- public Shape(List<Entity> entities) {
- this.entities = entities;
- }
- }
-
- private class Entity {
- }
-
- private class Circle extends Entity {
- private Map<String, Integer> center;
- private Integer radius;
-
- public Circle(Map<String, Integer> center, Integer radius) {
- this.center = center;
- this.radius = radius;
- }
-
- public Map<String, Integer> getCenter() {
- return center;
- }
-
- public Integer getRadius() {
- return radius;
- }
- }
-
- private class Line extends Entity {
- private Map<String, Integer> start;
- private Map<String, Integer> finish;
-
- public Line(Map<String, Integer> start, Map<String, Integer> finish) {
- this.start = start;
- this.finish = finish;
- }
-
- public Map<String, Integer> getStart() {
- return start;
- }
-
- public Map<String, Integer> getFinish() {
- return finish;
- }
- }
-
- private class Label extends Entity {
- private Map<String, Integer> start;
- private Integer color;
- private String text;
-
- public Label(Map<String, Integer> start, Integer color, String text) {
- this.start = start;
- this.color = color;
- this.text = text;
- }
-
- public Map<String, Integer> getStart() {
- return start;
- }
-
- public Integer getColor() {
- return color;
- }
-
- public String getText() {
- return text;
- }
- }
-
- public void testExample_2_24() {
- Yaml yaml = new Yaml(new MyConstructor());
- Shape shape = (Shape) yaml.load(Util.getLocalResource("specification/example2_24.yaml"));
- assertNotNull(shape);
- yaml = new Yaml(new MyRepresenter());
- String output = yaml.dump(shape);
- String etalon = Util.getLocalResource("specification/example2_24_dumped.yaml");
- assertEquals(etalon, output);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Represent;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * Test Example 2.24 from the YAML specification
+ *
+ * @author py4fun
+ * @see http://yaml.org/spec/1.1/
+ */
+public class Example2_24Test extends TestCase {
+ class MyConstructor extends Constructor {
+ public MyConstructor() {
+ this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:shape"),
+ new ConstructShape());
+ this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:circle"),
+ new ConstructCircle());
+ this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:line"), new ConstructLine());
+ this.yamlConstructors.put(new Tag("tag:clarkevans.com,2002:label"),
+ new ConstructLabel());
+ }
+
+ private class ConstructShape extends AbstractConstruct {
+ @SuppressWarnings("unchecked")
+ public Object construct(Node node) {
+ SequenceNode snode = (SequenceNode) node;
+ List<Entity> values = (List<Entity>) constructSequence(snode);
+ Shape shape = new Shape(values);
+ return shape;
+ }
+ }
+
+ private class ConstructCircle extends AbstractConstruct {
+ @SuppressWarnings("unchecked")
+ public Object construct(Node node) {
+ MappingNode mnode = (MappingNode) node;
+ Map<Object, Object> values = constructMapping(mnode);
+ Circle circle = new Circle((Map<String, Integer>) values.get("center"),
+ (Integer) values.get("radius"));
+ return circle;
+ }
+ }
+
+ private class ConstructLine extends AbstractConstruct {
+ @SuppressWarnings("unchecked")
+ public Object construct(Node node) {
+ MappingNode mnode = (MappingNode) node;
+ Map<Object, Object> values = constructMapping(mnode);
+ Line line = new Line((Map<String, Integer>) values.get("start"),
+ (Map<String, Integer>) values.get("finish"));
+ return line;
+ }
+ }
+
+ private class ConstructLabel extends AbstractConstruct {
+ @SuppressWarnings("unchecked")
+ public Object construct(Node node) {
+ MappingNode mnode = (MappingNode) node;
+ Map<Object, Object> values = constructMapping(mnode);
+ Label label = new Label((Map<String, Integer>) values.get("start"),
+ (Integer) values.get("color"), (String) values.get("text"));
+ return label;
+ }
+ }
+ }
+
+ class MyRepresenter extends Representer {
+ public MyRepresenter() {
+ this.representers.put(Shape.class, new RepresentShape());
+ this.representers.put(Circle.class, new RepresentCircle());
+ this.representers.put(Line.class, new RepresentLine());
+ this.representers.put(Label.class, new RepresentLabel());
+ this.representers.put(HexInteger.class, new RepresentHex());
+ }
+
+ private class RepresentShape implements Represent {
+ public Node representData(Object data) {
+ Shape shape = (Shape) data;
+ List<Entity> value = shape.getEntities();
+ return representSequence(new Tag("!shape"), value, Boolean.FALSE);
+ }
+ }
+
+ private class RepresentCircle implements Represent {
+ public Node representData(Object data) {
+ Circle circle = (Circle) data;
+ Map<String, Object> map = new TreeMap<String, Object>();
+ map.put("center", circle.getCenter());
+ map.put("radius", circle.getRadius());
+ return representMapping(new Tag("!circle"), map, Boolean.FALSE);
+ }
+ }
+
+ private class RepresentLine implements Represent {
+ public Node representData(Object data) {
+ Line line = (Line) data;
+ Map<String, Object> map = new TreeMap<String, Object>();
+ map.put("start", line.getStart());
+ map.put("finish", line.getFinish());
+ return representMapping(new Tag("!line"), map, Boolean.FALSE);
+ }
+ }
+
+ private class RepresentLabel implements Represent {
+ public Node representData(Object data) {
+ Label label = (Label) data;
+ Map<String, Object> map = new TreeMap<String, Object>();
+ map.put("start", label.getStart());
+ map.put("color", new HexInteger(label.getColor()));
+ map.put("text", label.getText());
+ return representMapping(new Tag("!label"), map, Boolean.FALSE);
+ }
+ }
+
+ private class RepresentHex implements Represent {
+ public Node representData(Object data) {
+ HexInteger hex = (HexInteger) data;
+ return representScalar(Tag.INT, "0x"
+ + Integer.toHexString(hex.getColor()).toUpperCase(), null);
+ }
+ }
+ }
+
+ private class HexInteger {
+ private Integer color;
+
+ public HexInteger(Integer color) {
+ this.color = color;
+ }
+
+ public Integer getColor() {
+ return color;
+ }
+ }
+
+ private class Shape {
+ private List<Entity> entities;
+
+ public List<Entity> getEntities() {
+ return entities;
+ }
+
+ public Shape(List<Entity> entities) {
+ this.entities = entities;
+ }
+ }
+
+ private class Entity {
+ }
+
+ private class Circle extends Entity {
+ private Map<String, Integer> center;
+ private Integer radius;
+
+ public Circle(Map<String, Integer> center, Integer radius) {
+ this.center = center;
+ this.radius = radius;
+ }
+
+ public Map<String, Integer> getCenter() {
+ return center;
+ }
+
+ public Integer getRadius() {
+ return radius;
+ }
+ }
+
+ private class Line extends Entity {
+ private Map<String, Integer> start;
+ private Map<String, Integer> finish;
+
+ public Line(Map<String, Integer> start, Map<String, Integer> finish) {
+ this.start = start;
+ this.finish = finish;
+ }
+
+ public Map<String, Integer> getStart() {
+ return start;
+ }
+
+ public Map<String, Integer> getFinish() {
+ return finish;
+ }
+ }
+
+ private class Label extends Entity {
+ private Map<String, Integer> start;
+ private Integer color;
+ private String text;
+
+ public Label(Map<String, Integer> start, Integer color, String text) {
+ this.start = start;
+ this.color = color;
+ this.text = text;
+ }
+
+ public Map<String, Integer> getStart() {
+ return start;
+ }
+
+ public Integer getColor() {
+ return color;
+ }
+
+ public String getText() {
+ return text;
+ }
+ }
+
+ public void testExample_2_24() {
+ Yaml yaml = new Yaml(new MyConstructor());
+ Shape shape = (Shape) yaml.load(Util.getLocalResource("specification/example2_24.yaml"));
+ assertNotNull(shape);
+ yaml = new Yaml(new MyRepresenter());
+ String output = yaml.dump(shape);
+ String etalon = Util.getLocalResource("specification/example2_24_dumped.yaml");
+ assertEquals(etalon, output);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Example2_27Test.java b/src/test/java/org/yaml/snakeyaml/Example2_27Test.java
index d837077..a7f587a 100644
--- a/src/test/java/org/yaml/snakeyaml/Example2_27Test.java
+++ b/src/test/java/org/yaml/snakeyaml/Example2_27Test.java
@@ -1,43 +1,43 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.constructor.Constructor;
-
-/**
- * Test Example 2.27 from the YAML specification
- *
- * @author py4fun
- * @see http://yaml.org/spec/1.1/
- */
-public class Example2_27Test extends TestCase {
-
- public void testExample_2_27() {
- Yaml yaml = new Yaml(new Constructor(Invoice.class));
- Invoice invoice = (Invoice) yaml.load(Util
- .getLocalResource("specification/example2_27.yaml"));
- assertNotNull(invoice);
- Person billTo = invoice.billTo;
- assertEquals("Dumars", billTo.family);
- yaml = new Yaml();
- String output = yaml.dump(invoice);
- String etalon = Util.getLocalResource("specification/example2_27_dumped.yaml");
- assertEquals(etalon, output);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.constructor.Constructor;
+
+/**
+ * Test Example 2.27 from the YAML specification
+ *
+ * @author py4fun
+ * @see http://yaml.org/spec/1.1/
+ */
+public class Example2_27Test extends TestCase {
+
+ public void testExample_2_27() {
+ Yaml yaml = new Yaml(new Constructor(Invoice.class));
+ Invoice invoice = (Invoice) yaml.load(Util
+ .getLocalResource("specification/example2_27.yaml"));
+ assertNotNull(invoice);
+ Person billTo = invoice.billTo;
+ assertEquals("Dumars", billTo.family);
+ yaml = new Yaml();
+ String output = yaml.dump(invoice);
+ String etalon = Util.getLocalResource("specification/example2_27_dumped.yaml");
+ assertEquals(etalon, output);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/InputOutputExceptionTest.java b/src/test/java/org/yaml/snakeyaml/InputOutputExceptionTest.java
index f3e5b40..055defa 100644
--- a/src/test/java/org/yaml/snakeyaml/InputOutputExceptionTest.java
+++ b/src/test/java/org/yaml/snakeyaml/InputOutputExceptionTest.java
@@ -1,81 +1,81 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.YAMLException;
-
-public class InputOutputExceptionTest extends TestCase {
- public void testIOExceptionOnLoad() {
- try {
- new Yaml().load(new BrokenInputStream());
- fail("Input must be broken.");
- } catch (YAMLException e) {
- assertTrue(e.getCause() instanceof IOException);
- assertEquals("java.io.IOException: Broken 2", e.getMessage());
- }
- }
-
- public void testIOExceptionOnDump() {
- try {
- new Yaml().dump("something", new BrokenWriter());
- fail("Output must be broken.");
- } catch (YAMLException e) {
- assertTrue(e.getCause() instanceof IOException);
- assertEquals("java.io.IOException: Broken 12", e.getMessage());
- }
- }
-
- private static class BrokenInputStream extends InputStream {
- @Override
- public int read() throws IOException {
- throw new IOException("Broken 1");
- }
-
- @Override
- public int read(byte[] bytes, int i, int i1) throws IOException {
- throw new IOException("Broken 2");
- }
-
- @Override
- public void close() throws IOException {
- throw new IOException("Broken 3");
- }
- }
-
- private static class BrokenWriter extends Writer {
- @Override
- public void close() throws IOException {
- throw new IOException("Broken 10");
- }
-
- @Override
- public void flush() throws IOException {
- throw new IOException("Broken 11");
- }
-
- @Override
- public void write(char[] cbuf, int off, int len) throws IOException {
- throw new IOException("Broken 12");
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Writer;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class InputOutputExceptionTest extends TestCase {
+ public void testIOExceptionOnLoad() {
+ try {
+ new Yaml().load(new BrokenInputStream());
+ fail("Input must be broken.");
+ } catch (YAMLException e) {
+ assertTrue(e.getCause() instanceof IOException);
+ assertEquals("java.io.IOException: Broken 2", e.getMessage());
+ }
+ }
+
+ public void testIOExceptionOnDump() {
+ try {
+ new Yaml().dump("something", new BrokenWriter());
+ fail("Output must be broken.");
+ } catch (YAMLException e) {
+ assertTrue(e.getCause() instanceof IOException);
+ assertEquals("java.io.IOException: Broken 12", e.getMessage());
+ }
+ }
+
+ private static class BrokenInputStream extends InputStream {
+ @Override
+ public int read() throws IOException {
+ throw new IOException("Broken 1");
+ }
+
+ @Override
+ public int read(byte[] bytes, int i, int i1) throws IOException {
+ throw new IOException("Broken 2");
+ }
+
+ @Override
+ public void close() throws IOException {
+ throw new IOException("Broken 3");
+ }
+ }
+
+ private static class BrokenWriter extends Writer {
+ @Override
+ public void close() throws IOException {
+ throw new IOException("Broken 10");
+ }
+
+ @Override
+ public void flush() throws IOException {
+ throw new IOException("Broken 11");
+ }
+
+ @Override
+ public void write(char[] cbuf, int off, int len) throws IOException {
+ throw new IOException("Broken 12");
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Invoice.java b/src/test/java/org/yaml/snakeyaml/Invoice.java
index 56041c5..75dff25 100644
--- a/src/test/java/org/yaml/snakeyaml/Invoice.java
+++ b/src/test/java/org/yaml/snakeyaml/Invoice.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.List;
-
-public class Invoice {
- public Integer invoice; // invoice
- public String date; // date
- public Person billTo;// bill-to
- public Person shipTo;// ship-to
- public List<Product> product;
- public Float tax;
- public Float total;
- public String comments;
-
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.List;
+
+public class Invoice {
+ public Integer invoice; // invoice
+ public String date; // date
+ public Person billTo;// bill-to
+ public Person shipTo;// ship-to
+ public List<Product> product;
+ public Float tax;
+ public Float total;
+ public String comments;
+
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/JavaBeanDumperTest.java b/src/test/java/org/yaml/snakeyaml/JavaBeanDumperTest.java
index 77d3107..0a04deb 100644
--- a/src/test/java/org/yaml/snakeyaml/JavaBeanDumperTest.java
+++ b/src/test/java/org/yaml/snakeyaml/JavaBeanDumperTest.java
@@ -1,109 +1,109 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.StringWriter;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.representer.Representer;
-
-@SuppressWarnings("deprecation")
-public class JavaBeanDumperTest extends TestCase {
-
- public void testDumpObjectWriter() {
- DumpBean bean = new DumpBean();
- bean.setName("Name1");
- bean.setNumber(3);
- JavaBeanDumper dumper = new JavaBeanDumper();
- String output = dumper.dump(bean);
- assertEquals("name: Name1\nnumber: 3\n", output);
- assertEquals(FlowStyle.BLOCK, dumper.getFlowStyle());
- assertFalse(dumper.isUseGlobalTag());
- //
- dumper.setFlowStyle(FlowStyle.AUTO);
- output = dumper.dump(bean);
- assertEquals("{name: Name1, number: 3}\n", output);
- //
- dumper.setUseGlobalTag(true);
- output = dumper.dump(bean);
- assertEquals("!!org.yaml.snakeyaml.JavaBeanDumperTest$DumpBean {name: Name1, number: 3}\n",
- output);
- }
-
- public void testDumpObject() {
- DumpBean bean = new DumpBean();
- bean.setName("Name2");
- bean.setNumber(4);
- JavaBeanDumper dumper = new JavaBeanDumper();
- StringWriter buffer = new StringWriter();
- dumper.dump(bean, buffer);
- assertEquals("name: Name2\nnumber: 4\n", buffer.toString());
- }
-
- public void testDumpObject2() {
- DumpBean bean = new DumpBean();
- bean.setName("Name2");
- bean.setNumber(4);
- JavaBeanDumper dumper = new JavaBeanDumper();
- StringWriter buffer = new StringWriter();
- dumper.dump(bean, buffer);
- assertEquals("name: Name2\nnumber: 4\n", buffer.toString());
- String output = dumper.dump(bean);
- assertEquals("name: Name2\nnumber: 4\n", output);
- }
-
- public void testDumpObjectNullRepresenter() {
- try {
- new JavaBeanDumper(null, new DumperOptions());
- fail();
- } catch (NullPointerException e) {
- assertEquals("Representer must be provided.", e.getMessage());
- }
- }
-
- public void testDumpObjectNullOptions() {
- try {
- new JavaBeanDumper(new Representer(), null);
- fail();
- } catch (NullPointerException e) {
- assertEquals("DumperOptions must be provided.", e.getMessage());
- }
- }
-
- public static class DumpBean {
- private String name;
- private int number;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.StringWriter;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.representer.Representer;
+
+@SuppressWarnings("deprecation")
+public class JavaBeanDumperTest extends TestCase {
+
+ public void testDumpObjectWriter() {
+ DumpBean bean = new DumpBean();
+ bean.setName("Name1");
+ bean.setNumber(3);
+ JavaBeanDumper dumper = new JavaBeanDumper();
+ String output = dumper.dump(bean);
+ assertEquals("name: Name1\nnumber: 3\n", output);
+ assertEquals(FlowStyle.BLOCK, dumper.getFlowStyle());
+ assertFalse(dumper.isUseGlobalTag());
+ //
+ dumper.setFlowStyle(FlowStyle.AUTO);
+ output = dumper.dump(bean);
+ assertEquals("{name: Name1, number: 3}\n", output);
+ //
+ dumper.setUseGlobalTag(true);
+ output = dumper.dump(bean);
+ assertEquals("!!org.yaml.snakeyaml.JavaBeanDumperTest$DumpBean {name: Name1, number: 3}\n",
+ output);
+ }
+
+ public void testDumpObject() {
+ DumpBean bean = new DumpBean();
+ bean.setName("Name2");
+ bean.setNumber(4);
+ JavaBeanDumper dumper = new JavaBeanDumper();
+ StringWriter buffer = new StringWriter();
+ dumper.dump(bean, buffer);
+ assertEquals("name: Name2\nnumber: 4\n", buffer.toString());
+ }
+
+ public void testDumpObject2() {
+ DumpBean bean = new DumpBean();
+ bean.setName("Name2");
+ bean.setNumber(4);
+ JavaBeanDumper dumper = new JavaBeanDumper();
+ StringWriter buffer = new StringWriter();
+ dumper.dump(bean, buffer);
+ assertEquals("name: Name2\nnumber: 4\n", buffer.toString());
+ String output = dumper.dump(bean);
+ assertEquals("name: Name2\nnumber: 4\n", output);
+ }
+
+ public void testDumpObjectNullRepresenter() {
+ try {
+ new JavaBeanDumper(null, new DumperOptions());
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("Representer must be provided.", e.getMessage());
+ }
+ }
+
+ public void testDumpObjectNullOptions() {
+ try {
+ new JavaBeanDumper(new Representer(), null);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("DumperOptions must be provided.", e.getMessage());
+ }
+ }
+
+ public static class DumpBean {
+ private String name;
+ private int number;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/JavaBeanLoaderTest.java b/src/test/java/org/yaml/snakeyaml/JavaBeanLoaderTest.java
index e8287e7..4ed4cd1 100644
--- a/src/test/java/org/yaml/snakeyaml/JavaBeanLoaderTest.java
+++ b/src/test/java/org/yaml/snakeyaml/JavaBeanLoaderTest.java
@@ -1,246 +1,246 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.introspector.BeanAccess;
-
-public class JavaBeanLoaderTest extends TestCase {
-
- public void testLoadString() {
- Bean bean = new Bean();
- bean.setId(3);
- bean.setName("Test me.");
- Yaml yaml = new Yaml();
- String output = yaml.dump(bean);
- assertEquals("!!org.yaml.snakeyaml.JavaBeanLoaderTest$Bean {id: 3, name: Test me.}\n",
- output);
- Yaml loader = new Yaml();
- Bean parsed = loader.loadAs(output, Bean.class);
- assertEquals(3, parsed.getId());
- assertEquals("Test me.", parsed.getName());
- // Runtime definition is more important
- Bean2 parsed2 = loader.loadAs(output, Bean2.class);
- assertEquals(3, parsed2.getId());
- assertEquals("Test me.", parsed2.getName());
- assertFalse(parsed2.isValid());
- }
-
- public void testLoadInputStream() {
- String yaml = "!!org.yaml.snakeyaml.JavaBeanParserTest$Bean {id: 3, name: Test me.}\n";
- InputStream input = new ByteArrayInputStream(yaml.getBytes());
- Yaml loader = new Yaml();
- Bean parsed = loader.loadAs(input, Bean.class);
- assertEquals(3, parsed.getId());
- assertEquals("Test me.", parsed.getName());
- }
-
- public void testLoadReader() {
- String yaml = "!!org.yaml.snakeyaml.JavaBeanParserTest$Bean {id: 3, name: Test me.}\n";
- Reader input = new StringReader(yaml);
- Yaml loader = new Yaml();
- Bean parsed = loader.loadAs(input, Bean.class);
- assertEquals(3, parsed.getId());
- assertEquals("Test me.", parsed.getName());
- }
-
- @SuppressWarnings("deprecation")
- public void testLoaderNullClass() {
- try {
- new JavaBeanLoader<Bean>((Class<Bean>) null);
- fail();
- } catch (NullPointerException e) {
- assertEquals("Class for tag must be provided.", e.getMessage());
- }
- }
-
- @SuppressWarnings("deprecation")
- public void testLoaderNullTypeDescription() {
- try {
- new JavaBeanLoader<Bean>((TypeDescription) null);
- fail();
- } catch (NullPointerException e) {
- assertEquals("TypeDescription must be provided.", e.getMessage());
- }
- }
-
- public void testLoaderNullRootClass() {
- try {
- Yaml loader = new Yaml();
- loader.loadAs("123", null);
- fail();
- } catch (NullPointerException e) {
- assertEquals("Class for tag must be provided.", e.getMessage());
- }
- }
-
- @SuppressWarnings("deprecation")
- public void testLoaderNullOptions() {
- try {
- new JavaBeanLoader<Bean>((LoaderOptions) null, BeanAccess.DEFAULT);
- fail();
- } catch (NullPointerException e) {
- assertEquals("LoaderOptions must be provided.", e.getMessage());
- }
- }
-
- public static class Bean {
- private String name;
- private int id;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
- }
-
- public static class Bean2 {
- private String name;
- private int id;
- private boolean valid;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public boolean isValid() {
- return valid;
- }
-
- public void setValid(boolean valid) {
- this.valid = valid;
- }
- }
-
- public void testTypeDescription1() {
- Bean3 bean3 = new Bean3();
- bean3.setName("Name123");
- Bean bean = new Bean();
- bean.setId(3);
- bean.setName("Test me.");
- bean3.setBean(bean);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean3);
- assertEquals("bean:\n id: 3\n name: Test me.\nlist: null\nname: Name123\n", output);
- TypeDescription td = new TypeDescription(Bean3.class);
- td.putListPropertyType("list", Integer.class);
- Yaml loader = new Yaml(new Constructor(td));
- Bean3 parsed = (Bean3) loader.load(output);
- assertEquals("Name123", parsed.getName());
- }
-
- public void testTypeDescription2() {
- Bean3 bean3 = new Bean3();
- bean3.setName("Name123");
- Bean bean = new Bean();
- bean.setId(3);
- bean.setName("Test me.");
- bean3.setBean(bean);
- List<Integer> list = new ArrayList<Integer>();
- list.add(13);
- list.add(17);
- bean3.setList(list);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean3);
- assertEquals("bean:\n id: 3\n name: Test me.\nlist:\n- 13\n- 17\nname: Name123\n", output);
- TypeDescription td = new TypeDescription(Bean3.class);
- td.putListPropertyType("list", Integer.class);
- Yaml loader = new Yaml(new Constructor(td));
- Bean3 parsed = (Bean3) loader.load(output);
- assertEquals("Name123", parsed.getName());
- List<Integer> parsedList = parsed.getList();
- assertEquals(2, parsedList.size());
- }
-
- public void testTypeDescription3() {
- Bean3 bean3 = new Bean3();
- bean3.setName("Name123");
- Bean bean = new Bean();
- bean.setId(3);
- bean.setName("Test me.");
- bean3.setBean(bean);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean3);
- assertEquals("bean:\n id: 3\n name: Test me.\nlist: null\nname: Name123\n", output);
- TypeDescription td = new TypeDescription(Bean2.class);
- Yaml loader = new Yaml(new Constructor(td));
- Bean3 parsed = loader.loadAs(output, Bean3.class);// Bean3 must be taken
- assertEquals("Name123", parsed.getName());
- }
-
- public static class Bean3 {
- private String name;
- private Bean bean;
- private List<Integer> list;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Bean getBean() {
- return bean;
- }
-
- public void setBean(Bean bean) {
- this.bean = bean;
- }
-
- public List<Integer> getList() {
- return list;
- }
-
- public void setList(List<Integer> list) {
- this.list = list;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.introspector.BeanAccess;
+
+public class JavaBeanLoaderTest extends TestCase {
+
+ public void testLoadString() {
+ Bean bean = new Bean();
+ bean.setId(3);
+ bean.setName("Test me.");
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(bean);
+ assertEquals("!!org.yaml.snakeyaml.JavaBeanLoaderTest$Bean {id: 3, name: Test me.}\n",
+ output);
+ Yaml loader = new Yaml();
+ Bean parsed = loader.loadAs(output, Bean.class);
+ assertEquals(3, parsed.getId());
+ assertEquals("Test me.", parsed.getName());
+ // Runtime definition is more important
+ Bean2 parsed2 = loader.loadAs(output, Bean2.class);
+ assertEquals(3, parsed2.getId());
+ assertEquals("Test me.", parsed2.getName());
+ assertFalse(parsed2.isValid());
+ }
+
+ public void testLoadInputStream() {
+ String yaml = "!!org.yaml.snakeyaml.JavaBeanParserTest$Bean {id: 3, name: Test me.}\n";
+ InputStream input = new ByteArrayInputStream(yaml.getBytes());
+ Yaml loader = new Yaml();
+ Bean parsed = loader.loadAs(input, Bean.class);
+ assertEquals(3, parsed.getId());
+ assertEquals("Test me.", parsed.getName());
+ }
+
+ public void testLoadReader() {
+ String yaml = "!!org.yaml.snakeyaml.JavaBeanParserTest$Bean {id: 3, name: Test me.}\n";
+ Reader input = new StringReader(yaml);
+ Yaml loader = new Yaml();
+ Bean parsed = loader.loadAs(input, Bean.class);
+ assertEquals(3, parsed.getId());
+ assertEquals("Test me.", parsed.getName());
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testLoaderNullClass() {
+ try {
+ new JavaBeanLoader<Bean>((Class<Bean>) null);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("Class for tag must be provided.", e.getMessage());
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testLoaderNullTypeDescription() {
+ try {
+ new JavaBeanLoader<Bean>((TypeDescription) null);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("TypeDescription must be provided.", e.getMessage());
+ }
+ }
+
+ public void testLoaderNullRootClass() {
+ try {
+ Yaml loader = new Yaml();
+ loader.loadAs("123", null);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("Class for tag must be provided.", e.getMessage());
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testLoaderNullOptions() {
+ try {
+ new JavaBeanLoader<Bean>((LoaderOptions) null, BeanAccess.DEFAULT);
+ fail();
+ } catch (NullPointerException e) {
+ assertEquals("LoaderOptions must be provided.", e.getMessage());
+ }
+ }
+
+ public static class Bean {
+ private String name;
+ private int id;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+ }
+
+ public static class Bean2 {
+ private String name;
+ private int id;
+ private boolean valid;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public boolean isValid() {
+ return valid;
+ }
+
+ public void setValid(boolean valid) {
+ this.valid = valid;
+ }
+ }
+
+ public void testTypeDescription1() {
+ Bean3 bean3 = new Bean3();
+ bean3.setName("Name123");
+ Bean bean = new Bean();
+ bean.setId(3);
+ bean.setName("Test me.");
+ bean3.setBean(bean);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean3);
+ assertEquals("bean:\n id: 3\n name: Test me.\nlist: null\nname: Name123\n", output);
+ TypeDescription td = new TypeDescription(Bean3.class);
+ td.putListPropertyType("list", Integer.class);
+ Yaml loader = new Yaml(new Constructor(td));
+ Bean3 parsed = (Bean3) loader.load(output);
+ assertEquals("Name123", parsed.getName());
+ }
+
+ public void testTypeDescription2() {
+ Bean3 bean3 = new Bean3();
+ bean3.setName("Name123");
+ Bean bean = new Bean();
+ bean.setId(3);
+ bean.setName("Test me.");
+ bean3.setBean(bean);
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(13);
+ list.add(17);
+ bean3.setList(list);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean3);
+ assertEquals("bean:\n id: 3\n name: Test me.\nlist:\n- 13\n- 17\nname: Name123\n", output);
+ TypeDescription td = new TypeDescription(Bean3.class);
+ td.putListPropertyType("list", Integer.class);
+ Yaml loader = new Yaml(new Constructor(td));
+ Bean3 parsed = (Bean3) loader.load(output);
+ assertEquals("Name123", parsed.getName());
+ List<Integer> parsedList = parsed.getList();
+ assertEquals(2, parsedList.size());
+ }
+
+ public void testTypeDescription3() {
+ Bean3 bean3 = new Bean3();
+ bean3.setName("Name123");
+ Bean bean = new Bean();
+ bean.setId(3);
+ bean.setName("Test me.");
+ bean3.setBean(bean);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean3);
+ assertEquals("bean:\n id: 3\n name: Test me.\nlist: null\nname: Name123\n", output);
+ TypeDescription td = new TypeDescription(Bean2.class);
+ Yaml loader = new Yaml(new Constructor(td));
+ Bean3 parsed = loader.loadAs(output, Bean3.class);// Bean3 must be taken
+ assertEquals("Name123", parsed.getName());
+ }
+
+ public static class Bean3 {
+ private String name;
+ private Bean bean;
+ private List<Integer> list;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Bean getBean() {
+ return bean;
+ }
+
+ public void setBean(Bean bean) {
+ this.bean = bean;
+ }
+
+ public List<Integer> getList() {
+ return list;
+ }
+
+ public void setList(List<Integer> list) {
+ this.list = list;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/JavaBeanTimeStampTest.java b/src/test/java/org/yaml/snakeyaml/JavaBeanTimeStampTest.java
index 63d0b49..b9403ea 100644
--- a/src/test/java/org/yaml/snakeyaml/JavaBeanTimeStampTest.java
+++ b/src/test/java/org/yaml/snakeyaml/JavaBeanTimeStampTest.java
@@ -1,62 +1,62 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.sql.Date;
-import java.sql.Timestamp;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-
-public class JavaBeanTimeStampTest extends TestCase {
- public void testLoadDefaultJavaSqlTimestamp() {
- JavaBeanWithSqlTimestamp javaBeanToDump = new JavaBeanWithSqlTimestamp();
- Timestamp stamp = new Timestamp(1000000000000L);
- javaBeanToDump.setTimestamp(stamp);
- Date date = new Date(1001376000000L);
- javaBeanToDump.setDate(date);
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- String dumpStr = yaml.dump(javaBeanToDump);
- assertEquals(
- "!!org.yaml.snakeyaml.JavaBeanWithSqlTimestamp\ndate: 2001-09-25T00:00:00Z\ntimestamp: 2001-09-09T01:46:40Z\n",
- dumpStr);
- Yaml loader = new Yaml();
- JavaBeanWithSqlTimestamp javaBeanToLoad = loader.loadAs(dumpStr,
- JavaBeanWithSqlTimestamp.class);
- assertEquals(stamp, javaBeanToLoad.getTimestamp());
- assertEquals(date, javaBeanToLoad.getDate());
- }
-
- public void testLoadDefaultJavaSqlTimestampNoGlobalTag() {
- JavaBeanWithSqlTimestamp javaBeanToDump = new JavaBeanWithSqlTimestamp();
- Timestamp stamp = new Timestamp(1000000000000L);
- javaBeanToDump.setTimestamp(stamp);
- Date date = new Date(1001376000000L);
- javaBeanToDump.setDate(date);
- Yaml yaml = new Yaml();
- String dumpStr = yaml.dumpAsMap(javaBeanToDump);
- assertEquals("date: 2001-09-25T00:00:00Z\ntimestamp: 2001-09-09T01:46:40Z\n", dumpStr);
- Yaml loader = new Yaml();
- JavaBeanWithSqlTimestamp javaBeanToLoad = loader.loadAs(dumpStr,
- JavaBeanWithSqlTimestamp.class);
- assertEquals(stamp, javaBeanToLoad.getTimestamp());
- assertEquals(date, javaBeanToLoad.getDate());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+
+public class JavaBeanTimeStampTest extends TestCase {
+ public void testLoadDefaultJavaSqlTimestamp() {
+ JavaBeanWithSqlTimestamp javaBeanToDump = new JavaBeanWithSqlTimestamp();
+ Timestamp stamp = new Timestamp(1000000000000L);
+ javaBeanToDump.setTimestamp(stamp);
+ Date date = new Date(1001376000000L);
+ javaBeanToDump.setDate(date);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ String dumpStr = yaml.dump(javaBeanToDump);
+ assertEquals(
+ "!!org.yaml.snakeyaml.JavaBeanWithSqlTimestamp\ndate: 2001-09-25T00:00:00Z\ntimestamp: 2001-09-09T01:46:40Z\n",
+ dumpStr);
+ Yaml loader = new Yaml();
+ JavaBeanWithSqlTimestamp javaBeanToLoad = loader.loadAs(dumpStr,
+ JavaBeanWithSqlTimestamp.class);
+ assertEquals(stamp, javaBeanToLoad.getTimestamp());
+ assertEquals(date, javaBeanToLoad.getDate());
+ }
+
+ public void testLoadDefaultJavaSqlTimestampNoGlobalTag() {
+ JavaBeanWithSqlTimestamp javaBeanToDump = new JavaBeanWithSqlTimestamp();
+ Timestamp stamp = new Timestamp(1000000000000L);
+ javaBeanToDump.setTimestamp(stamp);
+ Date date = new Date(1001376000000L);
+ javaBeanToDump.setDate(date);
+ Yaml yaml = new Yaml();
+ String dumpStr = yaml.dumpAsMap(javaBeanToDump);
+ assertEquals("date: 2001-09-25T00:00:00Z\ntimestamp: 2001-09-09T01:46:40Z\n", dumpStr);
+ Yaml loader = new Yaml();
+ JavaBeanWithSqlTimestamp javaBeanToLoad = loader.loadAs(dumpStr,
+ JavaBeanWithSqlTimestamp.class);
+ assertEquals(stamp, javaBeanToLoad.getTimestamp());
+ assertEquals(date, javaBeanToLoad.getDate());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/JavaBeanWithSqlTimestamp.java b/src/test/java/org/yaml/snakeyaml/JavaBeanWithSqlTimestamp.java
index c05b51d..158a7c7 100644
--- a/src/test/java/org/yaml/snakeyaml/JavaBeanWithSqlTimestamp.java
+++ b/src/test/java/org/yaml/snakeyaml/JavaBeanWithSqlTimestamp.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-public class JavaBeanWithSqlTimestamp {
- private java.sql.Timestamp timestamp;
- private java.sql.Date date;
-
- public java.sql.Timestamp getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(java.sql.Timestamp timestamp) {
- this.timestamp = timestamp;
- }
-
- public java.sql.Date getDate() {
- return date;
- }
-
- public void setDate(java.sql.Date date) {
- this.date = date;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+public class JavaBeanWithSqlTimestamp {
+ private java.sql.Timestamp timestamp;
+ private java.sql.Date date;
+
+ public java.sql.Timestamp getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(java.sql.Timestamp timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public java.sql.Date getDate() {
+ return date;
+ }
+
+ public void setDate(java.sql.Date date) {
+ this.date = date;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/LoaderTest.java b/src/test/java/org/yaml/snakeyaml/LoaderTest.java
index a1371ba..caeef52 100644
--- a/src/test/java/org/yaml/snakeyaml/LoaderTest.java
+++ b/src/test/java/org/yaml/snakeyaml/LoaderTest.java
@@ -1,105 +1,105 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.StringReader;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeId;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-public class LoaderTest extends TestCase {
-
- public void testCompose1() {
- Yaml loader = new Yaml();
- String yaml = "abc: 3";
- MappingNode node = (MappingNode) loader.compose(new StringReader(yaml));
- List<NodeTuple> nodes = node.getValue();
- assertEquals(1, nodes.size());
- NodeTuple pairs = nodes.get(0);
- ScalarNode key = (ScalarNode) pairs.getKeyNode();
- assertEquals(Tag.STR, key.getTag());
- assertEquals("abc", key.getValue());
- //
- ScalarNode value = (ScalarNode) pairs.getValueNode();
- assertEquals(Tag.INT, value.getTag());
- assertEquals("3", value.getValue());
- //
- assertEquals(
- "<org.yaml.snakeyaml.nodes.MappingNode (tag=tag:yaml.org,2002:map, values={ key=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=abc)>; value=<NodeTuple keyNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=abc)>; valueNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:int, value=3)>> })>",
- node.toString());
- }
-
- public void testCompose2() {
- LoaderOptions options = new LoaderOptions();
- Yaml loader = new Yaml(options);
- String yaml = "3";
- ScalarNode node = (ScalarNode) loader.compose(new StringReader(yaml));
- assertEquals(Tag.INT, node.getTag());
- assertEquals("3", node.getValue());
- // not sure whether it should be null or 0
- assertEquals(new Character('\u0000'), node.getStyle());
- assertEquals(Object.class, node.getType());
- Mark mark = node.getStartMark();
- assertEquals(0, mark.getColumn());
- assertEquals(0, mark.getLine());
- assertEquals("<reader>", mark.getName());
- assertEquals(" 3\n ^", mark.get_snippet());
- assertEquals("<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:int, value=3)>",
- node.toString());
- }
-
- public void testComposeAll() {
- Yaml loader = new Yaml();
- String yaml = "abc: 3\n---\n2\n---\n- qwe\n- asd\n";
- int counter = 0;
- for (Node node : loader.composeAll(new StringReader(yaml))) {
- assertNotNull(node);
- switch (counter++) {
- case 0:
- assertEquals(NodeId.mapping, node.getNodeId());
- break;
- case 1:
- assertEquals(NodeId.scalar, node.getNodeId());
- break;
- case 2:
- assertEquals(NodeId.sequence, node.getNodeId());
- break;
- default:
- fail("Unexpected document.");
- }
- }
- }
-
- @SuppressWarnings("deprecation")
- public void testDeprecated() {
- Yaml yaml = new Yaml(new Loader());
- yaml.load("123");
- yaml = new Yaml(new Loader(), new Dumper());
- yaml.load("123");
- yaml = new Yaml(new Loader(), new Dumper(), new Resolver());
- yaml.load("123");
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.StringReader;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeId;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+public class LoaderTest extends TestCase {
+
+ public void testCompose1() {
+ Yaml loader = new Yaml();
+ String yaml = "abc: 3";
+ MappingNode node = (MappingNode) loader.compose(new StringReader(yaml));
+ List<NodeTuple> nodes = node.getValue();
+ assertEquals(1, nodes.size());
+ NodeTuple pairs = nodes.get(0);
+ ScalarNode key = (ScalarNode) pairs.getKeyNode();
+ assertEquals(Tag.STR, key.getTag());
+ assertEquals("abc", key.getValue());
+ //
+ ScalarNode value = (ScalarNode) pairs.getValueNode();
+ assertEquals(Tag.INT, value.getTag());
+ assertEquals("3", value.getValue());
+ //
+ assertEquals(
+ "<org.yaml.snakeyaml.nodes.MappingNode (tag=tag:yaml.org,2002:map, values={ key=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=abc)>; value=<NodeTuple keyNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=abc)>; valueNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:int, value=3)>> })>",
+ node.toString());
+ }
+
+ public void testCompose2() {
+ LoaderOptions options = new LoaderOptions();
+ Yaml loader = new Yaml(options);
+ String yaml = "3";
+ ScalarNode node = (ScalarNode) loader.compose(new StringReader(yaml));
+ assertEquals(Tag.INT, node.getTag());
+ assertEquals("3", node.getValue());
+ // not sure whether it should be null or 0
+ assertEquals(new Character('\u0000'), node.getStyle());
+ assertEquals(Object.class, node.getType());
+ Mark mark = node.getStartMark();
+ assertEquals(0, mark.getColumn());
+ assertEquals(0, mark.getLine());
+ assertEquals("<reader>", mark.getName());
+ assertEquals(" 3\n ^", mark.get_snippet());
+ assertEquals("<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:int, value=3)>",
+ node.toString());
+ }
+
+ public void testComposeAll() {
+ Yaml loader = new Yaml();
+ String yaml = "abc: 3\n---\n2\n---\n- qwe\n- asd\n";
+ int counter = 0;
+ for (Node node : loader.composeAll(new StringReader(yaml))) {
+ assertNotNull(node);
+ switch (counter++) {
+ case 0:
+ assertEquals(NodeId.mapping, node.getNodeId());
+ break;
+ case 1:
+ assertEquals(NodeId.scalar, node.getNodeId());
+ break;
+ case 2:
+ assertEquals(NodeId.sequence, node.getNodeId());
+ break;
+ default:
+ fail("Unexpected document.");
+ }
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void testDeprecated() {
+ Yaml yaml = new Yaml(new Loader());
+ yaml.load("123");
+ yaml = new Yaml(new Loader(), new Dumper());
+ yaml.load("123");
+ yaml = new Yaml(new Loader(), new Dumper(), new Resolver());
+ yaml.load("123");
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Person.java b/src/test/java/org/yaml/snakeyaml/Person.java
index fd3a0b7..2866af4 100644
--- a/src/test/java/org/yaml/snakeyaml/Person.java
+++ b/src/test/java/org/yaml/snakeyaml/Person.java
@@ -1,23 +1,23 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-public class Person {
- public String given;
- public String family;
- public Address address;
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+public class Person {
+ public String given;
+ public String family;
+ public Address address;
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/Product.java b/src/test/java/org/yaml/snakeyaml/Product.java
index d424d47..049fd9f 100644
--- a/src/test/java/org/yaml/snakeyaml/Product.java
+++ b/src/test/java/org/yaml/snakeyaml/Product.java
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-public class Product {
- public String sku;
- public Integer quantity;
- public String description;
- public Float price;
-
- @Override
- public String toString() {
- return "Product: " + sku;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+public class Product {
+ public String sku;
+ public Integer quantity;
+ public String description;
+ public Float price;
+
+ @Override
+ public String toString() {
+ return "Product: " + sku;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/Suit.java b/src/test/java/org/yaml/snakeyaml/Suit.java
index c856be3..dcdb0b5 100644
--- a/src/test/java/org/yaml/snakeyaml/Suit.java
+++ b/src/test/java/org/yaml/snakeyaml/Suit.java
@@ -1,21 +1,21 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-public enum Suit {
- CLUBS, DIAMONDS, HEARTS, SPADES
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+public enum Suit {
+ CLUBS, DIAMONDS, HEARTS, SPADES
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/TypeDescriptionTest.java b/src/test/java/org/yaml/snakeyaml/TypeDescriptionTest.java
index c2d2d7c..5234aa4 100644
--- a/src/test/java/org/yaml/snakeyaml/TypeDescriptionTest.java
+++ b/src/test/java/org/yaml/snakeyaml/TypeDescriptionTest.java
@@ -1,40 +1,40 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.constructor.ArrayTagsTest.CarWithArray;
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class TypeDescriptionTest extends TestCase {
-
- public void testSetTag() {
- TypeDescription descr = new TypeDescription(TypeDescriptionTest.class);
- descr.setTag("!bla");
- assertEquals(new Tag("!bla"), descr.getTag());
- descr.setTag(new Tag("!foo"));
- assertEquals(new Tag("!foo"), descr.getTag());
- }
-
- public void testToString() {
- TypeDescription carDescription = new TypeDescription(CarWithArray.class, "!car");
- assertEquals(
- "TypeDescription for class org.yaml.snakeyaml.constructor.ArrayTagsTest$CarWithArray (tag='!car')",
- carDescription.toString());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.constructor.ArrayTagsTest.CarWithArray;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class TypeDescriptionTest extends TestCase {
+
+ public void testSetTag() {
+ TypeDescription descr = new TypeDescription(TypeDescriptionTest.class);
+ descr.setTag("!bla");
+ assertEquals(new Tag("!bla"), descr.getTag());
+ descr.setTag(new Tag("!foo"));
+ assertEquals(new Tag("!foo"), descr.getTag());
+ }
+
+ public void testToString() {
+ TypeDescription carDescription = new TypeDescription(CarWithArray.class, "!car");
+ assertEquals(
+ "TypeDescription for class org.yaml.snakeyaml.constructor.ArrayTagsTest$CarWithArray (tag='!car')",
+ carDescription.toString());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/Util.java b/src/test/java/org/yaml/snakeyaml/Util.java
index 6fe26e5..59852b4 100644
--- a/src/test/java/org/yaml/snakeyaml/Util.java
+++ b/src/test/java/org/yaml/snakeyaml/Util.java
@@ -1,55 +1,55 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class Util {
-
- public static String getLocalResource(String theName) {
- try {
- InputStream input;
- input = YamlDocument.class.getClassLoader().getResourceAsStream(theName);
- if (input == null) {
- throw new RuntimeException("Can not find " + theName);
- }
- BufferedInputStream is = new BufferedInputStream(input);
- StringBuilder buf = new StringBuilder(3000);
- int i;
- try {
- while ((i = is.read()) != -1) {
- buf.append((char) i);
- }
- } finally {
- is.close();
- }
- String resource = buf.toString();
- // convert EOLs
- String[] lines = resource.split("\\r?\\n");
- StringBuilder buffer = new StringBuilder();
- for (int j = 0; j < lines.length; j++) {
- buffer.append(lines[j]);
- buffer.append("\n");
- }
- return buffer.toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class Util {
+
+ public static String getLocalResource(String theName) {
+ try {
+ InputStream input;
+ input = YamlDocument.class.getClassLoader().getResourceAsStream(theName);
+ if (input == null) {
+ throw new RuntimeException("Can not find " + theName);
+ }
+ BufferedInputStream is = new BufferedInputStream(input);
+ StringBuilder buf = new StringBuilder(3000);
+ int i;
+ try {
+ while ((i = is.read()) != -1) {
+ buf.append((char) i);
+ }
+ } finally {
+ is.close();
+ }
+ String resource = buf.toString();
+ // convert EOLs
+ String[] lines = resource.split("\\r?\\n");
+ StringBuilder buffer = new StringBuilder();
+ for (int j = 0; j < lines.length; j++) {
+ buffer.append(lines[j]);
+ buffer.append("\n");
+ }
+ return buffer.toString();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/YamlComposeTest.java b/src/test/java/org/yaml/snakeyaml/YamlComposeTest.java
index 72ef1dc..ca348a0 100644
--- a/src/test/java/org/yaml/snakeyaml/YamlComposeTest.java
+++ b/src/test/java/org/yaml/snakeyaml/YamlComposeTest.java
@@ -1,69 +1,69 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeId;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-
-public class YamlComposeTest extends TestCase {
-
- public void testComposeManyDocuments() {
- try {
- Yaml yaml = new Yaml();
- yaml.compose(new StringReader("abc: 56\n---\n123\n---\n456"));
- fail("YAML contans more then one document.");
- } catch (Exception e) {
- assertEquals("expected a single document in the stream; but found another document",
- e.getMessage());
- }
- }
-
- public void testComposeFromReader() {
- Yaml yaml = new Yaml();
- MappingNode node = (MappingNode) yaml.compose(new StringReader("abc: 56"));
- ScalarNode node1 = (ScalarNode) node.getValue().get(0).getKeyNode();
- assertEquals("abc", node1.getValue());
- ScalarNode node2 = (ScalarNode) node.getValue().get(0).getValueNode();
- assertEquals("56", node2.getValue());
- }
-
- public void testComposeAllFromReader() {
- Yaml yaml = new Yaml();
- boolean first = true;
- for (Node node : yaml.composeAll(new StringReader("abc: 56\n---\n123\n---\n456"))) {
- if (first) {
- assertEquals(NodeId.mapping, node.getNodeId());
- } else {
- assertEquals(NodeId.scalar, node.getNodeId());
- }
- first = false;
- }
- }
-
- public void testComposeAllOneDocument() {
- Yaml yaml = new Yaml();
- for (Node node : yaml.composeAll(new StringReader("6"))) {
- assertEquals(NodeId.scalar, node.getNodeId());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeId;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+
+public class YamlComposeTest extends TestCase {
+
+ public void testComposeManyDocuments() {
+ try {
+ Yaml yaml = new Yaml();
+ yaml.compose(new StringReader("abc: 56\n---\n123\n---\n456"));
+ fail("YAML contans more then one document.");
+ } catch (Exception e) {
+ assertEquals("expected a single document in the stream; but found another document",
+ e.getMessage());
+ }
+ }
+
+ public void testComposeFromReader() {
+ Yaml yaml = new Yaml();
+ MappingNode node = (MappingNode) yaml.compose(new StringReader("abc: 56"));
+ ScalarNode node1 = (ScalarNode) node.getValue().get(0).getKeyNode();
+ assertEquals("abc", node1.getValue());
+ ScalarNode node2 = (ScalarNode) node.getValue().get(0).getValueNode();
+ assertEquals("56", node2.getValue());
+ }
+
+ public void testComposeAllFromReader() {
+ Yaml yaml = new Yaml();
+ boolean first = true;
+ for (Node node : yaml.composeAll(new StringReader("abc: 56\n---\n123\n---\n456"))) {
+ if (first) {
+ assertEquals(NodeId.mapping, node.getNodeId());
+ } else {
+ assertEquals(NodeId.scalar, node.getNodeId());
+ }
+ first = false;
+ }
+ }
+
+ public void testComposeAllOneDocument() {
+ Yaml yaml = new Yaml();
+ for (Node node : yaml.composeAll(new StringReader("6"))) {
+ assertEquals(NodeId.scalar, node.getNodeId());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/YamlDocument.java b/src/test/java/org/yaml/snakeyaml/YamlDocument.java
index b240f8d..c2a8712 100644
--- a/src/test/java/org/yaml/snakeyaml/YamlDocument.java
+++ b/src/test/java/org/yaml/snakeyaml/YamlDocument.java
@@ -1,80 +1,80 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class YamlDocument {
- public static final String ROOT = "specification/";
- private String source;
- private String presentation;
- private Object nativeData;
-
- public YamlDocument(String sourceName, boolean check, Constructor constructor) {
- InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
- ROOT + sourceName);
- if (constructor == null) {
- constructor = new Constructor();
- }
- Yaml yaml = new Yaml(constructor);
- nativeData = yaml.load(input);
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- Charset charset = Charset.forName("UTF-8");
- yaml.dump(nativeData, new OutputStreamWriter(output, charset));
- try {
- presentation = output.toString(charset.name());
- source = Util.getLocalResource(ROOT + sourceName);
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- // try to read generated presentation to prove that the presentation
- // is identical to the source
- Object result = yaml.load(presentation);
- if (check && !nativeData.equals(result)) {
- throw new RuntimeException("Generated presentation is not valid: " + presentation);
- }
- }
-
- public YamlDocument(String sourceName, boolean check) {
- this(sourceName, check, null);
- }
-
- public YamlDocument(String sourceName) {
- this(sourceName, true);
- }
-
- public String getSource() {
- return source;
- }
-
- public String getPresentation() {
- return presentation;
- }
-
- public Object getNativeData() {
- if (nativeData == null) {
- throw new NullPointerException("No object is parsed.");
- }
- return nativeData;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
+
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class YamlDocument {
+ public static final String ROOT = "specification/";
+ private String source;
+ private String presentation;
+ private Object nativeData;
+
+ public YamlDocument(String sourceName, boolean check, Constructor constructor) {
+ InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
+ ROOT + sourceName);
+ if (constructor == null) {
+ constructor = new Constructor();
+ }
+ Yaml yaml = new Yaml(constructor);
+ nativeData = yaml.load(input);
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ Charset charset = Charset.forName("UTF-8");
+ yaml.dump(nativeData, new OutputStreamWriter(output, charset));
+ try {
+ presentation = output.toString(charset.name());
+ source = Util.getLocalResource(ROOT + sourceName);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ // try to read generated presentation to prove that the presentation
+ // is identical to the source
+ Object result = yaml.load(presentation);
+ if (check && !nativeData.equals(result)) {
+ throw new RuntimeException("Generated presentation is not valid: " + presentation);
+ }
+ }
+
+ public YamlDocument(String sourceName, boolean check) {
+ this(sourceName, check, null);
+ }
+
+ public YamlDocument(String sourceName) {
+ this(sourceName, true);
+ }
+
+ public String getSource() {
+ return source;
+ }
+
+ public String getPresentation() {
+ return presentation;
+ }
+
+ public Object getNativeData() {
+ if (nativeData == null) {
+ throw new NullPointerException("No object is parsed.");
+ }
+ return nativeData;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/YamlParseTest.java b/src/test/java/org/yaml/snakeyaml/YamlParseTest.java
index 3775673..cb5fcb9 100644
--- a/src/test/java/org/yaml/snakeyaml/YamlParseTest.java
+++ b/src/test/java/org/yaml/snakeyaml/YamlParseTest.java
@@ -1,58 +1,58 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.StreamEndEvent;
-import org.yaml.snakeyaml.events.StreamStartEvent;
-
-public class YamlParseTest extends TestCase {
-
- public void testParse() {
- Yaml yaml = new Yaml();
- Event e = null;
- int counter = 0;
- for (Event event : yaml.parse(new StringReader("abc: 56"))) {
- if (e == null) {
- assertTrue(event instanceof StreamStartEvent);
- }
- e = event;
- counter++;
- }
- assertTrue(e instanceof StreamEndEvent);
- assertEquals(8, counter);
- }
-
- public void testParseManyDocuments() {
- Yaml yaml = new Yaml();
- Event e = null;
- int counter = 0;
- for (Event event : yaml.parse(new StringReader("abc: 56\n---\n4\n---\nqwe\n"))) {
- if (e == null) {
- assertTrue(event instanceof StreamStartEvent);
- }
- e = event;
- counter++;
- }
- assertTrue(e instanceof StreamEndEvent);
- assertEquals(14, counter);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.StreamEndEvent;
+import org.yaml.snakeyaml.events.StreamStartEvent;
+
+public class YamlParseTest extends TestCase {
+
+ public void testParse() {
+ Yaml yaml = new Yaml();
+ Event e = null;
+ int counter = 0;
+ for (Event event : yaml.parse(new StringReader("abc: 56"))) {
+ if (e == null) {
+ assertTrue(event instanceof StreamStartEvent);
+ }
+ e = event;
+ counter++;
+ }
+ assertTrue(e instanceof StreamEndEvent);
+ assertEquals(8, counter);
+ }
+
+ public void testParseManyDocuments() {
+ Yaml yaml = new Yaml();
+ Event e = null;
+ int counter = 0;
+ for (Event event : yaml.parse(new StringReader("abc: 56\n---\n4\n---\nqwe\n"))) {
+ if (e == null) {
+ assertTrue(event instanceof StreamStartEvent);
+ }
+ e = event;
+ counter++;
+ }
+ assertTrue(e instanceof StreamEndEvent);
+ assertEquals(14, counter);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/YamlStream.java b/src/test/java/org/yaml/snakeyaml/YamlStream.java
index 76a2326..7635b87 100644
--- a/src/test/java/org/yaml/snakeyaml/YamlStream.java
+++ b/src/test/java/org/yaml/snakeyaml/YamlStream.java
@@ -1,96 +1,96 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.AssertionFailedError;
-
-public class YamlStream {
- private List<Object> nativeData = new ArrayList<Object>();
-
- public YamlStream(String sourceName) {
- InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
- YamlDocument.ROOT + sourceName);
- Yaml yaml = new Yaml();
- for (Object document : yaml.loadAll(input)) {
- nativeData.add(document);
- }
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- yaml.dumpAll(nativeData.iterator(), new OutputStreamWriter(output));
- String presentation;
- try {
- presentation = output.toString("UTF-8");
- } catch (UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
- // try to read generated presentation to prove that the presentation
- // is identical to the source
- List<Object> parsedNativeData = new ArrayList<Object>();
- for (Object document : yaml.loadAll(presentation)) {
- parsedNativeData.add(document);
- }
- if (nativeData.getClass() != parsedNativeData.getClass()) {
- throw new AssertionFailedError("Different class: " + parsedNativeData.getClass());
- }
- if (nativeData.size() != parsedNativeData.size()) {
- throw new AssertionFailedError("Different size.");
- }
- Iterator<Object> piterator = parsedNativeData.iterator();
- Iterator<Object> niterator = nativeData.iterator();
- while (piterator.hasNext()) {
- Object obj1 = niterator.next();
- Object obj2 = piterator.next();
- if (obj1 instanceof Map) {
- @SuppressWarnings("unchecked")
- Map<Object, Object> map1 = (Map<Object, Object>) obj1;
- @SuppressWarnings("unchecked")
- Map<Object, Object> map2 = (Map<Object, Object>) obj2;
- if (!map1.keySet().equals(map2.keySet())) {
- throw new AssertionFailedError("Keyset: " + map1.keySet() + "; but was: "
- + map2.keySet());
- }
- for (Iterator<Object> iterator = map1.keySet().iterator(); iterator.hasNext();) {
- Object key = iterator.next();
- Object o1 = map1.get(key);
- Object o2 = map2.get(key);
- if (!o1.equals(o2)) {
- throw new AssertionFailedError("Values: " + o1 + "; but was: " + o2);
- }
- }
- }
- if (!obj1.equals(obj2)) {
- throw new AssertionFailedError("Expected: " + obj1 + "; but was: " + obj2);
- }
- }
- if (!parsedNativeData.equals(nativeData)) {
- throw new AssertionFailedError("Generated presentation is not the same: "
- + presentation);
- }
- }
-
- public List<Object> getNativeData() {
- return nativeData;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.AssertionFailedError;
+
+public class YamlStream {
+ private List<Object> nativeData = new ArrayList<Object>();
+
+ public YamlStream(String sourceName) {
+ InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
+ YamlDocument.ROOT + sourceName);
+ Yaml yaml = new Yaml();
+ for (Object document : yaml.loadAll(input)) {
+ nativeData.add(document);
+ }
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
+ yaml.dumpAll(nativeData.iterator(), new OutputStreamWriter(output));
+ String presentation;
+ try {
+ presentation = output.toString("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ // try to read generated presentation to prove that the presentation
+ // is identical to the source
+ List<Object> parsedNativeData = new ArrayList<Object>();
+ for (Object document : yaml.loadAll(presentation)) {
+ parsedNativeData.add(document);
+ }
+ if (nativeData.getClass() != parsedNativeData.getClass()) {
+ throw new AssertionFailedError("Different class: " + parsedNativeData.getClass());
+ }
+ if (nativeData.size() != parsedNativeData.size()) {
+ throw new AssertionFailedError("Different size.");
+ }
+ Iterator<Object> piterator = parsedNativeData.iterator();
+ Iterator<Object> niterator = nativeData.iterator();
+ while (piterator.hasNext()) {
+ Object obj1 = niterator.next();
+ Object obj2 = piterator.next();
+ if (obj1 instanceof Map) {
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> map1 = (Map<Object, Object>) obj1;
+ @SuppressWarnings("unchecked")
+ Map<Object, Object> map2 = (Map<Object, Object>) obj2;
+ if (!map1.keySet().equals(map2.keySet())) {
+ throw new AssertionFailedError("Keyset: " + map1.keySet() + "; but was: "
+ + map2.keySet());
+ }
+ for (Iterator<Object> iterator = map1.keySet().iterator(); iterator.hasNext();) {
+ Object key = iterator.next();
+ Object o1 = map1.get(key);
+ Object o2 = map2.get(key);
+ if (!o1.equals(o2)) {
+ throw new AssertionFailedError("Values: " + o1 + "; but was: " + o2);
+ }
+ }
+ }
+ if (!obj1.equals(obj2)) {
+ throw new AssertionFailedError("Expected: " + obj1 + "; but was: " + obj2);
+ }
+ }
+ if (!parsedNativeData.equals(nativeData)) {
+ throw new AssertionFailedError("Generated presentation is not the same: "
+ + presentation);
+ }
+ }
+
+ public List<Object> getNativeData() {
+ return nativeData;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/YamlTest.java b/src/test/java/org/yaml/snakeyaml/YamlTest.java
index a54c743..cb706c7 100644
--- a/src/test/java/org/yaml/snakeyaml/YamlTest.java
+++ b/src/test/java/org/yaml/snakeyaml/YamlTest.java
@@ -1,70 +1,70 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.YAMLException;
-
-public class YamlTest extends TestCase {
-
- public void testSetNoName() {
- Yaml yaml = new Yaml();
- assertTrue(yaml.toString().matches("Yaml:\\d+"));
- }
-
- public void testSetName() {
- Yaml yaml = new Yaml();
- yaml.setName("REST");
- assertEquals("REST", yaml.getName());
- assertEquals("REST", yaml.toString());
- }
-
- /**
- * Check that documents are parsed only when they are asked to be loaded.
- */
- public void testOneDocument() {
- Yaml yaml = new Yaml();
- String doc = "--- a\n--- [:]";
- Iterator<Object> loaded = yaml.loadAll(doc).iterator();
- assertTrue(loaded.hasNext());
- Object obj1 = loaded.next();
- assertEquals("a", obj1);
- assertTrue(loaded.hasNext());
- try {
- loaded.next();
- fail("Second document is invalid");
- } catch (Exception e) {
- assertEquals("while parsing a flow node; expected the node content, but found Value",
- e.getMessage());
- }
- }
-
- public void testOnlyOneDocument() {
- Yaml yaml = new Yaml();
- String doc = "--- a\n--- b";
- try {
- yaml.load(doc);
- fail("It must be only one document.");
- } catch (YAMLException e) {
- assertEquals("expected a single document in the stream; but found another document",
- e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class YamlTest extends TestCase {
+
+ public void testSetNoName() {
+ Yaml yaml = new Yaml();
+ assertTrue(yaml.toString().matches("Yaml:\\d+"));
+ }
+
+ public void testSetName() {
+ Yaml yaml = new Yaml();
+ yaml.setName("REST");
+ assertEquals("REST", yaml.getName());
+ assertEquals("REST", yaml.toString());
+ }
+
+ /**
+ * Check that documents are parsed only when they are asked to be loaded.
+ */
+ public void testOneDocument() {
+ Yaml yaml = new Yaml();
+ String doc = "--- a\n--- [:]";
+ Iterator<Object> loaded = yaml.loadAll(doc).iterator();
+ assertTrue(loaded.hasNext());
+ Object obj1 = loaded.next();
+ assertEquals("a", obj1);
+ assertTrue(loaded.hasNext());
+ try {
+ loaded.next();
+ fail("Second document is invalid");
+ } catch (Exception e) {
+ assertEquals("while parsing a flow node; expected the node content, but found Value",
+ e.getMessage());
+ }
+ }
+
+ public void testOnlyOneDocument() {
+ Yaml yaml = new Yaml();
+ String doc = "--- a\n--- b";
+ try {
+ yaml.load(doc);
+ fail("It must be only one document.");
+ } catch (YAMLException e) {
+ assertEquals("expected a single document in the stream; but found another document",
+ e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/composer/ComposerImplTest.java b/src/test/java/org/yaml/snakeyaml/composer/ComposerImplTest.java
index b3d5f92..f35cf4f 100644
--- a/src/test/java/org/yaml/snakeyaml/composer/ComposerImplTest.java
+++ b/src/test/java/org/yaml/snakeyaml/composer/ComposerImplTest.java
@@ -1,75 +1,75 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.composer;
-
-import java.io.StringReader;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeId;
-
-public class ComposerImplTest extends TestCase {
-
- public void testGetNode() {
- String data = "american:\n - Boston Red Sox";
- Yaml yaml = new Yaml();
- Node node = yaml.compose(new StringReader(data));
- assertNotNull(node);
- assertTrue(node instanceof MappingNode);
- String data2 = "---\namerican:\n- Boston Red Sox";
- Node node2 = yaml.compose(new StringReader(data2));
- assertNotNull(node2);
- assertFalse(node.equals(node2));
- }
-
- public void testComposeBean() {
- String data = "!!org.yaml.snakeyaml.composer.ComposerImplTest$BeanToCompose {name: Bill, age: 18}";
- Yaml yaml = new Yaml();
- Node node = yaml.compose(new StringReader(data));
- assertNotNull(node);
- assertTrue(node instanceof MappingNode);
- assertEquals(
- "tag:yaml.org,2002:org.yaml.snakeyaml.composer.ComposerImplTest$BeanToCompose",
- node.getTag().getValue());
- assertEquals(NodeId.mapping, node.getNodeId());
- assertEquals(Object.class, node.getType());
- }
-
- public static class BeanToCompose {
- private String name;
- private int age;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.composer;
+
+import java.io.StringReader;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeId;
+
+public class ComposerImplTest extends TestCase {
+
+ public void testGetNode() {
+ String data = "american:\n - Boston Red Sox";
+ Yaml yaml = new Yaml();
+ Node node = yaml.compose(new StringReader(data));
+ assertNotNull(node);
+ assertTrue(node instanceof MappingNode);
+ String data2 = "---\namerican:\n- Boston Red Sox";
+ Node node2 = yaml.compose(new StringReader(data2));
+ assertNotNull(node2);
+ assertFalse(node.equals(node2));
+ }
+
+ public void testComposeBean() {
+ String data = "!!org.yaml.snakeyaml.composer.ComposerImplTest$BeanToCompose {name: Bill, age: 18}";
+ Yaml yaml = new Yaml();
+ Node node = yaml.compose(new StringReader(data));
+ assertNotNull(node);
+ assertTrue(node instanceof MappingNode);
+ assertEquals(
+ "tag:yaml.org,2002:org.yaml.snakeyaml.composer.ComposerImplTest$BeanToCompose",
+ node.getTag().getValue());
+ assertEquals(NodeId.mapping, node.getNodeId());
+ assertEquals(Object.class, node.getType());
+ }
+
+ public static class BeanToCompose {
+ private String name;
+ private int age;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ArrayTagsTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ArrayTagsTest.java
index 7b6f8b5..a67239e 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ArrayTagsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ArrayTagsTest.java
@@ -1,113 +1,113 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-public class ArrayTagsTest extends TestCase {
-
- public void testDefaultRepresenter() {
- CarWithArray car = new CarWithArray();
- car.setPlate("12-XP-F4");
- Wheel[] wheels = new Wheel[5];
- for (int i = 1; i < 6; i++) {
- Wheel wheel = new Wheel();
- wheel.setId(i);
- wheels[i - 1] = wheel;
- }
- car.setWheels(wheels);
- assertEquals(Util.getLocalResource("constructor/cararray-with-tags-flow-auto.yaml"),
- new Yaml().dump(car));
- }
-
- public void testFlowBlock() {
- CarWithArray car = new CarWithArray();
- car.setPlate("12-XP-F4");
- Wheel[] wheels = new Wheel[5];
- for (int i = 1; i < 6; i++) {
- Wheel wheel = new Wheel();
- wheel.setId(i);
- wheels[i - 1] = wheel;
- }
- car.setWheels(wheels);
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- assertEquals(Util.getLocalResource("constructor/cararray-with-tags.yaml"), yaml.dump(car));
- }
-
- public void testLoadClassTag() {
- Constructor constructor = new Constructor();
- constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
- Yaml yaml = new Yaml(constructor);
- Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
- assertEquals("12-XP-F4", car.getPlate());
- List<Wheel> wheels = car.getWheels();
- assertNotNull(wheels);
- assertEquals(5, wheels.size());
- }
-
- public void testNullDescription() {
- Constructor constructor = new Constructor();
- try {
- constructor.addTypeDescription(null);
- fail("Description is required.");
- } catch (Exception e) {
- assertEquals("TypeDescription is required.", e.getMessage());
- }
- }
-
- public void testLoadClassNoRoot() {
- Constructor constructor = new Constructor(new TypeDescription(CarWithArray.class));
- Yaml yaml = new Yaml(constructor);
- CarWithArray car = (CarWithArray) yaml.load(Util
- .getLocalResource("constructor/car-no-root-class.yaml"));
- assertEquals("12-XP-F4", car.getPlate());
- Wheel[] wheels = car.getWheels();
- assertNotNull(wheels);
- assertEquals(5, wheels.length);
- }
-
- public static class CarWithArray {
- private String plate;
- private Wheel[] wheels;
-
- public String getPlate() {
- return plate;
- }
-
- public void setPlate(String plate) {
- this.plate = plate;
- }
-
- public Wheel[] getWheels() {
- return wheels;
- }
-
- public void setWheels(Wheel[] wheels) {
- this.wheels = wheels;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+public class ArrayTagsTest extends TestCase {
+
+ public void testDefaultRepresenter() {
+ CarWithArray car = new CarWithArray();
+ car.setPlate("12-XP-F4");
+ Wheel[] wheels = new Wheel[5];
+ for (int i = 1; i < 6; i++) {
+ Wheel wheel = new Wheel();
+ wheel.setId(i);
+ wheels[i - 1] = wheel;
+ }
+ car.setWheels(wheels);
+ assertEquals(Util.getLocalResource("constructor/cararray-with-tags-flow-auto.yaml"),
+ new Yaml().dump(car));
+ }
+
+ public void testFlowBlock() {
+ CarWithArray car = new CarWithArray();
+ car.setPlate("12-XP-F4");
+ Wheel[] wheels = new Wheel[5];
+ for (int i = 1; i < 6; i++) {
+ Wheel wheel = new Wheel();
+ wheel.setId(i);
+ wheels[i - 1] = wheel;
+ }
+ car.setWheels(wheels);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ assertEquals(Util.getLocalResource("constructor/cararray-with-tags.yaml"), yaml.dump(car));
+ }
+
+ public void testLoadClassTag() {
+ Constructor constructor = new Constructor();
+ constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
+ Yaml yaml = new Yaml(constructor);
+ Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
+ assertEquals("12-XP-F4", car.getPlate());
+ List<Wheel> wheels = car.getWheels();
+ assertNotNull(wheels);
+ assertEquals(5, wheels.size());
+ }
+
+ public void testNullDescription() {
+ Constructor constructor = new Constructor();
+ try {
+ constructor.addTypeDescription(null);
+ fail("Description is required.");
+ } catch (Exception e) {
+ assertEquals("TypeDescription is required.", e.getMessage());
+ }
+ }
+
+ public void testLoadClassNoRoot() {
+ Constructor constructor = new Constructor(new TypeDescription(CarWithArray.class));
+ Yaml yaml = new Yaml(constructor);
+ CarWithArray car = (CarWithArray) yaml.load(Util
+ .getLocalResource("constructor/car-no-root-class.yaml"));
+ assertEquals("12-XP-F4", car.getPlate());
+ Wheel[] wheels = car.getWheels();
+ assertNotNull(wheels);
+ assertEquals(5, wheels.length);
+ }
+
+ public static class CarWithArray {
+ private String plate;
+ private Wheel[] wheels;
+
+ public String getPlate() {
+ return plate;
+ }
+
+ public void setPlate(String plate) {
+ this.plate = plate;
+ }
+
+ public Wheel[] getWheels() {
+ return wheels;
+ }
+
+ public void setWheels(Wheel[] wheels) {
+ this.wheels = wheels;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/AtomicJavaBean.java b/src/test/java/org/yaml/snakeyaml/constructor/AtomicJavaBean.java
index 282587a..7c3e6fd 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/AtomicJavaBean.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/AtomicJavaBean.java
@@ -1,45 +1,45 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-public class AtomicJavaBean {
- private float amount;
- private AtomicLong atomic;
-
- public float getAmount() {
- return amount;
- }
-
- public void setAmount(float amount) {
- this.amount = amount;
- }
-
- public AtomicLong getAtomic() {
- return atomic;
- }
-
- public void setAtomic(AtomicLong atomic) {
- this.atomic = atomic;
- }
-
- @Override
- public String toString() {
- return "AtomicJavaBean";
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+public class AtomicJavaBean {
+ private float amount;
+ private AtomicLong atomic;
+
+ public float getAmount() {
+ return amount;
+ }
+
+ public void setAmount(float amount) {
+ this.amount = amount;
+ }
+
+ public AtomicLong getAtomic() {
+ return atomic;
+ }
+
+ public void setAtomic(AtomicLong atomic) {
+ this.atomic = atomic;
+ }
+
+ @Override
+ public String toString() {
+ return "AtomicJavaBean";
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/BeanConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/BeanConstructorTest.java
index 073188e..78ea017 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/BeanConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/BeanConstructorTest.java
@@ -1,251 +1,251 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.math.BigInteger;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.error.YAMLException;
-
-public class BeanConstructorTest extends TestCase {
-
- public void testPrimitivesConstructor() {
- Yaml yaml = new Yaml(new Constructor(TestBean1.class));
- String document = Util.getLocalResource("constructor/test-primitives1.yaml");
- TestBean1 result = (TestBean1) yaml.load(document);
- assertNotNull(result);
- assertEquals(new Byte((byte) 1), result.getByteClass());
- assertEquals((byte) -3, result.getBytePrimitive());
- assertEquals(new Short((short) 0), result.getShortClass());
- assertEquals((short) -13, result.getShortPrimitive());
- assertEquals(new Integer(5), result.getInteger());
- assertEquals(17, result.getIntPrimitive());
- assertEquals("the text", result.getText());
- assertEquals("13", result.getId());
- assertEquals(new Long(11111111111L), result.getLongClass());
- assertEquals(9999999999L, result.getLongPrimitive());
- assertEquals(Boolean.TRUE, result.getBooleanClass());
- assertTrue(result.isBooleanPrimitive());
- assertEquals(new Character('2'), result.getCharClass());
- assertEquals('#', result.getCharPrimitive());
- assertEquals(new BigInteger("1234567890123456789012345678901234567890"),
- result.getBigInteger());
- assertEquals(new Float(2), result.getFloatClass());
- assertEquals(new Float(3.1416), result.getFloatPrimitive());
- assertEquals(new Double(4), result.getDoubleClass());
- assertEquals(new Double(11200), result.getDoublePrimitive());
- assertEquals(1199836800000L, result.getDate().getTime());
- assertEquals("public", result.publicField);
- //
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Yaml yamlToDump = new Yaml(options);
- String output = yamlToDump.dump(result);
- TestBean1 result2 = (TestBean1) yaml.load(output);
- assertNotNull(result2);
- TestBean1 result3 = (TestBean1) new Yaml().load(output);
- assertNotNull(result3);
- }
-
- public void testNoClassConstructor() {
- try {
- new Yaml(new Constructor((Class<? extends Object>) null));
- fail("Class must be provided.");
- } catch (NullPointerException e) {
- assertEquals("Root class must be provided.", e.getMessage());
- }
- }
-
- public void testNoClassConstructorString() throws ClassNotFoundException {
- try {
- new Yaml(new Constructor((String) null));
- fail("Class must be provided.");
- } catch (NullPointerException e) {
- assertEquals("Root type must be provided.", e.getMessage());
- }
- }
-
- public void testNoClassConstructorEmptyString() throws ClassNotFoundException {
- try {
- new Yaml(new Constructor(" "));
- fail("Class must be provided.");
- } catch (YAMLException e) {
- assertEquals("Root type must be provided.", e.getMessage());
- }
- }
-
- public void testCharacter() {
- Yaml yaml = new Yaml(new Constructor(TestBean1.class));
- String document = "charClass: id";
- try {
- yaml.load(document);
- fail("Only one char must be allowed.");
- } catch (Exception e) {
- assertTrue(e.getMessage(),
- e.getMessage().contains("Invalid node Character: 'id'; length: 2"));
- }
- document = "charClass: #";
- TestBean1 bean = (TestBean1) yaml.load(document);
- assertNull("Null must be accepted.", bean.getCharClass());
- document = "charClass: ''";
- bean = (TestBean1) yaml.load(document);
- assertNull("Null must be accepted.", bean.getCharClass());
- document = "charClass:\n";
- bean = (TestBean1) yaml.load(document);
- assertNull("Null must be accepted.", bean.getCharClass());
- document = "charClass: 1\n";
- bean = (TestBean1) yaml.load(document);
- assertEquals(new Character('1'), bean.getCharClass());
- }
-
- public void testNoEmptyConstructor() {
- Yaml yaml = new Yaml(new Constructor(TestBean2.class));
- String document = "text: qwerty";
- try {
- yaml.load(document);
- fail("No empty constructor available");
- } catch (Exception e) {
- assertTrue(e.getMessage(), e.getMessage().contains("NoSuchMethodException"));
- }
- TestBean2 bean = new TestBean2();
- assertEquals("", bean.getText());
- }
-
- private class TestBean2 {
- private String text;
-
- public TestBean2() {
- setText("");
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
- }
-
- public void testPrivateMethod() {
- // TODO: Are we sure no private ????
- Yaml yaml = new Yaml(new Constructor(TestBean2.class));
- String document = "text: qwerty";
- try {
- yaml.load(document);
- fail("Private method cannot be called.");
- } catch (Exception e) {
- assertTrue(e.getMessage(), e.getMessage().contains("NoSuchMethodException"));
- }
- }
-
- public void testKeyNotScalar() {
- Yaml yaml = new Yaml(new Constructor(TestBean1.class));
- String document = "[1, 2]: qwerty";
- try {
- yaml.load(document);
- fail("Keys must be scalars.");
- } catch (Exception e) {
- assertTrue(e.getMessage(), e.getMessage().contains("Keys must be scalars but found"));
- }
- }
-
- public void testInvalidKey() {
- Yaml yaml = new Yaml(new Constructor(TestBean1.class));
- String document = "something: qwerty";
- try {
- yaml.load(document);
- fail("Non-existing property must fail.");
- } catch (Exception e) {
- assertTrue(e.getMessage(),
- e.getMessage().contains("Unable to find property 'something'"));
- }
- }
-
- public void testStaticField() {
- Yaml yaml = new Yaml(new Constructor(TestBean1.class));
- String document = "staticInteger: 123";
- try {
- yaml.load(document);
- fail("Staic variables must not be used.");
- } catch (Exception e) {
- assertTrue(e.getMessage(),
- e.getMessage().contains("Unable to find property 'staticInteger'"));
- }
- }
-
- public void testScalarContructor() {
- Yaml yaml = new Yaml(new Constructor(Parent1.class));
- String document = "id: 123\nchild: 25";
- Parent1 parent = (Parent1) yaml.load(document);
- assertEquals("123", parent.getId());
- Child1 child = parent.getChild();
- assertEquals(new Integer(25), child.getCode());
- }
-
- public void testScalarContructorException() {
- Yaml yaml = new Yaml(new Constructor(ExceptionParent.class));
- String document = "id: 123\nchild: 25";
- try {
- yaml.load(document);
- fail("ExceptionParent should not be created.");
- } catch (Exception e) {
- assertTrue(
- e.getMessage(),
- e.getMessage().contains(
- "Can't construct a java object for scalar tag:yaml.org,2002:int"));
- }
- }
-
- static public class ExceptionParent {
- private String id;
- private ExceptionChild child;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public ExceptionChild getChild() {
- return child;
- }
-
- public void setChild(ExceptionChild child) {
- this.child = child;
- }
-
- }
-
- public static class ExceptionChild {
- private Integer code;
-
- public ExceptionChild(Integer code) {
- throw new RuntimeException("ExceptionChild cannot be created.");
- }
-
- public Integer getCode() {
- return code;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.math.BigInteger;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class BeanConstructorTest extends TestCase {
+
+ public void testPrimitivesConstructor() {
+ Yaml yaml = new Yaml(new Constructor(TestBean1.class));
+ String document = Util.getLocalResource("constructor/test-primitives1.yaml");
+ TestBean1 result = (TestBean1) yaml.load(document);
+ assertNotNull(result);
+ assertEquals(new Byte((byte) 1), result.getByteClass());
+ assertEquals((byte) -3, result.getBytePrimitive());
+ assertEquals(new Short((short) 0), result.getShortClass());
+ assertEquals((short) -13, result.getShortPrimitive());
+ assertEquals(new Integer(5), result.getInteger());
+ assertEquals(17, result.getIntPrimitive());
+ assertEquals("the text", result.getText());
+ assertEquals("13", result.getId());
+ assertEquals(new Long(11111111111L), result.getLongClass());
+ assertEquals(9999999999L, result.getLongPrimitive());
+ assertEquals(Boolean.TRUE, result.getBooleanClass());
+ assertTrue(result.isBooleanPrimitive());
+ assertEquals(new Character('2'), result.getCharClass());
+ assertEquals('#', result.getCharPrimitive());
+ assertEquals(new BigInteger("1234567890123456789012345678901234567890"),
+ result.getBigInteger());
+ assertEquals(new Float(2), result.getFloatClass());
+ assertEquals(new Float(3.1416), result.getFloatPrimitive());
+ assertEquals(new Double(4), result.getDoubleClass());
+ assertEquals(new Double(11200), result.getDoublePrimitive());
+ assertEquals(1199836800000L, result.getDate().getTime());
+ assertEquals("public", result.publicField);
+ //
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ Yaml yamlToDump = new Yaml(options);
+ String output = yamlToDump.dump(result);
+ TestBean1 result2 = (TestBean1) yaml.load(output);
+ assertNotNull(result2);
+ TestBean1 result3 = (TestBean1) new Yaml().load(output);
+ assertNotNull(result3);
+ }
+
+ public void testNoClassConstructor() {
+ try {
+ new Yaml(new Constructor((Class<? extends Object>) null));
+ fail("Class must be provided.");
+ } catch (NullPointerException e) {
+ assertEquals("Root class must be provided.", e.getMessage());
+ }
+ }
+
+ public void testNoClassConstructorString() throws ClassNotFoundException {
+ try {
+ new Yaml(new Constructor((String) null));
+ fail("Class must be provided.");
+ } catch (NullPointerException e) {
+ assertEquals("Root type must be provided.", e.getMessage());
+ }
+ }
+
+ public void testNoClassConstructorEmptyString() throws ClassNotFoundException {
+ try {
+ new Yaml(new Constructor(" "));
+ fail("Class must be provided.");
+ } catch (YAMLException e) {
+ assertEquals("Root type must be provided.", e.getMessage());
+ }
+ }
+
+ public void testCharacter() {
+ Yaml yaml = new Yaml(new Constructor(TestBean1.class));
+ String document = "charClass: id";
+ try {
+ yaml.load(document);
+ fail("Only one char must be allowed.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Invalid node Character: 'id'; length: 2"));
+ }
+ document = "charClass: #";
+ TestBean1 bean = (TestBean1) yaml.load(document);
+ assertNull("Null must be accepted.", bean.getCharClass());
+ document = "charClass: ''";
+ bean = (TestBean1) yaml.load(document);
+ assertNull("Null must be accepted.", bean.getCharClass());
+ document = "charClass:\n";
+ bean = (TestBean1) yaml.load(document);
+ assertNull("Null must be accepted.", bean.getCharClass());
+ document = "charClass: 1\n";
+ bean = (TestBean1) yaml.load(document);
+ assertEquals(new Character('1'), bean.getCharClass());
+ }
+
+ public void testNoEmptyConstructor() {
+ Yaml yaml = new Yaml(new Constructor(TestBean2.class));
+ String document = "text: qwerty";
+ try {
+ yaml.load(document);
+ fail("No empty constructor available");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("NoSuchMethodException"));
+ }
+ TestBean2 bean = new TestBean2();
+ assertEquals("", bean.getText());
+ }
+
+ private class TestBean2 {
+ private String text;
+
+ public TestBean2() {
+ setText("");
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+ }
+
+ public void testPrivateMethod() {
+ // TODO: Are we sure no private ????
+ Yaml yaml = new Yaml(new Constructor(TestBean2.class));
+ String document = "text: qwerty";
+ try {
+ yaml.load(document);
+ fail("Private method cannot be called.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("NoSuchMethodException"));
+ }
+ }
+
+ public void testKeyNotScalar() {
+ Yaml yaml = new Yaml(new Constructor(TestBean1.class));
+ String document = "[1, 2]: qwerty";
+ try {
+ yaml.load(document);
+ fail("Keys must be scalars.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("Keys must be scalars but found"));
+ }
+ }
+
+ public void testInvalidKey() {
+ Yaml yaml = new Yaml(new Constructor(TestBean1.class));
+ String document = "something: qwerty";
+ try {
+ yaml.load(document);
+ fail("Non-existing property must fail.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Unable to find property 'something'"));
+ }
+ }
+
+ public void testStaticField() {
+ Yaml yaml = new Yaml(new Constructor(TestBean1.class));
+ String document = "staticInteger: 123";
+ try {
+ yaml.load(document);
+ fail("Staic variables must not be used.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage(),
+ e.getMessage().contains("Unable to find property 'staticInteger'"));
+ }
+ }
+
+ public void testScalarContructor() {
+ Yaml yaml = new Yaml(new Constructor(Parent1.class));
+ String document = "id: 123\nchild: 25";
+ Parent1 parent = (Parent1) yaml.load(document);
+ assertEquals("123", parent.getId());
+ Child1 child = parent.getChild();
+ assertEquals(new Integer(25), child.getCode());
+ }
+
+ public void testScalarContructorException() {
+ Yaml yaml = new Yaml(new Constructor(ExceptionParent.class));
+ String document = "id: 123\nchild: 25";
+ try {
+ yaml.load(document);
+ fail("ExceptionParent should not be created.");
+ } catch (Exception e) {
+ assertTrue(
+ e.getMessage(),
+ e.getMessage().contains(
+ "Can't construct a java object for scalar tag:yaml.org,2002:int"));
+ }
+ }
+
+ static public class ExceptionParent {
+ private String id;
+ private ExceptionChild child;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public ExceptionChild getChild() {
+ return child;
+ }
+
+ public void setChild(ExceptionChild child) {
+ this.child = child;
+ }
+
+ }
+
+ public static class ExceptionChild {
+ private Integer code;
+
+ public ExceptionChild(Integer code) {
+ throw new RuntimeException("ExceptionChild cannot be created.");
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalBeanConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalBeanConstructorTest.java
index c08da16..c27130a 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalBeanConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalBeanConstructorTest.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.math.BigDecimal;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class BigDecimalBeanConstructorTest extends TestCase {
-
- public void testRepresentor() {
- BigDecimalJavaBean bean = new BigDecimalJavaBean();
- bean.setAmount(1.5f);
- bean.setNumber(new BigDecimal("3.1416"));
- Yaml yaml = new Yaml();
- String output = yaml.dump(bean);
- String className = this.getClass().getPackage().getName();
- assertEquals("!!" + className + ".BigDecimalJavaBean {amount: 1.5, number: 3.1416}\n",
- output);
- }
-
- public void testConstructor() {
- String className = "!!" + this.getClass().getPackage().getName()
- + ".BigDecimalJavaBean {amount: 1.5, number: 3.1416}";
- Yaml yaml = new Yaml();
- BigDecimalJavaBean bean = (BigDecimalJavaBean) yaml.load(className);
- assertNotNull(bean);
- assertTrue(1.5 - bean.getAmount() < 0.0000001);
- assertTrue((new BigDecimal("3.1416")).add(bean.getNumber().negate()).doubleValue() < 0.0000001);
- }
-
- public void testConstructorAtomic() {
- String className = "!!" + this.getClass().getPackage().getName()
- + ".AtomicJavaBean {amount: 1.5, atomic: 0}";
- Yaml yaml = new Yaml();
- try {
- yaml.load(className);
- fail("AtomicLong is not supported.");
- } catch (Exception e) {
- assertEquals(
- "Cannot create property=atomic for JavaBean=AtomicJavaBean; Unsupported class: class java.util.concurrent.atomic.AtomicLong",
- e.getCause().getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.math.BigDecimal;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class BigDecimalBeanConstructorTest extends TestCase {
+
+ public void testRepresentor() {
+ BigDecimalJavaBean bean = new BigDecimalJavaBean();
+ bean.setAmount(1.5f);
+ bean.setNumber(new BigDecimal("3.1416"));
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(bean);
+ String className = this.getClass().getPackage().getName();
+ assertEquals("!!" + className + ".BigDecimalJavaBean {amount: 1.5, number: 3.1416}\n",
+ output);
+ }
+
+ public void testConstructor() {
+ String className = "!!" + this.getClass().getPackage().getName()
+ + ".BigDecimalJavaBean {amount: 1.5, number: 3.1416}";
+ Yaml yaml = new Yaml();
+ BigDecimalJavaBean bean = (BigDecimalJavaBean) yaml.load(className);
+ assertNotNull(bean);
+ assertTrue(1.5 - bean.getAmount() < 0.0000001);
+ assertTrue((new BigDecimal("3.1416")).add(bean.getNumber().negate()).doubleValue() < 0.0000001);
+ }
+
+ public void testConstructorAtomic() {
+ String className = "!!" + this.getClass().getPackage().getName()
+ + ".AtomicJavaBean {amount: 1.5, atomic: 0}";
+ Yaml yaml = new Yaml();
+ try {
+ yaml.load(className);
+ fail("AtomicLong is not supported.");
+ } catch (Exception e) {
+ assertEquals(
+ "Cannot create property=atomic for JavaBean=AtomicJavaBean; Unsupported class: class java.util.concurrent.atomic.AtomicLong",
+ e.getCause().getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalJavaBean.java b/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalJavaBean.java
index 9ee39cf..981a0e9 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalJavaBean.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/BigDecimalJavaBean.java
@@ -1,40 +1,40 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.math.BigDecimal;
-
-public class BigDecimalJavaBean {
- private BigDecimal number;
- private float amount;
-
- public BigDecimal getNumber() {
- return number;
- }
-
- public void setNumber(BigDecimal number) {
- this.number = number;
- }
-
- public float getAmount() {
- return amount;
- }
-
- public void setAmount(float amount) {
- this.amount = amount;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.math.BigDecimal;
+
+public class BigDecimalJavaBean {
+ private BigDecimal number;
+ private float amount;
+
+ public BigDecimal getNumber() {
+ return number;
+ }
+
+ public void setNumber(BigDecimal number) {
+ this.number = number;
+ }
+
+ public float getAmount() {
+ return amount;
+ }
+
+ public void setAmount(float amount) {
+ this.amount = amount;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/Car.java b/src/test/java/org/yaml/snakeyaml/constructor/Car.java
index 570c53f..2f944e5 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/Car.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/Car.java
@@ -1,40 +1,40 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.List;
-
-public class Car {
- private String plate;
- private List<Wheel> wheels;
-
- public String getPlate() {
- return plate;
- }
-
- public void setPlate(String plate) {
- this.plate = plate;
- }
-
- public List<Wheel> getWheels() {
- return wheels;
- }
-
- public void setWheels(List<Wheel> wheels) {
- this.wheels = wheels;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.List;
+
+public class Car {
+ private String plate;
+ private List<Wheel> wheels;
+
+ public String getPlate() {
+ return plate;
+ }
+
+ public void setPlate(String plate) {
+ this.plate = plate;
+ }
+
+ public List<Wheel> getWheels() {
+ return wheels;
+ }
+
+ public void setWheels(List<Wheel> wheels) {
+ this.wheels = wheels;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/Child1.java b/src/test/java/org/yaml/snakeyaml/constructor/Child1.java
index 6a5e096..a5f4bcd 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/Child1.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/Child1.java
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-public class Child1 {
- private Integer code;
-
- public Child1(Integer code) {
- this.code = code;
- }
-
- public Integer getCode() {
- return code;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+public class Child1 {
+ private Integer code;
+
+ public Child1(Integer code) {
+ this.code = code;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java
index 43e15b5..e779158 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ClassTagsTest.java
@@ -1,106 +1,106 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class ClassTagsTest extends TestCase {
-
- public void testDefaultRepresenter() {
- Car car = new Car();
- car.setPlate("12-XP-F4");
- List<Wheel> wheels = new ArrayList<Wheel>();
- for (int i = 1; i < 6; i++) {
- Wheel wheel = new Wheel();
- wheel.setId(i);
- wheels.add(wheel);
- }
- car.setWheels(wheels);
- assertEquals(Util.getLocalResource("constructor/car-with-tags.yaml"), new Yaml().dump(car));
- }
-
- public void testDumpClassTag() {
- Car car = new Car();
- car.setPlate("12-XP-F4");
- List<Wheel> wheels = new ArrayList<Wheel>();
- for (int i = 1; i < 6; i++) {
- Wheel wheel = new Wheel();
- wheel.setId(i);
- wheels.add(wheel);
- }
- car.setWheels(wheels);
- Representer representer = new Representer();
- representer.addClassTag(Car.class, new Tag("!car"));
- representer.addClassTag(Wheel.class, Tag.MAP);
- Yaml yaml = new Yaml(representer);
- String output = yaml.dump(car);
- assertEquals(Util.getLocalResource("constructor/car-without-tags.yaml"), output);
- }
-
- public void testLoadUnknounClassTag() {
- try {
- Yaml yaml = new Yaml();
- yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
- fail("Must fail because of unknown tag: !car");
- } catch (YAMLException e) {
- assertTrue(e.getMessage().contains("Invalid tag: !car"));
- }
-
- }
-
- public void testLoadClassTag() {
- Constructor constructor = new Constructor();
- constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
- Yaml yaml = new Yaml(constructor);
- String source = Util.getLocalResource("constructor/car-without-tags.yaml");
- Car car = (Car) yaml.load(source);
- assertEquals("12-XP-F4", car.getPlate());
- List<Wheel> wheels = car.getWheels();
- assertNotNull(wheels);
- assertEquals(5, wheels.size());
- }
-
- public void testNullDescription() {
- Constructor constructor = new Constructor();
- try {
- constructor.addTypeDescription(null);
- fail("Description is required.");
- } catch (Exception e) {
- assertEquals("TypeDescription is required.", e.getMessage());
- }
- }
-
- public void testLoadClassNoRoot() {
- Constructor constructor = new Constructor(new TypeDescription(Car.class));
- Yaml yaml = new Yaml(constructor);
- Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
- assertEquals("12-XP-F4", car.getPlate());
- List<Wheel> wheels = car.getWheels();
- assertNotNull(wheels);
- assertEquals(5, wheels.size());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class ClassTagsTest extends TestCase {
+
+ public void testDefaultRepresenter() {
+ Car car = new Car();
+ car.setPlate("12-XP-F4");
+ List<Wheel> wheels = new ArrayList<Wheel>();
+ for (int i = 1; i < 6; i++) {
+ Wheel wheel = new Wheel();
+ wheel.setId(i);
+ wheels.add(wheel);
+ }
+ car.setWheels(wheels);
+ assertEquals(Util.getLocalResource("constructor/car-with-tags.yaml"), new Yaml().dump(car));
+ }
+
+ public void testDumpClassTag() {
+ Car car = new Car();
+ car.setPlate("12-XP-F4");
+ List<Wheel> wheels = new ArrayList<Wheel>();
+ for (int i = 1; i < 6; i++) {
+ Wheel wheel = new Wheel();
+ wheel.setId(i);
+ wheels.add(wheel);
+ }
+ car.setWheels(wheels);
+ Representer representer = new Representer();
+ representer.addClassTag(Car.class, new Tag("!car"));
+ representer.addClassTag(Wheel.class, Tag.MAP);
+ Yaml yaml = new Yaml(representer);
+ String output = yaml.dump(car);
+ assertEquals(Util.getLocalResource("constructor/car-without-tags.yaml"), output);
+ }
+
+ public void testLoadUnknounClassTag() {
+ try {
+ Yaml yaml = new Yaml();
+ yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
+ fail("Must fail because of unknown tag: !car");
+ } catch (YAMLException e) {
+ assertTrue(e.getMessage().contains("Invalid tag: !car"));
+ }
+
+ }
+
+ public void testLoadClassTag() {
+ Constructor constructor = new Constructor();
+ constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
+ Yaml yaml = new Yaml(constructor);
+ String source = Util.getLocalResource("constructor/car-without-tags.yaml");
+ Car car = (Car) yaml.load(source);
+ assertEquals("12-XP-F4", car.getPlate());
+ List<Wheel> wheels = car.getWheels();
+ assertNotNull(wheels);
+ assertEquals(5, wheels.size());
+ }
+
+ public void testNullDescription() {
+ Constructor constructor = new Constructor();
+ try {
+ constructor.addTypeDescription(null);
+ fail("Description is required.");
+ } catch (Exception e) {
+ assertEquals("TypeDescription is required.", e.getMessage());
+ }
+ }
+
+ public void testLoadClassNoRoot() {
+ Constructor constructor = new Constructor(new TypeDescription(Car.class));
+ Yaml yaml = new Yaml(constructor);
+ Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
+ assertEquals("12-XP-F4", car.getPlate());
+ List<Wheel> wheels = car.getWheels();
+ assertNotNull(wheels);
+ assertEquals(5, wheels.size());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorMappingTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorMappingTest.java
index 55ab552..0f048c9 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorMappingTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorMappingTest.java
@@ -1,68 +1,68 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.composer.Composer;
-import org.yaml.snakeyaml.parser.Parser;
-import org.yaml.snakeyaml.parser.ParserImpl;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-public class ConstructorMappingTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testGetDefaultMap() {
- String data = "{ one: 1, two: 2, three: 3 }";
- Map<Object, Object> map = (Map<Object, Object>) construct(new CustomConstructor(), data);
- assertNotNull(map);
- assertTrue(map.getClass().toString(), map instanceof TreeMap);
- }
-
- @SuppressWarnings("unchecked")
- public void testGetArrayList() {
- String data = "{ one: 1, two: 2, three: 3 }";
- Map<Object, Object> map = (Map<Object, Object>) construct(data);
- assertNotNull(map);
- assertTrue(map.getClass().toString(), map instanceof LinkedHashMap);
- }
-
- private Object construct(String data) {
- return construct(new Constructor(), data);
- }
-
- private Object construct(Constructor constructor, String data) {
- StreamReader reader = new StreamReader(data);
- Parser parser = new ParserImpl(reader);
- Resolver resolver = new Resolver();
- Composer composer = new Composer(parser, resolver);
- constructor.setComposer(composer);
- return constructor.getSingleData(Object.class);
- }
-
- class CustomConstructor extends Constructor {
- @Override
- protected Map<Object, Object> createDefaultMap() {
- return new TreeMap<Object, Object>();
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.composer.Composer;
+import org.yaml.snakeyaml.parser.Parser;
+import org.yaml.snakeyaml.parser.ParserImpl;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+public class ConstructorMappingTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testGetDefaultMap() {
+ String data = "{ one: 1, two: 2, three: 3 }";
+ Map<Object, Object> map = (Map<Object, Object>) construct(new CustomConstructor(), data);
+ assertNotNull(map);
+ assertTrue(map.getClass().toString(), map instanceof TreeMap);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testGetArrayList() {
+ String data = "{ one: 1, two: 2, three: 3 }";
+ Map<Object, Object> map = (Map<Object, Object>) construct(data);
+ assertNotNull(map);
+ assertTrue(map.getClass().toString(), map instanceof LinkedHashMap);
+ }
+
+ private Object construct(String data) {
+ return construct(new Constructor(), data);
+ }
+
+ private Object construct(Constructor constructor, String data) {
+ StreamReader reader = new StreamReader(data);
+ Parser parser = new ParserImpl(reader);
+ Resolver resolver = new Resolver();
+ Composer composer = new Composer(parser, resolver);
+ constructor.setComposer(composer);
+ return constructor.getSingleData(Object.class);
+ }
+
+ class CustomConstructor extends Constructor {
+ @Override
+ protected Map<Object, Object> createDefaultMap() {
+ return new TreeMap<Object, Object>();
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java
index 0c89598..a17725e 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorSequenceTest.java
@@ -1,86 +1,86 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.composer.Composer;
-import org.yaml.snakeyaml.parser.Parser;
-import org.yaml.snakeyaml.parser.ParserImpl;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-public class ConstructorSequenceTest extends TestCase {
-
- public void testGetList() {
- String data = "[ 1, 2, 3 ]";
- List<Object> list = construct(new CustomConstructor(), data);
- assertNotNull(list);
- assertTrue(list.getClass().toString(), list instanceof ArrayList<?>);
- }
-
- public void testGetArrayList() {
- String data = "[ 1, 2, 3 ]";
- List<Object> list = construct(data);
- assertNotNull(list);
- assertTrue(list.getClass().toString(), list instanceof ArrayList<?>);
- }
-
- public void testDumpList() {
- List<Integer> l = new ArrayList<Integer>(2);
- l.add(1);
- l.add(2);
- Yaml yaml = new Yaml();
- String result = yaml.dump(l);
- assertEquals("[1, 2]\n", result);
- }
-
- public void testDumpListSameIntegers() {
- List<Integer> l = new ArrayList<Integer>(2);
- l.add(1);
- l.add(1);
- Yaml yaml = new Yaml();
- String result = yaml.dump(l);
- assertEquals("[1, 1]\n", result);
- }
-
- private List<Object> construct(String data) {
- return construct(new Constructor(), data);
- }
-
- @SuppressWarnings("unchecked")
- private List<Object> construct(Constructor constructor, String data) {
- StreamReader reader = new StreamReader(data);
- Parser parser = new ParserImpl(reader);
- Resolver resolver = new Resolver();
- Composer composer = new Composer(parser, resolver);
- constructor.setComposer(composer);
- List<Object> result = (List<Object>) constructor.getSingleData(Object.class);
- return result;
- }
-
- class CustomConstructor extends Constructor {
- @Override
- protected List<Object> createDefaultList(int initSize) {
- return new ArrayList<Object>(initSize);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.composer.Composer;
+import org.yaml.snakeyaml.parser.Parser;
+import org.yaml.snakeyaml.parser.ParserImpl;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+public class ConstructorSequenceTest extends TestCase {
+
+ public void testGetList() {
+ String data = "[ 1, 2, 3 ]";
+ List<Object> list = construct(new CustomConstructor(), data);
+ assertNotNull(list);
+ assertTrue(list.getClass().toString(), list instanceof ArrayList<?>);
+ }
+
+ public void testGetArrayList() {
+ String data = "[ 1, 2, 3 ]";
+ List<Object> list = construct(data);
+ assertNotNull(list);
+ assertTrue(list.getClass().toString(), list instanceof ArrayList<?>);
+ }
+
+ public void testDumpList() {
+ List<Integer> l = new ArrayList<Integer>(2);
+ l.add(1);
+ l.add(2);
+ Yaml yaml = new Yaml();
+ String result = yaml.dump(l);
+ assertEquals("[1, 2]\n", result);
+ }
+
+ public void testDumpListSameIntegers() {
+ List<Integer> l = new ArrayList<Integer>(2);
+ l.add(1);
+ l.add(1);
+ Yaml yaml = new Yaml();
+ String result = yaml.dump(l);
+ assertEquals("[1, 1]\n", result);
+ }
+
+ private List<Object> construct(String data) {
+ return construct(new Constructor(), data);
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<Object> construct(Constructor constructor, String data) {
+ StreamReader reader = new StreamReader(data);
+ Parser parser = new ParserImpl(reader);
+ Resolver resolver = new Resolver();
+ Composer composer = new Composer(parser, resolver);
+ constructor.setComposer(composer);
+ List<Object> result = (List<Object>) constructor.getSingleData(Object.class);
+ return result;
+ }
+
+ class CustomConstructor extends Constructor {
+ @Override
+ protected List<Object> createDefaultList(int initSize) {
+ return new ArrayList<Object>(initSize);
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorTest.java
index 607a3e9..93181c6 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ConstructorTest.java
@@ -1,113 +1,113 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class ConstructorTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testMapOrder() {
- String data = "one: zzz\ntwo: ccc\nthree: bbb\nfour: aaa";
- Object map = construct(data);
- assertNotNull(map);
- assertTrue(map.getClass().toString(), map instanceof LinkedHashMap);
- Map<String, String> m = (Map<String, String>) map;
- assertEquals(4, m.keySet().size());
- Iterator<String> iter = m.keySet().iterator();
- assertEquals("one", iter.next());
- assertEquals("two", iter.next());
- assertEquals("three", iter.next());
- assertEquals("four", iter.next());
- }
-
- /**
- * create JavaBean
- */
- public void testGetBeanAssumeClass() {
- String data = "--- !!org.yaml.snakeyaml.constructor.Person\nfirstName: Andrey\nage: 99";
- Object obj = construct(data);
- assertNotNull(obj);
- assertTrue("Unexpected: " + obj.getClass().toString(), obj instanceof Person);
- Person person = (Person) obj;
- assertEquals("Andrey", person.getFirstName());
- assertNull(person.getLastName());
- assertEquals(99, person.getAge().intValue());
- }
-
- /**
- * create instance using constructor arguments
- */
- public void testGetConstructorBean() {
- String data = "--- !!org.yaml.snakeyaml.constructor.Person [ Andrey, Somov, 99 ]";
- Object obj = construct(data);
- assertNotNull(obj);
- assertTrue(obj.getClass().toString(), obj instanceof Person);
- Person person = (Person) obj;
- assertEquals("Andrey", person.getFirstName());
- assertEquals("Somov", person.getLastName());
- assertEquals(99, person.getAge().intValue());
- }
-
- /**
- * create instance using scalar argument
- */
- public void testGetConstructorFromScalar() {
- String data = "--- !!org.yaml.snakeyaml.constructor.Person 'Somov'";
- Object obj = construct(data);
- assertNotNull(obj);
- assertTrue(obj.getClass().toString(), obj instanceof Person);
- Person person = (Person) obj;
- assertNull("Andrey", person.getFirstName());
- assertEquals("Somov", person.getLastName());
- assertNull(person.getAge());
- }
-
- public void testJavaBeanLoad() {
- java.util.Calendar cal = java.util.Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.clear();
- cal.set(1982, 5 - 1, 3); // Java's months are zero-based...
-
- TestBean expected = new TestBean("Ola Bini", 24, cal.getTime());
- assertEquals(
- expected,
- construct("--- !!org.yaml.snakeyaml.constructor.TestBean\nname: Ola Bini\nage: 24\nborn: 1982-05-03\n"));
- }
-
- public void testWrongName() {
- try {
- construct("--- !!org.yaml.snakeyaml.constructor.TestBean\nwrongName: No one\nage: 24\nborn: 1982-05-03\n");
- fail("IntrospectionException expected.");
- } catch (Exception e) {
- assertEquals(
- "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.constructor.TestBean; exception=Cannot create property=wrongName for JavaBean=#<org.jvyaml.TestBean name=\"null\" age=0 born=\"null\">; Unable to find property 'wrongName' on class: org.yaml.snakeyaml.constructor.TestBean",
- e.getMessage());
- }
- }
-
- private Object construct(String data) {
- Yaml yaml = new Yaml();
- return yaml.load(data);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class ConstructorTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testMapOrder() {
+ String data = "one: zzz\ntwo: ccc\nthree: bbb\nfour: aaa";
+ Object map = construct(data);
+ assertNotNull(map);
+ assertTrue(map.getClass().toString(), map instanceof LinkedHashMap);
+ Map<String, String> m = (Map<String, String>) map;
+ assertEquals(4, m.keySet().size());
+ Iterator<String> iter = m.keySet().iterator();
+ assertEquals("one", iter.next());
+ assertEquals("two", iter.next());
+ assertEquals("three", iter.next());
+ assertEquals("four", iter.next());
+ }
+
+ /**
+ * create JavaBean
+ */
+ public void testGetBeanAssumeClass() {
+ String data = "--- !!org.yaml.snakeyaml.constructor.Person\nfirstName: Andrey\nage: 99";
+ Object obj = construct(data);
+ assertNotNull(obj);
+ assertTrue("Unexpected: " + obj.getClass().toString(), obj instanceof Person);
+ Person person = (Person) obj;
+ assertEquals("Andrey", person.getFirstName());
+ assertNull(person.getLastName());
+ assertEquals(99, person.getAge().intValue());
+ }
+
+ /**
+ * create instance using constructor arguments
+ */
+ public void testGetConstructorBean() {
+ String data = "--- !!org.yaml.snakeyaml.constructor.Person [ Andrey, Somov, 99 ]";
+ Object obj = construct(data);
+ assertNotNull(obj);
+ assertTrue(obj.getClass().toString(), obj instanceof Person);
+ Person person = (Person) obj;
+ assertEquals("Andrey", person.getFirstName());
+ assertEquals("Somov", person.getLastName());
+ assertEquals(99, person.getAge().intValue());
+ }
+
+ /**
+ * create instance using scalar argument
+ */
+ public void testGetConstructorFromScalar() {
+ String data = "--- !!org.yaml.snakeyaml.constructor.Person 'Somov'";
+ Object obj = construct(data);
+ assertNotNull(obj);
+ assertTrue(obj.getClass().toString(), obj instanceof Person);
+ Person person = (Person) obj;
+ assertNull("Andrey", person.getFirstName());
+ assertEquals("Somov", person.getLastName());
+ assertNull(person.getAge());
+ }
+
+ public void testJavaBeanLoad() {
+ java.util.Calendar cal = java.util.Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ cal.clear();
+ cal.set(1982, 5 - 1, 3); // Java's months are zero-based...
+
+ TestBean expected = new TestBean("Ola Bini", 24, cal.getTime());
+ assertEquals(
+ expected,
+ construct("--- !!org.yaml.snakeyaml.constructor.TestBean\nname: Ola Bini\nage: 24\nborn: 1982-05-03\n"));
+ }
+
+ public void testWrongName() {
+ try {
+ construct("--- !!org.yaml.snakeyaml.constructor.TestBean\nwrongName: No one\nage: 24\nborn: 1982-05-03\n");
+ fail("IntrospectionException expected.");
+ } catch (Exception e) {
+ assertEquals(
+ "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.constructor.TestBean; exception=Cannot create property=wrongName for JavaBean=#<org.jvyaml.TestBean name=\"null\" age=0 born=\"null\">; Unable to find property 'wrongName' on class: org.yaml.snakeyaml.constructor.TestBean",
+ e.getMessage());
+ }
+ }
+
+ private Object construct(String data) {
+ Yaml yaml = new Yaml();
+ return yaml.load(data);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/CustomClassLoaderConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/CustomClassLoaderConstructorTest.java
index 65b54a1..4ea5c62 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/CustomClassLoaderConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/CustomClassLoaderConstructorTest.java
@@ -1,84 +1,84 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class CustomClassLoaderConstructorTest extends TestCase {
-
- public void testGetClassForNameNull() {
- try {
- new CustomClassLoaderConstructor(null);
- fail();
- } catch (Exception e) {
- assertEquals("Loader must be provided.", e.getMessage());
- }
- }
-
- public void testGetClassForName() {
- CustomClassLoaderConstructor constr = new CustomClassLoaderConstructor(
- CustomClassLoaderConstructorTest.class.getClassLoader());
- Yaml yaml = new Yaml(constr);
- String s = (String) yaml.load("abc");
- assertEquals("abc", s);
- }
-
- public void testGetClassForNameWithRoot() throws ClassNotFoundException {
- Class<?> clazz = Class.forName(
- "org.yaml.snakeyaml.constructor.CustomClassLoaderConstructorTest$LoaderBean", true,
- CustomClassLoaderConstructorTest.class.getClassLoader());
- CustomClassLoaderConstructor constr = new CustomClassLoaderConstructor(clazz,
- CustomClassLoaderConstructorTest.class.getClassLoader());
- Yaml yaml = new Yaml(constr);
- LoaderBean bean = (LoaderBean) yaml.load("{name: Andrey, number: 555}");
- assertEquals("Andrey", bean.getName());
- assertEquals(555, bean.getNumber());
- }
-
- public void testGetClassForNameBean() {
- CustomClassLoaderConstructor constr = new CustomClassLoaderConstructor(
- CustomClassLoaderConstructorTest.class.getClassLoader());
- Yaml yaml = new Yaml(constr);
- LoaderBean bean = (LoaderBean) yaml
- .load("!!org.yaml.snakeyaml.constructor.CustomClassLoaderConstructorTest$LoaderBean {name: Andrey, number: 555}");
- assertEquals("Andrey", bean.getName());
- assertEquals(555, bean.getNumber());
- }
-
- public static class LoaderBean {
- private String name;
- private int number;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class CustomClassLoaderConstructorTest extends TestCase {
+
+ public void testGetClassForNameNull() {
+ try {
+ new CustomClassLoaderConstructor(null);
+ fail();
+ } catch (Exception e) {
+ assertEquals("Loader must be provided.", e.getMessage());
+ }
+ }
+
+ public void testGetClassForName() {
+ CustomClassLoaderConstructor constr = new CustomClassLoaderConstructor(
+ CustomClassLoaderConstructorTest.class.getClassLoader());
+ Yaml yaml = new Yaml(constr);
+ String s = (String) yaml.load("abc");
+ assertEquals("abc", s);
+ }
+
+ public void testGetClassForNameWithRoot() throws ClassNotFoundException {
+ Class<?> clazz = Class.forName(
+ "org.yaml.snakeyaml.constructor.CustomClassLoaderConstructorTest$LoaderBean", true,
+ CustomClassLoaderConstructorTest.class.getClassLoader());
+ CustomClassLoaderConstructor constr = new CustomClassLoaderConstructor(clazz,
+ CustomClassLoaderConstructorTest.class.getClassLoader());
+ Yaml yaml = new Yaml(constr);
+ LoaderBean bean = (LoaderBean) yaml.load("{name: Andrey, number: 555}");
+ assertEquals("Andrey", bean.getName());
+ assertEquals(555, bean.getNumber());
+ }
+
+ public void testGetClassForNameBean() {
+ CustomClassLoaderConstructor constr = new CustomClassLoaderConstructor(
+ CustomClassLoaderConstructorTest.class.getClassLoader());
+ Yaml yaml = new Yaml(constr);
+ LoaderBean bean = (LoaderBean) yaml
+ .load("!!org.yaml.snakeyaml.constructor.CustomClassLoaderConstructorTest$LoaderBean {name: Andrey, number: 555}");
+ assertEquals("Andrey", bean.getName());
+ assertEquals(555, bean.getNumber());
+ }
+
+ public static class LoaderBean {
+ private String name;
+ private int number;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/FilterClassesConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/FilterClassesConstructorTest.java
index b005f65..bf1c868 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/FilterClassesConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/FilterClassesConstructorTest.java
@@ -1,75 +1,75 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class FilterClassesConstructorTest extends TestCase {
-
- public void testGetClassForName() {
- Yaml yaml = new Yaml(new FilterConstructor(true));
- String input = "!!org.yaml.snakeyaml.constructor.FilterClassesConstructorTest$FilteredBean {name: Andrey, number: 543}";
- try {
- yaml.load(input);
- fail("Filter is expected.");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("Filter is applied."));
- }
- yaml = new Yaml(new FilterConstructor(false));
- FilteredBean s = (FilteredBean) yaml.load(input);
- assertEquals("Andrey", s.getName());
- }
-
- class FilterConstructor extends Constructor {
- private boolean filter;
-
- public FilterConstructor(boolean f) {
- filter = f;
- }
-
- @Override
- protected Class<?> getClassForName(String name) throws ClassNotFoundException {
- if (filter && name.startsWith("org.yaml")) {
- throw new RuntimeException("Filter is applied.");
- }
- return super.getClassForName(name);
- }
- }
-
- public static class FilteredBean {
- private String name;
- private int number;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class FilterClassesConstructorTest extends TestCase {
+
+ public void testGetClassForName() {
+ Yaml yaml = new Yaml(new FilterConstructor(true));
+ String input = "!!org.yaml.snakeyaml.constructor.FilterClassesConstructorTest$FilteredBean {name: Andrey, number: 543}";
+ try {
+ yaml.load(input);
+ fail("Filter is expected.");
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("Filter is applied."));
+ }
+ yaml = new Yaml(new FilterConstructor(false));
+ FilteredBean s = (FilteredBean) yaml.load(input);
+ assertEquals("Andrey", s.getName());
+ }
+
+ class FilterConstructor extends Constructor {
+ private boolean filter;
+
+ public FilterConstructor(boolean f) {
+ filter = f;
+ }
+
+ @Override
+ protected Class<?> getClassForName(String name) throws ClassNotFoundException {
+ if (filter && name.startsWith("org.yaml")) {
+ throw new RuntimeException("Filter is applied.");
+ }
+ return super.getClassForName(name);
+ }
+ }
+
+ public static class FilteredBean {
+ private String name;
+ private int number;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java b/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java
index aa060b8..a8b1bff 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/ImplicitTagsTest.java
@@ -1,157 +1,157 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class ImplicitTagsTest extends TestCase {
-
- public void testDefaultRepresenter() {
- CarWithWheel car1 = new CarWithWheel();
- car1.setPlate("12-XP-F4");
- Wheel wheel = new Wheel();
- wheel.setId(2);
- car1.setWheel(wheel);
- Map<String, Integer> map = new HashMap<String, Integer>();
- map.put("id", 3);
- car1.setMap(map);
- car1.setPart(new Wheel(4));
- car1.setYear("2008");
- String carYaml1 = new Yaml().dump(car1);
- assertEquals(Util.getLocalResource("constructor/carwheel-without-tags.yaml"), carYaml1);
- CarWithWheel car2 = (CarWithWheel) new Yaml().load(carYaml1);
- String carYaml2 = new Yaml().dump(car2);
- assertEquals(carYaml1, carYaml2);
- }
-
- public void testNoRootTag() {
- CarWithWheel car1 = new CarWithWheel();
- car1.setPlate("12-XP-F4");
- Wheel wheel = new Wheel();
- wheel.setId(2);
- car1.setWheel(wheel);
- Map<String, Integer> map = new HashMap<String, Integer>();
- map.put("id", 3);
- car1.setMap(map);
- car1.setYear("2008");
- String carYaml1 = new Yaml().dumpAs(car1, Tag.MAP, FlowStyle.AUTO);
- assertEquals(Util.getLocalResource("constructor/car-without-root-tag.yaml"), carYaml1);
- //
- Constructor contructor = new Constructor(CarWithWheel.class);
- CarWithWheel car2 = (CarWithWheel) new Yaml(contructor).load(carYaml1);
- String carYaml2 = new Yaml().dumpAs(car2, Tag.MAP, FlowStyle.AUTO);
- assertEquals(carYaml1, carYaml2);
- }
-
- @SuppressWarnings("unchecked")
- public void testRootMap() {
- Map<Object, Object> car1 = new HashMap<Object, Object>();
- car1.put("plate", "12-XP-F4");
- Wheel wheel = new Wheel();
- wheel.setId(2);
- car1.put("wheel", wheel);
- Map<String, Integer> map = new HashMap<String, Integer>();
- map.put("id", 3);
- car1.put("map", map);
- String carYaml1 = new Yaml().dump(car1);
- assertEquals(Util.getLocalResource("constructor/carwheel-root-map.yaml"), carYaml1);
- Map<Object, Object> car2 = (Map<Object, Object>) new Yaml().load(carYaml1);
- assertEquals(car1, car2);
- assertEquals(carYaml1, new Yaml().dump(car2));
- }
-
- public void testLoadClassTag() {
- Constructor constructor = new Constructor();
- constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
- Yaml yaml = new Yaml(constructor);
- Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
- assertEquals("12-XP-F4", car.getPlate());
- List<Wheel> wheels = car.getWheels();
- assertNotNull(wheels);
- assertEquals(5, wheels.size());
- Wheel w1 = wheels.get(0);
- assertEquals(1, w1.getId());
- //
- String carYaml1 = new Yaml().dump(car);
- assertTrue(carYaml1.startsWith("!!org.yaml.snakeyaml.constructor.Car"));
- //
- Representer representer = new Representer();
- representer.addClassTag(Car.class, new Tag("!car"));
- yaml = new Yaml(representer);
- String carYaml2 = yaml.dump(car);
- assertEquals(Util.getLocalResource("constructor/car-without-tags.yaml"), carYaml2);
- }
-
- public static class CarWithWheel {
- private String plate;
- private String year;
- private Wheel wheel;
- private Object part;
- private Map<String, Integer> map;
-
- public String getPlate() {
- return plate;
- }
-
- public void setPlate(String plate) {
- this.plate = plate;
- }
-
- public Wheel getWheel() {
- return wheel;
- }
-
- public void setWheel(Wheel wheel) {
- this.wheel = wheel;
- }
-
- public Map<String, Integer> getMap() {
- return map;
- }
-
- public void setMap(Map<String, Integer> map) {
- this.map = map;
- }
-
- public Object getPart() {
- return part;
- }
-
- public void setPart(Object part) {
- this.part = part;
- }
-
- public String getYear() {
- return year;
- }
-
- public void setYear(String year) {
- this.year = year;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class ImplicitTagsTest extends TestCase {
+
+ public void testDefaultRepresenter() {
+ CarWithWheel car1 = new CarWithWheel();
+ car1.setPlate("12-XP-F4");
+ Wheel wheel = new Wheel();
+ wheel.setId(2);
+ car1.setWheel(wheel);
+ Map<String, Integer> map = new HashMap<String, Integer>();
+ map.put("id", 3);
+ car1.setMap(map);
+ car1.setPart(new Wheel(4));
+ car1.setYear("2008");
+ String carYaml1 = new Yaml().dump(car1);
+ assertEquals(Util.getLocalResource("constructor/carwheel-without-tags.yaml"), carYaml1);
+ CarWithWheel car2 = (CarWithWheel) new Yaml().load(carYaml1);
+ String carYaml2 = new Yaml().dump(car2);
+ assertEquals(carYaml1, carYaml2);
+ }
+
+ public void testNoRootTag() {
+ CarWithWheel car1 = new CarWithWheel();
+ car1.setPlate("12-XP-F4");
+ Wheel wheel = new Wheel();
+ wheel.setId(2);
+ car1.setWheel(wheel);
+ Map<String, Integer> map = new HashMap<String, Integer>();
+ map.put("id", 3);
+ car1.setMap(map);
+ car1.setYear("2008");
+ String carYaml1 = new Yaml().dumpAs(car1, Tag.MAP, FlowStyle.AUTO);
+ assertEquals(Util.getLocalResource("constructor/car-without-root-tag.yaml"), carYaml1);
+ //
+ Constructor contructor = new Constructor(CarWithWheel.class);
+ CarWithWheel car2 = (CarWithWheel) new Yaml(contructor).load(carYaml1);
+ String carYaml2 = new Yaml().dumpAs(car2, Tag.MAP, FlowStyle.AUTO);
+ assertEquals(carYaml1, carYaml2);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testRootMap() {
+ Map<Object, Object> car1 = new HashMap<Object, Object>();
+ car1.put("plate", "12-XP-F4");
+ Wheel wheel = new Wheel();
+ wheel.setId(2);
+ car1.put("wheel", wheel);
+ Map<String, Integer> map = new HashMap<String, Integer>();
+ map.put("id", 3);
+ car1.put("map", map);
+ String carYaml1 = new Yaml().dump(car1);
+ assertEquals(Util.getLocalResource("constructor/carwheel-root-map.yaml"), carYaml1);
+ Map<Object, Object> car2 = (Map<Object, Object>) new Yaml().load(carYaml1);
+ assertEquals(car1, car2);
+ assertEquals(carYaml1, new Yaml().dump(car2));
+ }
+
+ public void testLoadClassTag() {
+ Constructor constructor = new Constructor();
+ constructor.addTypeDescription(new TypeDescription(Car.class, "!car"));
+ Yaml yaml = new Yaml(constructor);
+ Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-without-tags.yaml"));
+ assertEquals("12-XP-F4", car.getPlate());
+ List<Wheel> wheels = car.getWheels();
+ assertNotNull(wheels);
+ assertEquals(5, wheels.size());
+ Wheel w1 = wheels.get(0);
+ assertEquals(1, w1.getId());
+ //
+ String carYaml1 = new Yaml().dump(car);
+ assertTrue(carYaml1.startsWith("!!org.yaml.snakeyaml.constructor.Car"));
+ //
+ Representer representer = new Representer();
+ representer.addClassTag(Car.class, new Tag("!car"));
+ yaml = new Yaml(representer);
+ String carYaml2 = yaml.dump(car);
+ assertEquals(Util.getLocalResource("constructor/car-without-tags.yaml"), carYaml2);
+ }
+
+ public static class CarWithWheel {
+ private String plate;
+ private String year;
+ private Wheel wheel;
+ private Object part;
+ private Map<String, Integer> map;
+
+ public String getPlate() {
+ return plate;
+ }
+
+ public void setPlate(String plate) {
+ this.plate = plate;
+ }
+
+ public Wheel getWheel() {
+ return wheel;
+ }
+
+ public void setWheel(Wheel wheel) {
+ this.wheel = wheel;
+ }
+
+ public Map<String, Integer> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, Integer> map) {
+ this.map = map;
+ }
+
+ public Object getPart() {
+ return part;
+ }
+
+ public void setPart(Object part) {
+ this.part = part;
+ }
+
+ public String getYear() {
+ return year;
+ }
+
+ public void setYear(String year) {
+ this.year = year;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/IncompleteBeanConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/IncompleteBeanConstructorTest.java
index a7432ee..17f4938 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/IncompleteBeanConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/IncompleteBeanConstructorTest.java
@@ -1,60 +1,60 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.error.YAMLException;
-
-public class IncompleteBeanConstructorTest extends TestCase {
-
- public void testRepresentor() {
- IncompleteJavaBean bean = new IncompleteJavaBean();
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(bean);
- String className = this.getClass().getPackage().getName();
- assertEquals("!!" + className + ".IncompleteJavaBean {name: No name}\n", output);
- }
-
- public void testConstructor() {
- String className = "!!" + this.getClass().getPackage().getName()
- + ".IncompleteJavaBean {number: 2}";
- Yaml yaml = new Yaml();
- IncompleteJavaBean bean = (IncompleteJavaBean) yaml.load(className);
- assertNotNull(bean);
- assertEquals("No name", bean.getName());
- assertEquals(2, bean.obtainNumber());
- }
-
- public void testConstructor2() {
- String className = "!!" + this.getClass().getPackage().getName()
- + ".IncompleteJavaBean {number: 2, name: Bill}";
- Yaml yaml = new Yaml();
- try {
- yaml.load(className);
- fail("'name' property does not have setter.");
- } catch (YAMLException e) {
- assertEquals(
- "Cannot create property=name for JavaBean=<IncompleteJavaBean name=No name>; Unable to find property 'name' on class: org.yaml.snakeyaml.constructor.IncompleteJavaBean",
- e.getCause().getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.YAMLException;
+
+public class IncompleteBeanConstructorTest extends TestCase {
+
+ public void testRepresentor() {
+ IncompleteJavaBean bean = new IncompleteJavaBean();
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(bean);
+ String className = this.getClass().getPackage().getName();
+ assertEquals("!!" + className + ".IncompleteJavaBean {name: No name}\n", output);
+ }
+
+ public void testConstructor() {
+ String className = "!!" + this.getClass().getPackage().getName()
+ + ".IncompleteJavaBean {number: 2}";
+ Yaml yaml = new Yaml();
+ IncompleteJavaBean bean = (IncompleteJavaBean) yaml.load(className);
+ assertNotNull(bean);
+ assertEquals("No name", bean.getName());
+ assertEquals(2, bean.obtainNumber());
+ }
+
+ public void testConstructor2() {
+ String className = "!!" + this.getClass().getPackage().getName()
+ + ".IncompleteJavaBean {number: 2, name: Bill}";
+ Yaml yaml = new Yaml();
+ try {
+ yaml.load(className);
+ fail("'name' property does not have setter.");
+ } catch (YAMLException e) {
+ assertEquals(
+ "Cannot create property=name for JavaBean=<IncompleteJavaBean name=No name>; Unable to find property 'name' on class: org.yaml.snakeyaml.constructor.IncompleteJavaBean",
+ e.getCause().getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/IncompleteJavaBean.java b/src/test/java/org/yaml/snakeyaml/constructor/IncompleteJavaBean.java
index 32b6b27..8f0148c 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/IncompleteJavaBean.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/IncompleteJavaBean.java
@@ -1,41 +1,41 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-public class IncompleteJavaBean {
- private int number;
- private String name = "No name";
- private float amount;
-
- public String getName() {
- return name;
- }
-
- public void setNumber(int number) {
- this.number = number;
- amount += number;
- }
-
- public int obtainNumber() {
- return number;
- }
-
- @Override
- public String toString() {
- return "<IncompleteJavaBean name=" + name + ">";
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+public class IncompleteJavaBean {
+ private int number;
+ private String name = "No name";
+ private float amount;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ amount += number;
+ }
+
+ public int obtainNumber() {
+ return number;
+ }
+
+ @Override
+ public String toString() {
+ return "<IncompleteJavaBean name=" + name + ">";
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/MockDateBeanConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/MockDateBeanConstructorTest.java
index 6dcd1d2..445a88b 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/MockDateBeanConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/MockDateBeanConstructorTest.java
@@ -1,73 +1,73 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class MockDateBeanConstructorTest extends TestCase {
-
- public void testConstructor() {
- String className = "!!org.yaml.snakeyaml.constructor.MockDateBeanConstructorTest$DateBean {number: 24, date: 2009-07-24}";
- Yaml yaml = new Yaml();
- try {
- yaml.load(className);
- fail("MockDate cannot be constructed.");
- } catch (Exception e) {
- assertEquals(
- "Cannot create property=date for JavaBean=<DateBean n=24>; Cannot construct: 'class org.yaml.snakeyaml.constructor.MockDateBeanConstructorTest$MockDate'",
- e.getCause().getMessage());
- }
- }
-
- public static class DateBean {
- private int number;
- private MockDate date;
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
-
- public MockDate getDate() {
- return date;
- }
-
- public void setDate(MockDate date) {
- this.date = date;
- }
-
- @Override
- public String toString() {
- return "<DateBean n=" + number + ">";
- }
- }
-
- public static class MockDate extends Date {
- private static final long serialVersionUID = 621384692653658062L;
-
- public MockDate(long date) {
- throw new RuntimeException("Test error.");
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class MockDateBeanConstructorTest extends TestCase {
+
+ public void testConstructor() {
+ String className = "!!org.yaml.snakeyaml.constructor.MockDateBeanConstructorTest$DateBean {number: 24, date: 2009-07-24}";
+ Yaml yaml = new Yaml();
+ try {
+ yaml.load(className);
+ fail("MockDate cannot be constructed.");
+ } catch (Exception e) {
+ assertEquals(
+ "Cannot create property=date for JavaBean=<DateBean n=24>; Cannot construct: 'class org.yaml.snakeyaml.constructor.MockDateBeanConstructorTest$MockDate'",
+ e.getCause().getMessage());
+ }
+ }
+
+ public static class DateBean {
+ private int number;
+ private MockDate date;
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public MockDate getDate() {
+ return date;
+ }
+
+ public void setDate(MockDate date) {
+ this.date = date;
+ }
+
+ @Override
+ public String toString() {
+ return "<DateBean n=" + number + ">";
+ }
+ }
+
+ public static class MockDate extends Date {
+ private static final long serialVersionUID = 621384692653658062L;
+
+ public MockDate(long date) {
+ throw new RuntimeException("Test error.");
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/MyCar.java b/src/test/java/org/yaml/snakeyaml/constructor/MyCar.java
index 9eedc98..9efc4ed 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/MyCar.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/MyCar.java
@@ -1,50 +1,50 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.Date;
-import java.util.Map;
-
-public class MyCar {
- private String plate;
- private Map<MyWheel, Date> wheels;
- private Map<String, Integer> windows;
-
- public String getPlate() {
- return plate;
- }
-
- public void setPlate(String plate) {
- this.plate = plate;
- }
-
- public Map<MyWheel, Date> getWheels() {
- return wheels;
- }
-
- public void setWheels(Map<MyWheel, Date> wheels) {
- this.wheels = wheels;
- }
-
- public Map<String, Integer> getWindows() {
- return windows;
- }
-
- public void setWindows(Map<String, Integer> windows) {
- this.windows = windows;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.Date;
+import java.util.Map;
+
+public class MyCar {
+ private String plate;
+ private Map<MyWheel, Date> wheels;
+ private Map<String, Integer> windows;
+
+ public String getPlate() {
+ return plate;
+ }
+
+ public void setPlate(String plate) {
+ this.plate = plate;
+ }
+
+ public Map<MyWheel, Date> getWheels() {
+ return wheels;
+ }
+
+ public void setWheels(Map<MyWheel, Date> wheels) {
+ this.wheels = wheels;
+ }
+
+ public Map<String, Integer> getWindows() {
+ return windows;
+ }
+
+ public void setWindows(Map<String, Integer> windows) {
+ this.windows = windows;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/MyWheel.java b/src/test/java/org/yaml/snakeyaml/constructor/MyWheel.java
index 67b48e8..dae07a7 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/MyWheel.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/MyWheel.java
@@ -1,66 +1,66 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-public class MyWheel implements Comparable<MyWheel> {
- private int id;
- private String brand;
-
- public MyWheel() {
- brand = "Pirelli";
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- return "Wheel id=" + id;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MyWheel) {
- MyWheel wheel = (MyWheel) obj;
- return id == wheel.getId();
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return new Integer(id).hashCode();
- }
-
- public String getBrand() {
- return brand;
- }
-
- public void setBrand(String brand) {
- this.brand = brand;
- }
-
- public int compareTo(MyWheel arg0) {
- return new Integer(id).compareTo(new Integer(arg0.id));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+public class MyWheel implements Comparable<MyWheel> {
+ private int id;
+ private String brand;
+
+ public MyWheel() {
+ brand = "Pirelli";
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return "Wheel id=" + id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof MyWheel) {
+ MyWheel wheel = (MyWheel) obj;
+ return id == wheel.getId();
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return new Integer(id).hashCode();
+ }
+
+ public String getBrand() {
+ return brand;
+ }
+
+ public void setBrand(String brand) {
+ this.brand = brand;
+ }
+
+ public int compareTo(MyWheel arg0) {
+ return new Integer(id).compareTo(new Integer(arg0.id));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/Parent1.java b/src/test/java/org/yaml/snakeyaml/constructor/Parent1.java
index 123262c..05d3e62 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/Parent1.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/Parent1.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-public class Parent1 {
- private String id;
- private Child1 child;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Child1 getChild() {
- return child;
- }
-
- public void setChild(Child1 child) {
- this.child = child;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+public class Parent1 {
+ private String id;
+ private Child1 child;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Child1 getChild() {
+ return child;
+ }
+
+ public void setChild(Child1 child) {
+ this.child = child;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/Person.java b/src/test/java/org/yaml/snakeyaml/constructor/Person.java
index 41487f0..2a7fe59 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/Person.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/Person.java
@@ -1,64 +1,64 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-/**
- * Test JavaBean
- */
-public class Person {
- private String firstName;
- private String lastName;
- private Integer age;
-
- public Person(String firstName, String lastName, Integer age) {
- this.firstName = firstName;
- this.lastName = lastName;
- this.age = age;
- }
-
- public Person() {
- }
-
- public Person(String lastName) {
- this.lastName = lastName;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public Integer getAge() {
- return age;
- }
-
- public void setAge(Integer age) {
- this.age = age;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+/**
+ * Test JavaBean
+ */
+public class Person {
+ private String firstName;
+ private String lastName;
+ private Integer age;
+
+ public Person(String firstName, String lastName, Integer age) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ }
+
+ public Person() {
+ }
+
+ public Person(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public Integer getAge() {
+ return age;
+ }
+
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/PrefixConstructorTest.java b/src/test/java/org/yaml/snakeyaml/constructor/PrefixConstructorTest.java
index 574a56a..19489d8 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/PrefixConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/PrefixConstructorTest.java
@@ -1,137 +1,137 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Example to process a family of tags with the same prefix with one constructor
- * (PrefixConstruct)
- */
-public class PrefixConstructorTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void test1() {
- Yaml yaml = new Yaml(new CustomConstructor());
- String input = "- !org.yaml.Foo 123\n- !org.yaml.Bar 456\n- !org.yaml.Exact 789\n- !Immutable [aaa, bbb]";
- List<Extra> list = (List<Extra>) yaml.load(input);
- assertEquals(4, list.size());
- Extra foo = list.get(0);
- assertEquals("Foo", foo.getName());
- assertEquals("123", foo.getValue());
- //
- Extra bar = list.get(1);
- assertEquals("Bar", bar.getName());
- assertEquals("456", bar.getValue());
- //
- Extra item = list.get(2);
- assertEquals("Item", item.getName());
- assertEquals("789", item.getValue());
- //
- Extra immut = list.get(3);
- assertEquals("aaa", immut.getName());
- assertEquals("bbb", immut.getValue());
- }
-
- private class CustomConstructor extends SafeConstructor {
- public CustomConstructor() {
- // define tags which begin with !org.yaml.
- String prefix = "!org.yaml.";
- this.yamlMultiConstructors.put(prefix, new PrefixConstruct(prefix,
- CustomConstructor.this));
- this.yamlConstructors.put(null, new ConstructUnknown(CustomConstructor.this));
- this.yamlConstructors.put(new Tag("!org.yaml.Exact"), new ExactConstruct(
- CustomConstructor.this));
- }
- }
-
- /**
- * Process tags which start with '!org.yaml.'
- */
- private class PrefixConstruct extends AbstractConstruct {
- private String prefix;
- private BaseConstructor con;
-
- public PrefixConstruct(String prefix, BaseConstructor con) {
- this.prefix = prefix;
- this.con = con;
- }
-
- public Object construct(Node node) {
- String suffix = node.getTag().getValue().substring(prefix.length());
- return new Extra(suffix, con.constructScalar((ScalarNode) node).toString());
- }
- }
-
- /**
- * This has more priority then PrefixConstruct
- */
- private class ExactConstruct extends AbstractConstruct {
- private BaseConstructor con;
-
- public ExactConstruct(BaseConstructor con) {
- this.con = con;
- }
-
- public Object construct(Node node) {
- return new Extra("Item", con.constructScalar((ScalarNode) node).toString());
- }
- }
-
- /**
- * Process unrecognised tags
- */
- private class ConstructUnknown extends AbstractConstruct {
- private BaseConstructor con;
-
- public ConstructUnknown(BaseConstructor con) {
- this.con = con;
- }
-
- @SuppressWarnings("unchecked")
- public Object construct(Node node) {
- List<String> list = (List<String>) con.constructSequence((SequenceNode) node);
- return new Extra(list.get(0), list.get(1));
- }
- }
-
- private class Extra {
- private String name;
- private String value;
-
- public Extra(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-
- public String getName() {
- return name;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Example to process a family of tags with the same prefix with one constructor
+ * (PrefixConstruct)
+ */
+public class PrefixConstructorTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void test1() {
+ Yaml yaml = new Yaml(new CustomConstructor());
+ String input = "- !org.yaml.Foo 123\n- !org.yaml.Bar 456\n- !org.yaml.Exact 789\n- !Immutable [aaa, bbb]";
+ List<Extra> list = (List<Extra>) yaml.load(input);
+ assertEquals(4, list.size());
+ Extra foo = list.get(0);
+ assertEquals("Foo", foo.getName());
+ assertEquals("123", foo.getValue());
+ //
+ Extra bar = list.get(1);
+ assertEquals("Bar", bar.getName());
+ assertEquals("456", bar.getValue());
+ //
+ Extra item = list.get(2);
+ assertEquals("Item", item.getName());
+ assertEquals("789", item.getValue());
+ //
+ Extra immut = list.get(3);
+ assertEquals("aaa", immut.getName());
+ assertEquals("bbb", immut.getValue());
+ }
+
+ private class CustomConstructor extends SafeConstructor {
+ public CustomConstructor() {
+ // define tags which begin with !org.yaml.
+ String prefix = "!org.yaml.";
+ this.yamlMultiConstructors.put(prefix, new PrefixConstruct(prefix,
+ CustomConstructor.this));
+ this.yamlConstructors.put(null, new ConstructUnknown(CustomConstructor.this));
+ this.yamlConstructors.put(new Tag("!org.yaml.Exact"), new ExactConstruct(
+ CustomConstructor.this));
+ }
+ }
+
+ /**
+ * Process tags which start with '!org.yaml.'
+ */
+ private class PrefixConstruct extends AbstractConstruct {
+ private String prefix;
+ private BaseConstructor con;
+
+ public PrefixConstruct(String prefix, BaseConstructor con) {
+ this.prefix = prefix;
+ this.con = con;
+ }
+
+ public Object construct(Node node) {
+ String suffix = node.getTag().getValue().substring(prefix.length());
+ return new Extra(suffix, con.constructScalar((ScalarNode) node).toString());
+ }
+ }
+
+ /**
+ * This has more priority then PrefixConstruct
+ */
+ private class ExactConstruct extends AbstractConstruct {
+ private BaseConstructor con;
+
+ public ExactConstruct(BaseConstructor con) {
+ this.con = con;
+ }
+
+ public Object construct(Node node) {
+ return new Extra("Item", con.constructScalar((ScalarNode) node).toString());
+ }
+ }
+
+ /**
+ * Process unrecognised tags
+ */
+ private class ConstructUnknown extends AbstractConstruct {
+ private BaseConstructor con;
+
+ public ConstructUnknown(BaseConstructor con) {
+ this.con = con;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object construct(Node node) {
+ List<String> list = (List<String>) con.constructSequence((SequenceNode) node);
+ return new Extra(list.get(0), list.get(1));
+ }
+ }
+
+ private class Extra {
+ private String name;
+ private String value;
+
+ public Extra(String name, String value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public String getName() {
+ return name;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/TestBean1.java b/src/test/java/org/yaml/snakeyaml/constructor/TestBean1.java
index 84b80d5..e03a571 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/TestBean1.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/TestBean1.java
@@ -1,205 +1,205 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.math.BigInteger;
-import java.util.Date;
-
-public class TestBean1 {
- private String text;
- private String id;
- private Byte byteClass;
- private byte bytePrimitive;
- private Short shortClass;
- private short shortPrimitive;
- private Integer integer;
- private int intPrimitive;
- private Long longClass;
- private long longPrimitive;
- private Boolean booleanClass;
- private boolean booleanPrimitive;
- private Character charClass;
- private char charPrimitive;
- private BigInteger bigInteger;
- private Float floatClass;
- private float floatPrimitive;
- private Double doubleClass;
- private double doublePrimitive;
- private Date date;
- public String publicField;
- static public Integer staticInteger;
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public Integer getInteger() {
- return integer;
- }
-
- public void setInteger(Integer integer) {
- this.integer = integer;
- }
-
- public int getIntPrimitive() {
- return intPrimitive;
- }
-
- public void setIntPrimitive(int intPrimitive) {
- this.intPrimitive = intPrimitive;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Byte getByteClass() {
- return byteClass;
- }
-
- public void setByteClass(Byte byteClass) {
- this.byteClass = byteClass;
- }
-
- public byte getBytePrimitive() {
- return bytePrimitive;
- }
-
- public void setBytePrimitive(byte bytePrimitive) {
- this.bytePrimitive = bytePrimitive;
- }
-
- public Short getShortClass() {
- return shortClass;
- }
-
- public void setShortClass(Short shortClass) {
- this.shortClass = shortClass;
- }
-
- public short getShortPrimitive() {
- return shortPrimitive;
- }
-
- public void setShortPrimitive(short shortPrimitive) {
- this.shortPrimitive = shortPrimitive;
- }
-
- public Long getLongClass() {
- return longClass;
- }
-
- public void setLongClass(Long longClass) {
- this.longClass = longClass;
- }
-
- public long getLongPrimitive() {
- return longPrimitive;
- }
-
- public void setLongPrimitive(long longPrimitive) {
- this.longPrimitive = longPrimitive;
- }
-
- public Boolean getBooleanClass() {
- return booleanClass;
- }
-
- public void setBooleanClass(Boolean booleanClass) {
- this.booleanClass = booleanClass;
- }
-
- public boolean isBooleanPrimitive() {
- return booleanPrimitive;
- }
-
- public void setBooleanPrimitive(boolean booleanPrimitive) {
- this.booleanPrimitive = booleanPrimitive;
- }
-
- public Character getCharClass() {
- return charClass;
- }
-
- public void setCharClass(Character charClass) {
- this.charClass = charClass;
- }
-
- public char getCharPrimitive() {
- return charPrimitive;
- }
-
- public void setCharPrimitive(char charPrimitive) {
- this.charPrimitive = charPrimitive;
- }
-
- public BigInteger getBigInteger() {
- return bigInteger;
- }
-
- public void setBigInteger(BigInteger bigInteger) {
- this.bigInteger = bigInteger;
- }
-
- public Float getFloatClass() {
- return floatClass;
- }
-
- public void setFloatClass(Float floatClass) {
- this.floatClass = floatClass;
- }
-
- public float getFloatPrimitive() {
- return floatPrimitive;
- }
-
- public void setFloatPrimitive(float floatPrimitive) {
- this.floatPrimitive = floatPrimitive;
- }
-
- public Double getDoubleClass() {
- return doubleClass;
- }
-
- public void setDoubleClass(Double doubleClass) {
- this.doubleClass = doubleClass;
- }
-
- public double getDoublePrimitive() {
- return doublePrimitive;
- }
-
- public void setDoublePrimitive(double doublePrimitive) {
- this.doublePrimitive = doublePrimitive;
- }
-
- public Date getDate() {
- return date;
- }
-
- public void setDate(Date date) {
- this.date = date;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.math.BigInteger;
+import java.util.Date;
+
+public class TestBean1 {
+ private String text;
+ private String id;
+ private Byte byteClass;
+ private byte bytePrimitive;
+ private Short shortClass;
+ private short shortPrimitive;
+ private Integer integer;
+ private int intPrimitive;
+ private Long longClass;
+ private long longPrimitive;
+ private Boolean booleanClass;
+ private boolean booleanPrimitive;
+ private Character charClass;
+ private char charPrimitive;
+ private BigInteger bigInteger;
+ private Float floatClass;
+ private float floatPrimitive;
+ private Double doubleClass;
+ private double doublePrimitive;
+ private Date date;
+ public String publicField;
+ static public Integer staticInteger;
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public Integer getInteger() {
+ return integer;
+ }
+
+ public void setInteger(Integer integer) {
+ this.integer = integer;
+ }
+
+ public int getIntPrimitive() {
+ return intPrimitive;
+ }
+
+ public void setIntPrimitive(int intPrimitive) {
+ this.intPrimitive = intPrimitive;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Byte getByteClass() {
+ return byteClass;
+ }
+
+ public void setByteClass(Byte byteClass) {
+ this.byteClass = byteClass;
+ }
+
+ public byte getBytePrimitive() {
+ return bytePrimitive;
+ }
+
+ public void setBytePrimitive(byte bytePrimitive) {
+ this.bytePrimitive = bytePrimitive;
+ }
+
+ public Short getShortClass() {
+ return shortClass;
+ }
+
+ public void setShortClass(Short shortClass) {
+ this.shortClass = shortClass;
+ }
+
+ public short getShortPrimitive() {
+ return shortPrimitive;
+ }
+
+ public void setShortPrimitive(short shortPrimitive) {
+ this.shortPrimitive = shortPrimitive;
+ }
+
+ public Long getLongClass() {
+ return longClass;
+ }
+
+ public void setLongClass(Long longClass) {
+ this.longClass = longClass;
+ }
+
+ public long getLongPrimitive() {
+ return longPrimitive;
+ }
+
+ public void setLongPrimitive(long longPrimitive) {
+ this.longPrimitive = longPrimitive;
+ }
+
+ public Boolean getBooleanClass() {
+ return booleanClass;
+ }
+
+ public void setBooleanClass(Boolean booleanClass) {
+ this.booleanClass = booleanClass;
+ }
+
+ public boolean isBooleanPrimitive() {
+ return booleanPrimitive;
+ }
+
+ public void setBooleanPrimitive(boolean booleanPrimitive) {
+ this.booleanPrimitive = booleanPrimitive;
+ }
+
+ public Character getCharClass() {
+ return charClass;
+ }
+
+ public void setCharClass(Character charClass) {
+ this.charClass = charClass;
+ }
+
+ public char getCharPrimitive() {
+ return charPrimitive;
+ }
+
+ public void setCharPrimitive(char charPrimitive) {
+ this.charPrimitive = charPrimitive;
+ }
+
+ public BigInteger getBigInteger() {
+ return bigInteger;
+ }
+
+ public void setBigInteger(BigInteger bigInteger) {
+ this.bigInteger = bigInteger;
+ }
+
+ public Float getFloatClass() {
+ return floatClass;
+ }
+
+ public void setFloatClass(Float floatClass) {
+ this.floatClass = floatClass;
+ }
+
+ public float getFloatPrimitive() {
+ return floatPrimitive;
+ }
+
+ public void setFloatPrimitive(float floatPrimitive) {
+ this.floatPrimitive = floatPrimitive;
+ }
+
+ public Double getDoubleClass() {
+ return doubleClass;
+ }
+
+ public void setDoubleClass(Double doubleClass) {
+ this.doubleClass = doubleClass;
+ }
+
+ public double getDoublePrimitive() {
+ return doublePrimitive;
+ }
+
+ public void setDoublePrimitive(double doublePrimitive) {
+ this.doublePrimitive = doublePrimitive;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/TypeSafeCollectionsTest.java b/src/test/java/org/yaml/snakeyaml/constructor/TypeSafeCollectionsTest.java
index 9272644..1ac72b7 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/TypeSafeCollectionsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/TypeSafeCollectionsTest.java
@@ -1,104 +1,104 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class TypeSafeCollectionsTest extends TestCase {
-
- public void testTypeSafeList() {
- Constructor constructor = new Constructor(Car.class);
- TypeDescription carDescription = new TypeDescription(Car.class);
- carDescription.putListPropertyType("wheels", Wheel.class);
- constructor.addTypeDescription(carDescription);
- Yaml yaml = new Yaml(constructor);
- Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
- assertEquals("12-XP-F4", car.getPlate());
- List<Wheel> wheels = car.getWheels();
- assertNotNull(wheels);
- assertEquals(5, wheels.size());
- for (Wheel wheel : wheels) {
- assertTrue(wheel.getId() > 0);
- }
- }
-
- public void testTypeSafeMap() {
- Constructor constructor = new Constructor(MyCar.class);
- TypeDescription carDescription = new TypeDescription(MyCar.class);
- carDescription.putMapPropertyType("wheels", MyWheel.class, Object.class);
- constructor.addTypeDescription(carDescription);
- Yaml yaml = new Yaml(constructor);
- MyCar car = (MyCar) yaml.load(Util
- .getLocalResource("constructor/car-no-root-class-map.yaml"));
- assertEquals("00-FF-Q2", car.getPlate());
- Map<MyWheel, Date> wheels = car.getWheels();
- assertNotNull(wheels);
- assertEquals(5, wheels.size());
- for (MyWheel wheel : wheels.keySet()) {
- assertTrue(wheel.getId() > 0);
- Date date = wheels.get(wheel);
- long time = date.getTime();
- assertTrue("It must be midnight.", time % 10000 == 0);
- }
- }
-
- public void testWithGlobalTag() {
- Map<MyWheel, Date> wheels = new TreeMap<MyWheel, Date>();
- long time = 1248212168084L;
- for (int i = 1; i < 6; i++) {
- MyWheel mw = new MyWheel();
- mw.setId(i);
- mw.setBrand(mw.getBrand() + String.valueOf(i));
- wheels.put(mw, new Date(time + i));
- }
- MyCar c = new MyCar();
- c.setPlate("00-FF-Q2");
- c.setWheels(wheels);
- Representer representer = new Representer();
- representer.addClassTag(MyWheel.class, Tag.MAP);
- Yaml yaml = new Yaml(representer);
- String output = yaml.dump(c);
- assertEquals(Util.getLocalResource("javabeans/mycar-with-global-tag1.yaml"), output);
- // load
- Yaml beanLoader = new Yaml();
- MyCar car = beanLoader.loadAs(output, MyCar.class);
- assertNotNull(car);
- assertEquals("00-FF-Q2", car.getPlate());
- assertEquals(5, car.getWheels().size());
- for (Date d : car.getWheels().values()) {
- // give a day for any timezone
- assertTrue(d.before(new Date(time + 1000 * 60 * 60 * 24)));
- assertTrue(d.after(new Date(time)));
- }
- Object wheel = car.getWheels().keySet().iterator().next();
- assertTrue(wheel instanceof MyWheel);
- MyWheel w = (MyWheel) wheel;
- assertEquals(1, w.getId());
- assertEquals("Pirelli1", w.getBrand());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class TypeSafeCollectionsTest extends TestCase {
+
+ public void testTypeSafeList() {
+ Constructor constructor = new Constructor(Car.class);
+ TypeDescription carDescription = new TypeDescription(Car.class);
+ carDescription.putListPropertyType("wheels", Wheel.class);
+ constructor.addTypeDescription(carDescription);
+ Yaml yaml = new Yaml(constructor);
+ Car car = (Car) yaml.load(Util.getLocalResource("constructor/car-no-root-class.yaml"));
+ assertEquals("12-XP-F4", car.getPlate());
+ List<Wheel> wheels = car.getWheels();
+ assertNotNull(wheels);
+ assertEquals(5, wheels.size());
+ for (Wheel wheel : wheels) {
+ assertTrue(wheel.getId() > 0);
+ }
+ }
+
+ public void testTypeSafeMap() {
+ Constructor constructor = new Constructor(MyCar.class);
+ TypeDescription carDescription = new TypeDescription(MyCar.class);
+ carDescription.putMapPropertyType("wheels", MyWheel.class, Object.class);
+ constructor.addTypeDescription(carDescription);
+ Yaml yaml = new Yaml(constructor);
+ MyCar car = (MyCar) yaml.load(Util
+ .getLocalResource("constructor/car-no-root-class-map.yaml"));
+ assertEquals("00-FF-Q2", car.getPlate());
+ Map<MyWheel, Date> wheels = car.getWheels();
+ assertNotNull(wheels);
+ assertEquals(5, wheels.size());
+ for (MyWheel wheel : wheels.keySet()) {
+ assertTrue(wheel.getId() > 0);
+ Date date = wheels.get(wheel);
+ long time = date.getTime();
+ assertTrue("It must be midnight.", time % 10000 == 0);
+ }
+ }
+
+ public void testWithGlobalTag() {
+ Map<MyWheel, Date> wheels = new TreeMap<MyWheel, Date>();
+ long time = 1248212168084L;
+ for (int i = 1; i < 6; i++) {
+ MyWheel mw = new MyWheel();
+ mw.setId(i);
+ mw.setBrand(mw.getBrand() + String.valueOf(i));
+ wheels.put(mw, new Date(time + i));
+ }
+ MyCar c = new MyCar();
+ c.setPlate("00-FF-Q2");
+ c.setWheels(wheels);
+ Representer representer = new Representer();
+ representer.addClassTag(MyWheel.class, Tag.MAP);
+ Yaml yaml = new Yaml(representer);
+ String output = yaml.dump(c);
+ assertEquals(Util.getLocalResource("javabeans/mycar-with-global-tag1.yaml"), output);
+ // load
+ Yaml beanLoader = new Yaml();
+ MyCar car = beanLoader.loadAs(output, MyCar.class);
+ assertNotNull(car);
+ assertEquals("00-FF-Q2", car.getPlate());
+ assertEquals(5, car.getWheels().size());
+ for (Date d : car.getWheels().values()) {
+ // give a day for any timezone
+ assertTrue(d.before(new Date(time + 1000 * 60 * 60 * 24)));
+ assertTrue(d.after(new Date(time)));
+ }
+ Object wheel = car.getWheels().keySet().iterator().next();
+ assertTrue(wheel instanceof MyWheel);
+ MyWheel w = (MyWheel) wheel;
+ assertEquals(1, w.getId());
+ assertEquals("Pirelli1", w.getBrand());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/constructor/Wheel.java b/src/test/java/org/yaml/snakeyaml/constructor/Wheel.java
index efcf0f9..a5c6799 100644
--- a/src/test/java/org/yaml/snakeyaml/constructor/Wheel.java
+++ b/src/test/java/org/yaml/snakeyaml/constructor/Wheel.java
@@ -1,57 +1,57 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.constructor;
-
-public class Wheel {
- private int id;
-
- public Wheel(int id) {
- this.id = id;
- }
-
- public Wheel() {
- this(0);
- }
-
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- return "Wheel id=" + id;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Wheel) {
- Wheel wheel = (Wheel) obj;
- return id == wheel.getId();
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return new Integer(id).hashCode();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.constructor;
+
+public class Wheel {
+ private int id;
+
+ public Wheel(int id) {
+ this.id = id;
+ }
+
+ public Wheel() {
+ this(0);
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return "Wheel id=" + id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Wheel) {
+ Wheel wheel = (Wheel) obj;
+ return id == wheel.getId();
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return new Integer(id).hashCode();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/emitter/EmitterMultiLineTest.java b/src/test/java/org/yaml/snakeyaml/emitter/EmitterMultiLineTest.java
index 0fe238c..0f37b3b 100644
--- a/src/test/java/org/yaml/snakeyaml/emitter/EmitterMultiLineTest.java
+++ b/src/test/java/org/yaml/snakeyaml/emitter/EmitterMultiLineTest.java
@@ -1,110 +1,110 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.Yaml;
-
-public class EmitterMultiLineTest extends TestCase {
-
- public void testWriteMultiLineLiteral() {
- String plain = "mama\nmila\nramu";
- Yaml yaml = new Yaml();
- String output = yaml.dump(plain);
- // System.out.println(output);
- assertEquals("|-\n mama\n mila\n ramu\n", output);
- String parsed = (String) yaml.load(output);
- // System.out.println(parsed);
- assertEquals(plain, parsed);
- }
-
- public void testWriteMultiLineList() {
- String one = "first\nsecond\nthird";
- String two = "one\ntwo\nthree\n";
- byte[] binary = { 8, 14, 15, 10, 126, 32, 65, 65, 65 };
- List<Object> list = new ArrayList<Object>(2);
- list.add(one);
- list.add(two);
- list.add(binary);
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(list);
- // System.out.println(output);
- String etalon = "- |-\n first\n second\n third\n- |\n one\n two\n three\n- !!binary |-\n CA4PCn4gQUFB\n";
- assertEquals(etalon, output);
- @SuppressWarnings("unchecked")
- List<Object> parsed = (List<Object>) yaml.load(etalon);
- assertEquals(3, parsed.size());
- assertEquals(one, parsed.get(0));
- assertEquals(two, parsed.get(1));
- assertEquals(new String(binary), new String((byte[]) parsed.get(2)));
- }
-
- public void testWriteMultiLineLiteralWithClipChomping() {
- String source = "a: 1\nb: |\n mama\n mila\n ramu\n";
- // System.out.println("Source:\n" + source);
- Yaml yaml = new Yaml();
- @SuppressWarnings("unchecked")
- Map<String, Object> parsed = (Map<String, Object>) yaml.load(source);
- String value = (String) parsed.get("b");
- // System.out.println(value);
- assertEquals("mama\nmila\nramu\n", value);
- String dumped = yaml.dump(parsed);
- // System.out.println(dumped);
- assertEquals("a: 1\nb: |\n mama\n mila\n ramu\n", dumped);
- }
-
- public void testWriteMultiLineQuotedInFlowContext() {
- String source = "{a: 1, b: 'mama\n\n mila\n\n ramu'}\n";
- // System.out.println("Source:\n" + source);
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.FLOW);
- Yaml yaml = new Yaml(options);
- @SuppressWarnings("unchecked")
- Map<String, Object> parsed = (Map<String, Object>) yaml.load(source);
- String value = (String) parsed.get("b");
- // System.out.println(value);
- assertEquals("mama\nmila\nramu", value);
- String dumped = yaml.dump(parsed);
- // System.out.println(dumped);
- assertEquals("{a: 1, b: \"mama\\nmila\\nramu\"}\n", dumped);
- }
-
- public void testWriteMultiLineLiteralWithStripChomping() {
- String source = "a: 1\nb: |-\n mama\n mila\n ramu\n";
- // System.out.println("Source:\n" + source);
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- @SuppressWarnings("unchecked")
- Map<String, Object> parsed = (Map<String, Object>) yaml.load(source);
- String value = (String) parsed.get("b");
- // System.out.println(value);
- assertEquals("mama\nmila\nramu", value);
- String dumped = yaml.dump(parsed);
- // System.out.println(dumped);
- assertEquals(source, dumped);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.Yaml;
+
+public class EmitterMultiLineTest extends TestCase {
+
+ public void testWriteMultiLineLiteral() {
+ String plain = "mama\nmila\nramu";
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(plain);
+ // System.out.println(output);
+ assertEquals("|-\n mama\n mila\n ramu\n", output);
+ String parsed = (String) yaml.load(output);
+ // System.out.println(parsed);
+ assertEquals(plain, parsed);
+ }
+
+ public void testWriteMultiLineList() {
+ String one = "first\nsecond\nthird";
+ String two = "one\ntwo\nthree\n";
+ byte[] binary = { 8, 14, 15, 10, 126, 32, 65, 65, 65 };
+ List<Object> list = new ArrayList<Object>(2);
+ list.add(one);
+ list.add(two);
+ list.add(binary);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(list);
+ // System.out.println(output);
+ String etalon = "- |-\n first\n second\n third\n- |\n one\n two\n three\n- !!binary |-\n CA4PCn4gQUFB\n";
+ assertEquals(etalon, output);
+ @SuppressWarnings("unchecked")
+ List<Object> parsed = (List<Object>) yaml.load(etalon);
+ assertEquals(3, parsed.size());
+ assertEquals(one, parsed.get(0));
+ assertEquals(two, parsed.get(1));
+ assertEquals(new String(binary), new String((byte[]) parsed.get(2)));
+ }
+
+ public void testWriteMultiLineLiteralWithClipChomping() {
+ String source = "a: 1\nb: |\n mama\n mila\n ramu\n";
+ // System.out.println("Source:\n" + source);
+ Yaml yaml = new Yaml();
+ @SuppressWarnings("unchecked")
+ Map<String, Object> parsed = (Map<String, Object>) yaml.load(source);
+ String value = (String) parsed.get("b");
+ // System.out.println(value);
+ assertEquals("mama\nmila\nramu\n", value);
+ String dumped = yaml.dump(parsed);
+ // System.out.println(dumped);
+ assertEquals("a: 1\nb: |\n mama\n mila\n ramu\n", dumped);
+ }
+
+ public void testWriteMultiLineQuotedInFlowContext() {
+ String source = "{a: 1, b: 'mama\n\n mila\n\n ramu'}\n";
+ // System.out.println("Source:\n" + source);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.FLOW);
+ Yaml yaml = new Yaml(options);
+ @SuppressWarnings("unchecked")
+ Map<String, Object> parsed = (Map<String, Object>) yaml.load(source);
+ String value = (String) parsed.get("b");
+ // System.out.println(value);
+ assertEquals("mama\nmila\nramu", value);
+ String dumped = yaml.dump(parsed);
+ // System.out.println(dumped);
+ assertEquals("{a: 1, b: \"mama\\nmila\\nramu\"}\n", dumped);
+ }
+
+ public void testWriteMultiLineLiteralWithStripChomping() {
+ String source = "a: 1\nb: |-\n mama\n mila\n ramu\n";
+ // System.out.println("Source:\n" + source);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ @SuppressWarnings("unchecked")
+ Map<String, Object> parsed = (Map<String, Object>) yaml.load(source);
+ String value = (String) parsed.get("b");
+ // System.out.println(value);
+ assertEquals("mama\nmila\nramu", value);
+ String dumped = yaml.dump(parsed);
+ // System.out.println(dumped);
+ assertEquals(source, dumped);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/emitter/EmitterTest.java b/src/test/java/org/yaml/snakeyaml/emitter/EmitterTest.java
index 634b291..e55f76e 100644
--- a/src/test/java/org/yaml/snakeyaml/emitter/EmitterTest.java
+++ b/src/test/java/org/yaml/snakeyaml/emitter/EmitterTest.java
@@ -1,110 +1,110 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
-import org.yaml.snakeyaml.Yaml;
-
-public class EmitterTest extends TestCase {
-
- public void testWriteFolded() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.FOLDED);
- String folded = "0123456789 0123456789\n0123456789 0123456789";
- Map<String, String> map = new LinkedHashMap<String, String>();
- map.put("aaa", folded);
- map.put("bbb", "\nbla-bla\n");
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- String etalon = "\"aaa\": >-\n 0123456789 0123456789\n\n 0123456789 0123456789\n\"bbb\": >2\n\n bla-bla\n";
- assertEquals(etalon, output);
- }
-
- public void testWriteLiteral() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.LITERAL);
- String folded = "0123456789 0123456789 0123456789 0123456789";
- Map<String, String> map = new LinkedHashMap<String, String>();
- map.put("aaa", folded);
- map.put("bbb", "\nbla-bla\n");
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- String etalon = "\"aaa\": |-\n 0123456789 0123456789 0123456789 0123456789\n\"bbb\": |2\n\n bla-bla\n";
- assertEquals(etalon, output);
- }
-
- public void testWritePlain() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.PLAIN);
- String folded = "0123456789 0123456789\n0123456789 0123456789";
- Map<String, String> map = new LinkedHashMap<String, String>();
- map.put("aaa", folded);
- map.put("bbb", "\nbla-bla");
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- String etalon = "aaa: |-\n 0123456789 0123456789\n 0123456789 0123456789\nbbb: |2-\n\n bla-bla\n";
- assertEquals(etalon, output);
- }
-
- public void testWritePlainPretty() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.PLAIN);
- options.setPrettyFlow(true);
-
- String folded = "0123456789 0123456789\n0123456789 0123456789";
- Map<String, String> map = new LinkedHashMap<String, String>();
- map.put("aaa", folded);
- map.put("bbb", "\nbla-bla");
-
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- String etalon = "aaa: |-\n 0123456789 0123456789\n 0123456789 0123456789\nbbb: |2-\n\n bla-bla\n";
- assertEquals(etalon, output);
- }
-
- public void testWriteSingleQuoted() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.SINGLE_QUOTED);
- String folded = "0123456789 0123456789\n0123456789 0123456789";
- Map<String, String> map = new LinkedHashMap<String, String>();
- map.put("aaa", folded);
- map.put("bbb", "\nbla-bla");
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- String etalon = "'aaa': '0123456789 0123456789\n\n 0123456789 0123456789'\n'bbb': '\n\n bla-bla'\n";
- assertEquals(etalon, output);
- }
-
- public void testWriteDoubleQuoted() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
- String folded = "0123456789 0123456789\n0123456789 0123456789";
- Map<String, String> map = new LinkedHashMap<String, String>();
- map.put("aaa", folded);
- map.put("bbb", "\nbla-bla");
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- String etalon = "\"aaa\": \"0123456789 0123456789\\n0123456789 0123456789\"\n\"bbb\": \"\\nbla-bla\"\n";
- assertEquals(etalon, output);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
+import org.yaml.snakeyaml.Yaml;
+
+public class EmitterTest extends TestCase {
+
+ public void testWriteFolded() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.FOLDED);
+ String folded = "0123456789 0123456789\n0123456789 0123456789";
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put("aaa", folded);
+ map.put("bbb", "\nbla-bla\n");
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ String etalon = "\"aaa\": >-\n 0123456789 0123456789\n\n 0123456789 0123456789\n\"bbb\": >2\n\n bla-bla\n";
+ assertEquals(etalon, output);
+ }
+
+ public void testWriteLiteral() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.LITERAL);
+ String folded = "0123456789 0123456789 0123456789 0123456789";
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put("aaa", folded);
+ map.put("bbb", "\nbla-bla\n");
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ String etalon = "\"aaa\": |-\n 0123456789 0123456789 0123456789 0123456789\n\"bbb\": |2\n\n bla-bla\n";
+ assertEquals(etalon, output);
+ }
+
+ public void testWritePlain() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.PLAIN);
+ String folded = "0123456789 0123456789\n0123456789 0123456789";
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put("aaa", folded);
+ map.put("bbb", "\nbla-bla");
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ String etalon = "aaa: |-\n 0123456789 0123456789\n 0123456789 0123456789\nbbb: |2-\n\n bla-bla\n";
+ assertEquals(etalon, output);
+ }
+
+ public void testWritePlainPretty() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.PLAIN);
+ options.setPrettyFlow(true);
+
+ String folded = "0123456789 0123456789\n0123456789 0123456789";
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put("aaa", folded);
+ map.put("bbb", "\nbla-bla");
+
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ String etalon = "aaa: |-\n 0123456789 0123456789\n 0123456789 0123456789\nbbb: |2-\n\n bla-bla\n";
+ assertEquals(etalon, output);
+ }
+
+ public void testWriteSingleQuoted() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.SINGLE_QUOTED);
+ String folded = "0123456789 0123456789\n0123456789 0123456789";
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put("aaa", folded);
+ map.put("bbb", "\nbla-bla");
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ String etalon = "'aaa': '0123456789 0123456789\n\n 0123456789 0123456789'\n'bbb': '\n\n bla-bla'\n";
+ assertEquals(etalon, output);
+ }
+
+ public void testWriteDoubleQuoted() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
+ String folded = "0123456789 0123456789\n0123456789 0123456789";
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put("aaa", folded);
+ map.put("bbb", "\nbla-bla");
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ String etalon = "\"aaa\": \"0123456789 0123456789\\n0123456789 0123456789\"\n\"bbb\": \"\\nbla-bla\"\n";
+ assertEquals(etalon, output);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/emitter/EventConstructor.java b/src/test/java/org/yaml/snakeyaml/emitter/EventConstructor.java
index e04572c..6d4f875 100644
--- a/src/test/java/org/yaml/snakeyaml/emitter/EventConstructor.java
+++ b/src/test/java/org/yaml/snakeyaml/emitter/EventConstructor.java
@@ -1,119 +1,119 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.events.AliasEvent;
-import org.yaml.snakeyaml.events.DocumentEndEvent;
-import org.yaml.snakeyaml.events.DocumentStartEvent;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.ImplicitTuple;
-import org.yaml.snakeyaml.events.MappingEndEvent;
-import org.yaml.snakeyaml.events.MappingStartEvent;
-import org.yaml.snakeyaml.events.ScalarEvent;
-import org.yaml.snakeyaml.events.SequenceEndEvent;
-import org.yaml.snakeyaml.events.SequenceStartEvent;
-import org.yaml.snakeyaml.events.StreamEndEvent;
-import org.yaml.snakeyaml.events.StreamStartEvent;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-
-public class EventConstructor extends Constructor {
-
- public EventConstructor() {
- this.yamlConstructors.put(null, new ConstructEvent());
- }
-
- private class ConstructEvent extends AbstractConstruct {
-
- @SuppressWarnings("unchecked")
- public Object construct(Node node) {
- Map<Object, Object> mapping;
- if (node instanceof ScalarNode) {
- mapping = new HashMap<Object, Object>();
- } else {
- mapping = constructMapping((MappingNode) node);
- }
- String className = node.getTag().getValue().substring(1) + "Event";
- Event value;
- if (className.equals("AliasEvent")) {
- value = new AliasEvent((String) mapping.get("anchor"), null, null);
- } else if (className.equals("ScalarEvent")) {
- String tag = (String) mapping.get("tag");
- String v = (String) mapping.get("value");
- if (v == null) {
- v = "";
- }
- List<Boolean> implicitList = (List<Boolean>) mapping.get("implicit");
- ImplicitTuple implicit;
- if (implicitList == null) {
- implicit = new ImplicitTuple(false, true);
- } else {
- implicit = new ImplicitTuple((Boolean) implicitList.get(0),
- (Boolean) implicitList.get(1));
- }
- value = new ScalarEvent((String) mapping.get("anchor"), tag, implicit, v, null,
- null, null);
- } else if (className.equals("SequenceStartEvent")) {
- String tag = (String) mapping.get("tag");
- Boolean implicit = (Boolean) mapping.get("implicit");
- if (implicit == null) {
- implicit = true;
- }
- value = new SequenceStartEvent((String) mapping.get("anchor"), tag, implicit, null,
- null, false);
- } else if (className.equals("MappingStartEvent")) {
- String tag = (String) mapping.get("tag");
- Boolean implicit = (Boolean) mapping.get("implicit");
- if (implicit == null) {
- implicit = true;
- }
- value = new MappingStartEvent((String) mapping.get("anchor"), tag, implicit, null,
- null, false);
- } else if (className.equals("DocumentEndEvent")) {
- value = new DocumentEndEvent(null, null, false);
- } else if (className.equals("DocumentStartEvent")) {
- Map<String, String> tags = (Map<String, String>) mapping.get("tags");
- List<Integer> versionList = (List<Integer>) mapping.get("version");
- Integer[] version = null;
- if (versionList != null) {
- version = new Integer[2];
- version[0] = versionList.get(0).intValue();
- version[1] = versionList.get(1).intValue();
- }
- value = new DocumentStartEvent(null, null, false, version, tags);
- } else if (className.equals("MappingEndEvent")) {
- value = new MappingEndEvent(null, null);
- } else if (className.equals("SequenceEndEvent")) {
- value = new SequenceEndEvent(null, null);
- } else if (className.equals("StreamEndEvent")) {
- value = new StreamEndEvent(null, null);
- } else if (className.equals("StreamStartEvent")) {
- value = new StreamStartEvent(null, null);
- } else {
- throw new UnsupportedOperationException();
- }
- return value;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.events.AliasEvent;
+import org.yaml.snakeyaml.events.DocumentEndEvent;
+import org.yaml.snakeyaml.events.DocumentStartEvent;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.ImplicitTuple;
+import org.yaml.snakeyaml.events.MappingEndEvent;
+import org.yaml.snakeyaml.events.MappingStartEvent;
+import org.yaml.snakeyaml.events.ScalarEvent;
+import org.yaml.snakeyaml.events.SequenceEndEvent;
+import org.yaml.snakeyaml.events.SequenceStartEvent;
+import org.yaml.snakeyaml.events.StreamEndEvent;
+import org.yaml.snakeyaml.events.StreamStartEvent;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+
+public class EventConstructor extends Constructor {
+
+ public EventConstructor() {
+ this.yamlConstructors.put(null, new ConstructEvent());
+ }
+
+ private class ConstructEvent extends AbstractConstruct {
+
+ @SuppressWarnings("unchecked")
+ public Object construct(Node node) {
+ Map<Object, Object> mapping;
+ if (node instanceof ScalarNode) {
+ mapping = new HashMap<Object, Object>();
+ } else {
+ mapping = constructMapping((MappingNode) node);
+ }
+ String className = node.getTag().getValue().substring(1) + "Event";
+ Event value;
+ if (className.equals("AliasEvent")) {
+ value = new AliasEvent((String) mapping.get("anchor"), null, null);
+ } else if (className.equals("ScalarEvent")) {
+ String tag = (String) mapping.get("tag");
+ String v = (String) mapping.get("value");
+ if (v == null) {
+ v = "";
+ }
+ List<Boolean> implicitList = (List<Boolean>) mapping.get("implicit");
+ ImplicitTuple implicit;
+ if (implicitList == null) {
+ implicit = new ImplicitTuple(false, true);
+ } else {
+ implicit = new ImplicitTuple((Boolean) implicitList.get(0),
+ (Boolean) implicitList.get(1));
+ }
+ value = new ScalarEvent((String) mapping.get("anchor"), tag, implicit, v, null,
+ null, null);
+ } else if (className.equals("SequenceStartEvent")) {
+ String tag = (String) mapping.get("tag");
+ Boolean implicit = (Boolean) mapping.get("implicit");
+ if (implicit == null) {
+ implicit = true;
+ }
+ value = new SequenceStartEvent((String) mapping.get("anchor"), tag, implicit, null,
+ null, false);
+ } else if (className.equals("MappingStartEvent")) {
+ String tag = (String) mapping.get("tag");
+ Boolean implicit = (Boolean) mapping.get("implicit");
+ if (implicit == null) {
+ implicit = true;
+ }
+ value = new MappingStartEvent((String) mapping.get("anchor"), tag, implicit, null,
+ null, false);
+ } else if (className.equals("DocumentEndEvent")) {
+ value = new DocumentEndEvent(null, null, false);
+ } else if (className.equals("DocumentStartEvent")) {
+ Map<String, String> tags = (Map<String, String>) mapping.get("tags");
+ List<Integer> versionList = (List<Integer>) mapping.get("version");
+ Integer[] version = null;
+ if (versionList != null) {
+ version = new Integer[2];
+ version[0] = versionList.get(0).intValue();
+ version[1] = versionList.get(1).intValue();
+ }
+ value = new DocumentStartEvent(null, null, false, version, tags);
+ } else if (className.equals("MappingEndEvent")) {
+ value = new MappingEndEvent(null, null);
+ } else if (className.equals("SequenceEndEvent")) {
+ value = new SequenceEndEvent(null, null);
+ } else if (className.equals("StreamEndEvent")) {
+ value = new StreamEndEvent(null, null);
+ } else if (className.equals("StreamStartEvent")) {
+ value = new StreamStartEvent(null, null);
+ } else {
+ throw new UnsupportedOperationException();
+ }
+ return value;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/emitter/template/MyBean.java b/src/test/java/org/yaml/snakeyaml/emitter/template/MyBean.java
index e84db7d..518572a 100644
--- a/src/test/java/org/yaml/snakeyaml/emitter/template/MyBean.java
+++ b/src/test/java/org/yaml/snakeyaml/emitter/template/MyBean.java
@@ -1,94 +1,94 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter.template;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.yaml.snakeyaml.immutable.Point;
-
-public class MyBean {
- private Point point;
- private List<String> list;
- private List<Integer> empty = new ArrayList<Integer>();
- private String id;
-
- public Point getPoint() {
- return point;
- }
-
- public void setPoint(Point point) {
- this.point = point;
- }
-
- public List<String> getList() {
- return list;
- }
-
- public void setList(List<String> list) {
- this.list = list;
- }
-
- public List<Integer> getEmpty() {
- return empty;
- }
-
- public void setEmpty(List<Integer> empty) {
- this.empty = empty;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MyBean) {
- MyBean bean = (MyBean) obj;
- if (!id.equals(bean.id)) {
- return false;
- }
- if (!point.equals(bean.point)) {
- return false;
- }
- if (!list.equals(bean.list)) {
- return false;
- }
- if (!empty.equals(bean.empty)) {
- return false;
- }
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- @Override
- public String toString() {
- return id;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter.template;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.yaml.snakeyaml.immutable.Point;
+
+public class MyBean {
+ private Point point;
+ private List<String> list;
+ private List<Integer> empty = new ArrayList<Integer>();
+ private String id;
+
+ public Point getPoint() {
+ return point;
+ }
+
+ public void setPoint(Point point) {
+ this.point = point;
+ }
+
+ public List<String> getList() {
+ return list;
+ }
+
+ public void setList(List<String> list) {
+ this.list = list;
+ }
+
+ public List<Integer> getEmpty() {
+ return empty;
+ }
+
+ public void setEmpty(List<Integer> empty) {
+ this.empty = empty;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof MyBean) {
+ MyBean bean = (MyBean) obj;
+ if (!id.equals(bean.id)) {
+ return false;
+ }
+ if (!point.equals(bean.point)) {
+ return false;
+ }
+ if (!list.equals(bean.list)) {
+ return false;
+ }
+ if (!empty.equals(bean.empty)) {
+ return false;
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return id;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/emitter/template/VelocityTest.java b/src/test/java/org/yaml/snakeyaml/emitter/template/VelocityTest.java
index 252aa57..103cb5d 100644
--- a/src/test/java/org/yaml/snakeyaml/emitter/template/VelocityTest.java
+++ b/src/test/java/org/yaml/snakeyaml/emitter/template/VelocityTest.java
@@ -1,79 +1,79 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.emitter.template;
-
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.immutable.Point;
-
-public class VelocityTest extends TestCase {
- public void testNoTemplate() {
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- String output = yaml.dumpAsMap(createBean());
- // System.out.println(output);
- assertEquals(Util.getLocalResource("template/etalon1.yaml"), output);
- }
-
- public void testTemplate1() throws Exception {
- VelocityContext context = new VelocityContext();
- MyBean bean = createBean();
- context.put("bean", bean);
- Yaml yaml = new Yaml();
- context.put("list", yaml.dump(bean.getList()));
- VelocityEngine ve = new VelocityEngine();
- ve.setProperty("file.resource.loader.class", ClasspathResourceLoader.class.getName());
- ve.init();
- Template t = ve.getTemplate("template/mybean1.vm");
- StringWriter writer = new StringWriter();
- t.merge(context, writer);
- String output = writer.toString().trim().replaceAll("\\r\\n", "\n");
- // System.out.println(output);
- String etalon = Util.getLocalResource("template/etalon2-template.yaml").trim();
- assertEquals(etalon.length(), output.length());
- assertEquals(etalon, output);
- // parse the YAML document
- Yaml loader = new Yaml();
- MyBean parsedBean = loader.loadAs(output, MyBean.class);
- assertEquals(bean, parsedBean);
- }
-
- private MyBean createBean() {
- MyBean bean = new MyBean();
- bean.setId("id123");
- List<String> list = new ArrayList<String>();
- list.add("aaa");
- list.add("bbb");
- list.add("ccc");
- bean.setList(list);
- Point p = new Point(1.0, 2.0);
- bean.setPoint(p);
- return bean;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.emitter.template;
+
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.immutable.Point;
+
+public class VelocityTest extends TestCase {
+ public void testNoTemplate() {
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dumpAsMap(createBean());
+ // System.out.println(output);
+ assertEquals(Util.getLocalResource("template/etalon1.yaml"), output);
+ }
+
+ public void testTemplate1() throws Exception {
+ VelocityContext context = new VelocityContext();
+ MyBean bean = createBean();
+ context.put("bean", bean);
+ Yaml yaml = new Yaml();
+ context.put("list", yaml.dump(bean.getList()));
+ VelocityEngine ve = new VelocityEngine();
+ ve.setProperty("file.resource.loader.class", ClasspathResourceLoader.class.getName());
+ ve.init();
+ Template t = ve.getTemplate("template/mybean1.vm");
+ StringWriter writer = new StringWriter();
+ t.merge(context, writer);
+ String output = writer.toString().trim().replaceAll("\\r\\n", "\n");
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("template/etalon2-template.yaml").trim();
+ assertEquals(etalon.length(), output.length());
+ assertEquals(etalon, output);
+ // parse the YAML document
+ Yaml loader = new Yaml();
+ MyBean parsedBean = loader.loadAs(output, MyBean.class);
+ assertEquals(bean, parsedBean);
+ }
+
+ private MyBean createBean() {
+ MyBean bean = new MyBean();
+ bean.setId("id123");
+ List<String> list = new ArrayList<String>();
+ list.add("aaa");
+ list.add("bbb");
+ list.add("ccc");
+ bean.setList(list);
+ Point p = new Point(1.0, 2.0);
+ bean.setPoint(p);
+ return bean;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/error/MarkTest.java b/src/test/java/org/yaml/snakeyaml/error/MarkTest.java
index 03216e8..faf43cd 100644
--- a/src/test/java/org/yaml/snakeyaml/error/MarkTest.java
+++ b/src/test/java/org/yaml/snakeyaml/error/MarkTest.java
@@ -1,44 +1,44 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.error;
-
-import junit.framework.TestCase;
-
-public class MarkTest extends TestCase {
-
- public void testGet_snippet() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- assertEquals(" *The first line.\n ^", mark.get_snippet());
- mark = new Mark("test1", 9, 0, 0, "The first*line.\nThe last line.", 9);
- assertEquals(" The first*line.\n ^", mark.get_snippet());
- }
-
- public void testToString() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- String[] lines = mark.toString().split("\n");
- assertEquals(" in \"test1\", line 1, column 1:", lines[0]);
- assertEquals("*The first line.", lines[1].trim());
- assertEquals("^", lines[2].trim());
- }
-
- public void testPosition() {
- Mark mark = new Mark("test1", 17, 29, 213, "*The first line.\nThe last line.", 0);
- assertEquals(17, mark.getIndex());
- assertEquals(29, mark.getLine());
- assertEquals(213, mark.getColumn());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.error;
+
+import junit.framework.TestCase;
+
+public class MarkTest extends TestCase {
+
+ public void testGet_snippet() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ assertEquals(" *The first line.\n ^", mark.get_snippet());
+ mark = new Mark("test1", 9, 0, 0, "The first*line.\nThe last line.", 9);
+ assertEquals(" The first*line.\n ^", mark.get_snippet());
+ }
+
+ public void testToString() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ String[] lines = mark.toString().split("\n");
+ assertEquals(" in \"test1\", line 1, column 1:", lines[0]);
+ assertEquals("*The first line.", lines[1].trim());
+ assertEquals("^", lines[2].trim());
+ }
+
+ public void testPosition() {
+ Mark mark = new Mark("test1", 17, 29, 213, "*The first line.\nThe last line.", 0);
+ assertEquals(17, mark.getIndex());
+ assertEquals(29, mark.getLine());
+ assertEquals(213, mark.getColumn());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/error/MarkedYAMLExceptionTest.java b/src/test/java/org/yaml/snakeyaml/error/MarkedYAMLExceptionTest.java
index 5a2323a..6a7b244 100644
--- a/src/test/java/org/yaml/snakeyaml/error/MarkedYAMLExceptionTest.java
+++ b/src/test/java/org/yaml/snakeyaml/error/MarkedYAMLExceptionTest.java
@@ -1,62 +1,62 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.error;
-
-import junit.framework.TestCase;
-
-public class MarkedYAMLExceptionTest extends TestCase {
-
- public void testToString1() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- MarkedYAMLException exception = new MarkedYAMLException(null, null, "Error happened", mark);
- assertTrue(exception.toString().contains("Error happened"));
- assertTrue(exception.toString().contains("The first line"));
- assertTrue(exception.toString().contains("\"test1\""));
- }
-
- public void testToString2() {
- Mark mark = new Mark("search", 0, 0, 0, "*The first line.\nThe last line.", 0);
- MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", mark,
- "Error2 happened", mark);
- assertTrue(exception.toString().contains("Error2 happened"));
- assertTrue(exception.toString().contains("The first line"));
- assertTrue(exception.toString().contains("\"search\""));
- }
-
- public void testToString3() {
- MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", null,
- null, null, "Note1");
- assertTrue(exception.toString().contains("Note1"));
- }
-
- public void testToString4() {
- Mark mark = new Mark("search", 0, 0, 0, "*The first line.\nThe last line.", 0);
- MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", mark,
- null, null, null, null);
- assertTrue(exception.toString().contains("first line"));
- }
-
- public void testGetters() {
- Mark mark = new Mark("search", 0, 0, 0, "*The first line.\nThe last line.", 0);
- MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", mark,
- "Error2 happened", mark);
- assertEquals("See http://www.google.com", exception.getContext());
- assertEquals(mark, exception.getContextMark());
- assertEquals("Error2 happened", exception.getProblem());
- assertEquals(mark, exception.getProblemMark());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.error;
+
+import junit.framework.TestCase;
+
+public class MarkedYAMLExceptionTest extends TestCase {
+
+ public void testToString1() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ MarkedYAMLException exception = new MarkedYAMLException(null, null, "Error happened", mark);
+ assertTrue(exception.toString().contains("Error happened"));
+ assertTrue(exception.toString().contains("The first line"));
+ assertTrue(exception.toString().contains("\"test1\""));
+ }
+
+ public void testToString2() {
+ Mark mark = new Mark("search", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", mark,
+ "Error2 happened", mark);
+ assertTrue(exception.toString().contains("Error2 happened"));
+ assertTrue(exception.toString().contains("The first line"));
+ assertTrue(exception.toString().contains("\"search\""));
+ }
+
+ public void testToString3() {
+ MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", null,
+ null, null, "Note1");
+ assertTrue(exception.toString().contains("Note1"));
+ }
+
+ public void testToString4() {
+ Mark mark = new Mark("search", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", mark,
+ null, null, null, null);
+ assertTrue(exception.toString().contains("first line"));
+ }
+
+ public void testGetters() {
+ Mark mark = new Mark("search", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ MarkedYAMLException exception = new MarkedYAMLException("See http://www.google.com", mark,
+ "Error2 happened", mark);
+ assertEquals("See http://www.google.com", exception.getContext());
+ assertEquals(mark, exception.getContextMark());
+ assertEquals("Error2 happened", exception.getProblem());
+ assertEquals(mark, exception.getProblemMark());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/events/ScalarEventTest.java b/src/test/java/org/yaml/snakeyaml/events/ScalarEventTest.java
index 276dd28..83bfd3e 100644
--- a/src/test/java/org/yaml/snakeyaml/events/ScalarEventTest.java
+++ b/src/test/java/org/yaml/snakeyaml/events/ScalarEventTest.java
@@ -1,36 +1,36 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.events;
-
-import junit.framework.TestCase;
-
-public class ScalarEventTest extends TestCase {
-
- public void testToString() {
- ScalarEvent event = new ScalarEvent("a2", "str", new ImplicitTuple(true, true), "text",
- null, null, '"');
- assertEquals(
- "<org.yaml.snakeyaml.events.ScalarEvent(anchor=a2, tag=str, implicit=[true, true], value=text)>",
- event.toString());
- }
-
- public void testNotEqual() {
- ScalarEvent event = new ScalarEvent("a2", "str", new ImplicitTuple(true, true), "text",
- null, null, '"');
- assertFalse(event.equals(event.toString()));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.events;
+
+import junit.framework.TestCase;
+
+public class ScalarEventTest extends TestCase {
+
+ public void testToString() {
+ ScalarEvent event = new ScalarEvent("a2", "str", new ImplicitTuple(true, true), "text",
+ null, null, '"');
+ assertEquals(
+ "<org.yaml.snakeyaml.events.ScalarEvent(anchor=a2, tag=str, implicit=[true, true], value=text)>",
+ event.toString());
+ }
+
+ public void testNotEqual() {
+ ScalarEvent event = new ScalarEvent("a2", "str", new ImplicitTuple(true, true), "text",
+ null, null, '"');
+ assertFalse(event.equals(event.toString()));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Box.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Box.java
index 91382e5..ba0233e 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Box.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Box.java
@@ -1,54 +1,54 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-public class Box {
- private String id;
- private String name;
- private Item top;
- private Item bottom;
-
- public Box(String id, String name) {
- super();
- this.id = id;
- this.name = name;
- }
-
- public Item getTop() {
- return top;
- }
-
- public void setTop(Item top) {
- this.top = top;
- }
-
- public Item getBottom() {
- return bottom;
- }
-
- public void setBottom(Item bottom) {
- this.bottom = bottom;
- }
-
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+public class Box {
+ private String id;
+ private String name;
+ private Item top;
+ private Item bottom;
+
+ public Box(String id, String name) {
+ super();
+ this.id = id;
+ this.name = name;
+ }
+
+ public Item getTop() {
+ return top;
+ }
+
+ public void setTop(Item top) {
+ this.top = top;
+ }
+
+ public Item getBottom() {
+ return bottom;
+ }
+
+ public void setBottom(Item bottom) {
+ this.bottom = bottom;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorErrorsTest.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorErrorsTest.java
index 19c8d43..4263ac8 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorErrorsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorErrorsTest.java
@@ -1,131 +1,131 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.BaseConstructor;
-
-public class CompactConstructorErrorsTest extends TestCase {
-
- public void test1() {
- BaseConstructor compact = new CompactConstructor();
- Yaml yaml = new Yaml(compact);
- String doc = Util.getLocalResource("compactnotation/error1.yaml");
- try {
- yaml.load(doc);
- fail("Package is not specified.");
- } catch (Exception e) {
- assertEquals("java.lang.ClassNotFoundException: Table", e.getMessage());
- }
- }
-
- private Object load(String fileName) {
- CompactConstructor compact = new PackageCompactConstructor(
- "org.yaml.snakeyaml.extensions.compactnotation");
- Yaml yaml = new Yaml(compact);
- String doc = Util.getLocalResource("compactnotation/" + fileName);
- Object obj = yaml.load(doc);
- assertNotNull(obj);
- return obj;
- }
-
- private void failLoad(String fileName, String failure) {
- load(fileName);
- fail(failure);
- }
-
- private void check(String fileName, String failure, String message) {
- try {
- failLoad(fileName, failure);
- } catch (Exception e) {
- assertEquals(message, e.getMessage());
- }
- }
-
- public void test2() {
- check("error2.yaml",
- "No single argument constructor provided.",
- "java.lang.NoSuchMethodException: org.yaml.snakeyaml.extensions.compactnotation.Table.<init>(java.lang.String)");
- }
-
- public void test3() {
- check("error3.yaml",
- "In-line parameters can only be Strings.",
- "org.yaml.snakeyaml.error.YAMLException: Cannot set property='size' with value='17' (class java.lang.String) in Row id=id111");
- }
-
- /**
- * Created Map instead of Row
- */
- @SuppressWarnings("unchecked")
- public void test4() {
- Table table = (Table) load("error4.yaml");
- List<Row> rows = table.getRows();
- assertEquals(1, rows.size());
- assertFalse("Row should not be created.", rows.get(0) instanceof Row);
- Map<String, String> map = (Map<String, String>) rows.get(0);
- assertEquals(1, map.size());
- assertEquals("15}", map.get("Row(id111, description = text) {size"));
- }
-
- /**
- * Wrong indent
- */
- @SuppressWarnings("unchecked")
- public void test5() {
- Table table = (Table) load("error5.yaml");
- List<Row> rows = table.getRows();
- assertEquals(1, rows.size());
- assertFalse("Row should not be created.", rows.get(0) instanceof Row);
- Map<String, String> map = (Map<String, String>) rows.get(0);
- assertEquals(4, map.size());
- // System.out.println(map);
- assertNull(map.get(new Row("id222")));
- assertTrue(map.containsKey(new Row("id222")));
- assertEquals(17, map.get("size"));
- }
-
- public void test6() {
- check("error6.yaml",
- "Invalid property.",
- "org.yaml.snakeyaml.error.YAMLException: Unable to find property 'foo' on class: org.yaml.snakeyaml.extensions.compactnotation.Table");
- }
-
- public void test7() {
- check("error7.yaml",
- "Invalid property.",
- "org.yaml.snakeyaml.error.YAMLException: Unable to find property 'foo' on class: org.yaml.snakeyaml.extensions.compactnotation.Table");
- }
-
- public void test8() {
- check("error8.yaml",
- "No list property",
- "org.yaml.snakeyaml.error.YAMLException: No list property found in class org.yaml.snakeyaml.extensions.compactnotation.Row");
- }
-
- public void test9() {
- check("error9.yaml",
- "Many list properties found",
- "org.yaml.snakeyaml.error.YAMLException: Many list properties found in class org.yaml.snakeyaml.extensions.compactnotation.ManyListsTable; Please override getSequencePropertyName() to specify which property to use.");
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.BaseConstructor;
+
+public class CompactConstructorErrorsTest extends TestCase {
+
+ public void test1() {
+ BaseConstructor compact = new CompactConstructor();
+ Yaml yaml = new Yaml(compact);
+ String doc = Util.getLocalResource("compactnotation/error1.yaml");
+ try {
+ yaml.load(doc);
+ fail("Package is not specified.");
+ } catch (Exception e) {
+ assertEquals("java.lang.ClassNotFoundException: Table", e.getMessage());
+ }
+ }
+
+ private Object load(String fileName) {
+ CompactConstructor compact = new PackageCompactConstructor(
+ "org.yaml.snakeyaml.extensions.compactnotation");
+ Yaml yaml = new Yaml(compact);
+ String doc = Util.getLocalResource("compactnotation/" + fileName);
+ Object obj = yaml.load(doc);
+ assertNotNull(obj);
+ return obj;
+ }
+
+ private void failLoad(String fileName, String failure) {
+ load(fileName);
+ fail(failure);
+ }
+
+ private void check(String fileName, String failure, String message) {
+ try {
+ failLoad(fileName, failure);
+ } catch (Exception e) {
+ assertEquals(message, e.getMessage());
+ }
+ }
+
+ public void test2() {
+ check("error2.yaml",
+ "No single argument constructor provided.",
+ "java.lang.NoSuchMethodException: org.yaml.snakeyaml.extensions.compactnotation.Table.<init>(java.lang.String)");
+ }
+
+ public void test3() {
+ check("error3.yaml",
+ "In-line parameters can only be Strings.",
+ "org.yaml.snakeyaml.error.YAMLException: Cannot set property='size' with value='17' (class java.lang.String) in Row id=id111");
+ }
+
+ /**
+ * Created Map instead of Row
+ */
+ @SuppressWarnings("unchecked")
+ public void test4() {
+ Table table = (Table) load("error4.yaml");
+ List<Row> rows = table.getRows();
+ assertEquals(1, rows.size());
+ assertFalse("Row should not be created.", rows.get(0) instanceof Row);
+ Map<String, String> map = (Map<String, String>) rows.get(0);
+ assertEquals(1, map.size());
+ assertEquals("15}", map.get("Row(id111, description = text) {size"));
+ }
+
+ /**
+ * Wrong indent
+ */
+ @SuppressWarnings("unchecked")
+ public void test5() {
+ Table table = (Table) load("error5.yaml");
+ List<Row> rows = table.getRows();
+ assertEquals(1, rows.size());
+ assertFalse("Row should not be created.", rows.get(0) instanceof Row);
+ Map<String, String> map = (Map<String, String>) rows.get(0);
+ assertEquals(4, map.size());
+ // System.out.println(map);
+ assertNull(map.get(new Row("id222")));
+ assertTrue(map.containsKey(new Row("id222")));
+ assertEquals(17, map.get("size"));
+ }
+
+ public void test6() {
+ check("error6.yaml",
+ "Invalid property.",
+ "org.yaml.snakeyaml.error.YAMLException: Unable to find property 'foo' on class: org.yaml.snakeyaml.extensions.compactnotation.Table");
+ }
+
+ public void test7() {
+ check("error7.yaml",
+ "Invalid property.",
+ "org.yaml.snakeyaml.error.YAMLException: Unable to find property 'foo' on class: org.yaml.snakeyaml.extensions.compactnotation.Table");
+ }
+
+ public void test8() {
+ check("error8.yaml",
+ "No list property",
+ "org.yaml.snakeyaml.error.YAMLException: No list property found in class org.yaml.snakeyaml.extensions.compactnotation.Row");
+ }
+
+ public void test9() {
+ check("error9.yaml",
+ "Many list properties found",
+ "org.yaml.snakeyaml.error.YAMLException: Many list properties found in class org.yaml.snakeyaml.extensions.compactnotation.ManyListsTable; Please override getSequencePropertyName() to specify which property to use.");
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java
index 3fad3e4..0026cc5 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorExampleTest.java
@@ -1,181 +1,181 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class CompactConstructorExampleTest extends TestCase {
-
- private Object load(String fileName) {
- CompactConstructor compact = new CompactConstructor();
- Yaml yaml = new Yaml(compact);
- String doc = Util.getLocalResource("compactnotation/" + fileName);
- Object obj = yaml.load(doc);
- assertNotNull(obj);
- return obj;
- }
-
- public void test1() {
- Object obj = load("example1.yaml");
- assertEquals(new Container(), obj);
- }
-
- public void test2() {
- Object obj = load("example2.yaml");
- assertEquals(new Container("title"), obj);
- }
-
- public void test3() {
- Container obj = (Container) load("example3.yaml");
- assertEquals(new Container("title3"), obj);
- assertEquals("title3", obj.getTitle());
- assertEquals("parent", obj.getName());
- assertEquals("123", obj.getId());
- }
-
- public void test4() {
- Object obj = load("example4.yaml");
- // System.out.println(obj);
- Container container = (Container) obj;
- assertNotNull(obj);
- assertEquals(new Container("title4"), obj);
- assertEquals("title4", container.getTitle());
- assertEquals("child4", container.getName());
- assertEquals("444", container.getId());
- }
-
- public void test5() {
- Object obj = load("example5.yaml");
- // System.out.println(obj);
- Container container = (Container) obj;
- assertNotNull(obj);
- assertEquals(new Container("title4"), obj);
- assertEquals("title4", container.getTitle());
- assertEquals("child5", container.getName());
- assertEquals("ID555", container.getId());
- }
-
- public void test6() {
- Object obj = load("example6.yaml");
- // System.out.println(obj);
- Container container = (Container) obj;
- assertNotNull(obj);
- assertEquals(new Container("title4"), obj);
- assertEquals("title4", container.getTitle());
- assertEquals("child6", container.getName());
- assertEquals("ID6", container.getId());
- }
-
- public void test7() {
- Object obj = load("example7.yaml");
- // System.out.println(obj);
- Container container = (Container) obj;
- assertNotNull(obj);
- assertEquals(new Container("The title"), obj);
- assertEquals("The title", container.getTitle());
- assertEquals("child7", container.getName());
- assertEquals("id7", container.getId());
- }
-
- @SuppressWarnings("unchecked")
- // TODO it is unclear how the result should look like for CON
- public void test9() {
- Map<String, Object> map = (Map<String, Object>) load("example9.yaml");
- assertEquals(1, map.size());
- Map<Container, Map<String, String>> containers = (Map<Container, Map<String, String>>) map
- .get("something");
- // System.out.println(obj);
- assertEquals(2, containers.size());
- for (Container c : containers.keySet()) {
- assertTrue(c.getId().matches("id\\d"));
- assertEquals(1, containers.get(c).size());
- }
- }
-
- @SuppressWarnings("unchecked")
- public void test10() {
- Map<String, Object> map = (Map<String, Object>) load("example10.yaml");
- assertEquals(1, map.size());
- List<Container> containers = (List<Container>) map.get("something");
- // System.out.println(obj);
- assertEquals(3, containers.size());
- for (Container c : containers) {
- assertTrue(c.toString(), c.getId().matches("id\\d+"));
- assertTrue(c.toString(), c.getName().matches("child\\d+"));
- // System.out.println(c);
- }
- }
-
- public void test11withoutPackageNames() {
- Constructor compact = new PackageCompactConstructor(
- "org.yaml.snakeyaml.extensions.compactnotation");
- Yaml yaml = new Yaml(compact);
- String doc = Util.getLocalResource("compactnotation/example11.yaml");
- Box box = (Box) yaml.load(doc);
- assertNotNull(box);
- assertEquals("id11", box.getId());
- assertEquals("Main box", box.getName());
- Item top = box.getTop();
- assertEquals("id003", top.getId());
- assertEquals("25.0", top.getPrice());
- assertEquals("parrot", top.getName());
- Item bottom = box.getBottom();
- assertEquals("id004", bottom.getId());
- assertEquals("3.5", bottom.getPrice());
- assertEquals("sweet", bottom.getName());
- }
-
- public void test12withList() {
- Constructor compact = new TableCompactConstructor(
- "org.yaml.snakeyaml.extensions.compactnotation");
- Yaml yaml = new Yaml(compact);
- String doc = Util.getLocalResource("compactnotation/example12.yaml");
- Table table = (Table) yaml.load(doc);
- assertNotNull(table);
- assertEquals("id12", table.getId());
- assertEquals("A table", table.getName());
- List<Row> rows = table.getRows();
- assertEquals(3, rows.size());
- Iterator<Row> iter = rows.iterator();
- Row first = iter.next();
- assertEquals("id111", first.getId());
- assertEquals("I think; therefore I am.", first.getDescription());
- assertEquals(0.125, first.getRatio(), 0.000000001);
- assertEquals(15, first.getSize());
- Row second = iter.next();
- assertEquals("id222", second.getId());
- assertEquals("We do not need new lines here, just replace them all with spaces\n",
- second.getDescription());
- assertEquals(0.333, second.getRatio(), 0.000000001);
- assertEquals(17, second.getSize());
- Row third = iter.next();
- assertEquals("id333", third.getId());
- assertEquals(
- "Please preserve all\nthe lines because they may be\nimportant, but do not include the last one !!!",
- third.getDescription());
- assertEquals(0.88, third.getRatio(), 0.000000001);
- assertEquals(52, third.getSize());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class CompactConstructorExampleTest extends TestCase {
+
+ private Object load(String fileName) {
+ CompactConstructor compact = new CompactConstructor();
+ Yaml yaml = new Yaml(compact);
+ String doc = Util.getLocalResource("compactnotation/" + fileName);
+ Object obj = yaml.load(doc);
+ assertNotNull(obj);
+ return obj;
+ }
+
+ public void test1() {
+ Object obj = load("example1.yaml");
+ assertEquals(new Container(), obj);
+ }
+
+ public void test2() {
+ Object obj = load("example2.yaml");
+ assertEquals(new Container("title"), obj);
+ }
+
+ public void test3() {
+ Container obj = (Container) load("example3.yaml");
+ assertEquals(new Container("title3"), obj);
+ assertEquals("title3", obj.getTitle());
+ assertEquals("parent", obj.getName());
+ assertEquals("123", obj.getId());
+ }
+
+ public void test4() {
+ Object obj = load("example4.yaml");
+ // System.out.println(obj);
+ Container container = (Container) obj;
+ assertNotNull(obj);
+ assertEquals(new Container("title4"), obj);
+ assertEquals("title4", container.getTitle());
+ assertEquals("child4", container.getName());
+ assertEquals("444", container.getId());
+ }
+
+ public void test5() {
+ Object obj = load("example5.yaml");
+ // System.out.println(obj);
+ Container container = (Container) obj;
+ assertNotNull(obj);
+ assertEquals(new Container("title4"), obj);
+ assertEquals("title4", container.getTitle());
+ assertEquals("child5", container.getName());
+ assertEquals("ID555", container.getId());
+ }
+
+ public void test6() {
+ Object obj = load("example6.yaml");
+ // System.out.println(obj);
+ Container container = (Container) obj;
+ assertNotNull(obj);
+ assertEquals(new Container("title4"), obj);
+ assertEquals("title4", container.getTitle());
+ assertEquals("child6", container.getName());
+ assertEquals("ID6", container.getId());
+ }
+
+ public void test7() {
+ Object obj = load("example7.yaml");
+ // System.out.println(obj);
+ Container container = (Container) obj;
+ assertNotNull(obj);
+ assertEquals(new Container("The title"), obj);
+ assertEquals("The title", container.getTitle());
+ assertEquals("child7", container.getName());
+ assertEquals("id7", container.getId());
+ }
+
+ @SuppressWarnings("unchecked")
+ // TODO it is unclear how the result should look like for CON
+ public void test9() {
+ Map<String, Object> map = (Map<String, Object>) load("example9.yaml");
+ assertEquals(1, map.size());
+ Map<Container, Map<String, String>> containers = (Map<Container, Map<String, String>>) map
+ .get("something");
+ // System.out.println(obj);
+ assertEquals(2, containers.size());
+ for (Container c : containers.keySet()) {
+ assertTrue(c.getId().matches("id\\d"));
+ assertEquals(1, containers.get(c).size());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void test10() {
+ Map<String, Object> map = (Map<String, Object>) load("example10.yaml");
+ assertEquals(1, map.size());
+ List<Container> containers = (List<Container>) map.get("something");
+ // System.out.println(obj);
+ assertEquals(3, containers.size());
+ for (Container c : containers) {
+ assertTrue(c.toString(), c.getId().matches("id\\d+"));
+ assertTrue(c.toString(), c.getName().matches("child\\d+"));
+ // System.out.println(c);
+ }
+ }
+
+ public void test11withoutPackageNames() {
+ Constructor compact = new PackageCompactConstructor(
+ "org.yaml.snakeyaml.extensions.compactnotation");
+ Yaml yaml = new Yaml(compact);
+ String doc = Util.getLocalResource("compactnotation/example11.yaml");
+ Box box = (Box) yaml.load(doc);
+ assertNotNull(box);
+ assertEquals("id11", box.getId());
+ assertEquals("Main box", box.getName());
+ Item top = box.getTop();
+ assertEquals("id003", top.getId());
+ assertEquals("25.0", top.getPrice());
+ assertEquals("parrot", top.getName());
+ Item bottom = box.getBottom();
+ assertEquals("id004", bottom.getId());
+ assertEquals("3.5", bottom.getPrice());
+ assertEquals("sweet", bottom.getName());
+ }
+
+ public void test12withList() {
+ Constructor compact = new TableCompactConstructor(
+ "org.yaml.snakeyaml.extensions.compactnotation");
+ Yaml yaml = new Yaml(compact);
+ String doc = Util.getLocalResource("compactnotation/example12.yaml");
+ Table table = (Table) yaml.load(doc);
+ assertNotNull(table);
+ assertEquals("id12", table.getId());
+ assertEquals("A table", table.getName());
+ List<Row> rows = table.getRows();
+ assertEquals(3, rows.size());
+ Iterator<Row> iter = rows.iterator();
+ Row first = iter.next();
+ assertEquals("id111", first.getId());
+ assertEquals("I think; therefore I am.", first.getDescription());
+ assertEquals(0.125, first.getRatio(), 0.000000001);
+ assertEquals(15, first.getSize());
+ Row second = iter.next();
+ assertEquals("id222", second.getId());
+ assertEquals("We do not need new lines here, just replace them all with spaces\n",
+ second.getDescription());
+ assertEquals(0.333, second.getRatio(), 0.000000001);
+ assertEquals(17, second.getSize());
+ Row third = iter.next();
+ assertEquals("id333", third.getId());
+ assertEquals(
+ "Please preserve all\nthe lines because they may be\nimportant, but do not include the last one !!!",
+ third.getDescription());
+ assertEquals(0.88, third.getRatio(), 0.000000001);
+ assertEquals(52, third.getSize());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorTest.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorTest.java
index e27a50e..16a3a49 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/CompactConstructorTest.java
@@ -1,113 +1,113 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-import junit.framework.TestCase;
-
-public class CompactConstructorTest extends TestCase {
-
- public void testNoCompactData() {
- CompactConstructor flow = new CompactConstructor();
- assertNull(flow.getCompactData("scalar"));
- assertNull(flow.getCompactData("123"));
- assertNull(flow.getCompactData("(name=frame,title=My Frame)"));
- assertNull(flow.getCompactData("JFrame name=frame,title=My Frame)"));
- assertNull(flow.getCompactData("JFrame name=frame,title=My Frame"));
- assertNull(flow.getCompactData("JFrame(name=frame,title=My Frame"));
- assertNull(flow.getCompactData("JFrame(name=frame,title=My Frame)b"));
- assertNull(flow.getCompactData("JFrame(name=frame,title=My Frame) "));
- assertNull(flow.getCompactData("JFrame(name=)"));
- assertNull(flow.getCompactData("JFrame(=name)"));
- }
-
- public void testGetCompactData1() {
- CompactConstructor flow = new CompactConstructor();
- CompactData data = flow.getCompactData("JFrame(name=frame)");
- assertNotNull(data);
- assertEquals("JFrame", data.getPrefix());
- assertEquals(1, data.getProperties().size());
- assertEquals("frame", data.getProperties().get("name"));
- }
-
- public void testGetCompactData2() {
- CompactConstructor flow = new CompactConstructor();
- CompactData data = flow.getCompactData("Frame(name=frame,title=My Frame)");
- assertNotNull(data);
- assertEquals("Frame", data.getPrefix());
- assertEquals(2, data.getProperties().size());
- assertEquals("frame", data.getProperties().get("name"));
- assertEquals("My Frame", data.getProperties().get("title"));
-
- assertNotNull(flow.getCompactData("JFrame ( name = frame , title = My Frame )"));
- }
-
- public void testGetCompactData3() {
- CompactConstructor flow = new CompactConstructor();
- CompactData data = flow
- .getCompactData("JFrame ( name = frame , title = My Frame, number= 123 )");
- assertNotNull(data);
- assertEquals("JFrame", data.getPrefix());
- assertEquals(3, data.getProperties().size());
- assertEquals("frame", data.getProperties().get("name"));
- assertEquals("My Frame", data.getProperties().get("title"));
- assertEquals("123", data.getProperties().get("number"));
- }
-
- public void testGetCompactData4() {
- CompactConstructor flow = new CompactConstructor();
- CompactData data = flow.getCompactData("JFrame(title)");
- assertNotNull(data);
- assertEquals("JFrame", data.getPrefix());
- assertEquals(0, data.getProperties().size());
- assertEquals(1, data.getArguments().size());
- assertEquals("title", data.getArguments().get(0));
- }
-
- public void testGetCompactData5() {
- CompactConstructor flow = new CompactConstructor();
- CompactData data = flow.getCompactData("JFrame(id123, title, name=foo, alignment=center)");
- assertNotNull(data);
- assertEquals("JFrame", data.getPrefix());
- assertEquals(2, data.getProperties().size());
- assertEquals(2, data.getArguments().size());
- assertEquals("id123", data.getArguments().get(0));
- assertEquals("title", data.getArguments().get(1));
- }
-
- public void testGetCompactData6() {
- CompactConstructor flow = new CompactConstructor();
- CompactData data = flow.getCompactData("JFrame()");
- assertNotNull(data);
- assertEquals("JFrame", data.getPrefix());
- assertEquals(0, data.getProperties().size());
- assertEquals(0, data.getArguments().size());
- }
-
- public void testGetCompactData7() {
- CompactConstructor flow = new CompactConstructor();
- CompactData data = flow.getCompactData("package.Container(name=parent, id=123)");
- assertNotNull(data);
- assertEquals("package.Container", data.getPrefix());
- assertEquals(2, data.getProperties().size());
- assertEquals(0, data.getArguments().size());
- }
-
- public void testCompactDataToString() {
- CompactData data = new CompactData("foo");
- assertEquals("CompactData: foo {}", data.toString());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+import junit.framework.TestCase;
+
+public class CompactConstructorTest extends TestCase {
+
+ public void testNoCompactData() {
+ CompactConstructor flow = new CompactConstructor();
+ assertNull(flow.getCompactData("scalar"));
+ assertNull(flow.getCompactData("123"));
+ assertNull(flow.getCompactData("(name=frame,title=My Frame)"));
+ assertNull(flow.getCompactData("JFrame name=frame,title=My Frame)"));
+ assertNull(flow.getCompactData("JFrame name=frame,title=My Frame"));
+ assertNull(flow.getCompactData("JFrame(name=frame,title=My Frame"));
+ assertNull(flow.getCompactData("JFrame(name=frame,title=My Frame)b"));
+ assertNull(flow.getCompactData("JFrame(name=frame,title=My Frame) "));
+ assertNull(flow.getCompactData("JFrame(name=)"));
+ assertNull(flow.getCompactData("JFrame(=name)"));
+ }
+
+ public void testGetCompactData1() {
+ CompactConstructor flow = new CompactConstructor();
+ CompactData data = flow.getCompactData("JFrame(name=frame)");
+ assertNotNull(data);
+ assertEquals("JFrame", data.getPrefix());
+ assertEquals(1, data.getProperties().size());
+ assertEquals("frame", data.getProperties().get("name"));
+ }
+
+ public void testGetCompactData2() {
+ CompactConstructor flow = new CompactConstructor();
+ CompactData data = flow.getCompactData("Frame(name=frame,title=My Frame)");
+ assertNotNull(data);
+ assertEquals("Frame", data.getPrefix());
+ assertEquals(2, data.getProperties().size());
+ assertEquals("frame", data.getProperties().get("name"));
+ assertEquals("My Frame", data.getProperties().get("title"));
+
+ assertNotNull(flow.getCompactData("JFrame ( name = frame , title = My Frame )"));
+ }
+
+ public void testGetCompactData3() {
+ CompactConstructor flow = new CompactConstructor();
+ CompactData data = flow
+ .getCompactData("JFrame ( name = frame , title = My Frame, number= 123 )");
+ assertNotNull(data);
+ assertEquals("JFrame", data.getPrefix());
+ assertEquals(3, data.getProperties().size());
+ assertEquals("frame", data.getProperties().get("name"));
+ assertEquals("My Frame", data.getProperties().get("title"));
+ assertEquals("123", data.getProperties().get("number"));
+ }
+
+ public void testGetCompactData4() {
+ CompactConstructor flow = new CompactConstructor();
+ CompactData data = flow.getCompactData("JFrame(title)");
+ assertNotNull(data);
+ assertEquals("JFrame", data.getPrefix());
+ assertEquals(0, data.getProperties().size());
+ assertEquals(1, data.getArguments().size());
+ assertEquals("title", data.getArguments().get(0));
+ }
+
+ public void testGetCompactData5() {
+ CompactConstructor flow = new CompactConstructor();
+ CompactData data = flow.getCompactData("JFrame(id123, title, name=foo, alignment=center)");
+ assertNotNull(data);
+ assertEquals("JFrame", data.getPrefix());
+ assertEquals(2, data.getProperties().size());
+ assertEquals(2, data.getArguments().size());
+ assertEquals("id123", data.getArguments().get(0));
+ assertEquals("title", data.getArguments().get(1));
+ }
+
+ public void testGetCompactData6() {
+ CompactConstructor flow = new CompactConstructor();
+ CompactData data = flow.getCompactData("JFrame()");
+ assertNotNull(data);
+ assertEquals("JFrame", data.getPrefix());
+ assertEquals(0, data.getProperties().size());
+ assertEquals(0, data.getArguments().size());
+ }
+
+ public void testGetCompactData7() {
+ CompactConstructor flow = new CompactConstructor();
+ CompactData data = flow.getCompactData("package.Container(name=parent, id=123)");
+ assertNotNull(data);
+ assertEquals("package.Container", data.getPrefix());
+ assertEquals(2, data.getProperties().size());
+ assertEquals(0, data.getArguments().size());
+ }
+
+ public void testCompactDataToString() {
+ CompactData data = new CompactData("foo");
+ assertEquals("CompactData: foo {}", data.toString());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Container.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Container.java
index 8e5d794..2886eba 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Container.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Container.java
@@ -1,77 +1,77 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-public class Container {
- private String title;
- private String name;
- private String id;
-
- public Container() {
- this("no title");
- }
-
- public Container(String title) {
- this.title = title;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Container) {
- Container c = (Container) obj;
- if (name != null && !name.equals(c.name)) {
- return false;
- }
- if (id != null && !id.equals(c.id)) {
- return false;
- }
- return title.equals(c.title);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return title.hashCode();
- }
-
- @Override
- public String toString() {
- return "Container=" + title;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getTitle() {
- return title;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+public class Container {
+ private String title;
+ private String name;
+ private String id;
+
+ public Container() {
+ this("no title");
+ }
+
+ public Container(String title) {
+ this.title = title;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Container) {
+ Container c = (Container) obj;
+ if (name != null && !name.equals(c.name)) {
+ return false;
+ }
+ if (id != null && !id.equals(c.id)) {
+ return false;
+ }
+ return title.equals(c.title);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return title.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "Container=" + title;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Item.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Item.java
index 5fa91be..8a8e755 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Item.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Item.java
@@ -1,47 +1,47 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-public class Item {
- private String id;
- private String price;
- private String name;
-
- public Item(String id) {
- this.id = id;
- }
-
- public String getPrice() {
- return price;
- }
-
- public void setPrice(String price) {
- this.price = price;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getId() {
- return id;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+public class Item {
+ private String id;
+ private String price;
+ private String name;
+
+ public Item(String id) {
+ this.id = id;
+ }
+
+ public String getPrice() {
+ return price;
+ }
+
+ public void setPrice(String price) {
+ this.price = price;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getId() {
+ return id;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/ManyListsTable.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/ManyListsTable.java
index 0478946..6aac95d 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/ManyListsTable.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/ManyListsTable.java
@@ -1,49 +1,49 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-import java.util.List;
-
-public class ManyListsTable {
- private String id;
- private List<Row> rows;
- private List<String> names;
-
- public ManyListsTable(String id) {
- this.id = id;
- }
-
- public List<Row> getRows() {
- return rows;
- }
-
- public void setRows(List<Row> rows) {
- this.rows = rows;
- }
-
- public String getId() {
- return id;
- }
-
- public List<String> getNames() {
- return names;
- }
-
- public void setNames(List<String> names) {
- this.names = names;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+import java.util.List;
+
+public class ManyListsTable {
+ private String id;
+ private List<Row> rows;
+ private List<String> names;
+
+ public ManyListsTable(String id) {
+ this.id = id;
+ }
+
+ public List<Row> getRows() {
+ return rows;
+ }
+
+ public void setRows(List<Row> rows) {
+ this.rows = rows;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public List<String> getNames() {
+ return names;
+ }
+
+ public void setNames(List<String> names) {
+ this.names = names;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructorTest.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructorTest.java
index b863bc7..2474b26 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructorTest.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/PackageCompactConstructorTest.java
@@ -1,51 +1,51 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-import junit.framework.TestCase;
-
-public class PackageCompactConstructorTest extends TestCase {
-
- public void testGetClassForName() throws ClassNotFoundException {
- assertEquals(Table.class, check("Table"));
- assertEquals(Table.class, check("org.yaml.snakeyaml.extensions.compactnotation.Table"));
- assertEquals(String.class, check("java.lang.String"));
- }
-
- public void testException1() throws ClassNotFoundException {
- try {
- check("foo.Bar");
- fail();
- } catch (ClassNotFoundException e) {
- assertEquals("foo.Bar", e.getMessage());
- }
- }
-
- public void testException2() throws ClassNotFoundException {
- try {
- check("FooBar");
- fail();
- } catch (ClassNotFoundException e) {
- assertEquals("FooBar", e.getMessage());
- }
- }
-
- private Class<?> check(String name) throws ClassNotFoundException {
- return new PackageCompactConstructor("org.yaml.snakeyaml.extensions.compactnotation")
- .getClassForName(name);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+import junit.framework.TestCase;
+
+public class PackageCompactConstructorTest extends TestCase {
+
+ public void testGetClassForName() throws ClassNotFoundException {
+ assertEquals(Table.class, check("Table"));
+ assertEquals(Table.class, check("org.yaml.snakeyaml.extensions.compactnotation.Table"));
+ assertEquals(String.class, check("java.lang.String"));
+ }
+
+ public void testException1() throws ClassNotFoundException {
+ try {
+ check("foo.Bar");
+ fail();
+ } catch (ClassNotFoundException e) {
+ assertEquals("foo.Bar", e.getMessage());
+ }
+ }
+
+ public void testException2() throws ClassNotFoundException {
+ try {
+ check("FooBar");
+ fail();
+ } catch (ClassNotFoundException e) {
+ assertEquals("FooBar", e.getMessage());
+ }
+ }
+
+ private Class<?> check(String name) throws ClassNotFoundException {
+ return new PackageCompactConstructor("org.yaml.snakeyaml.extensions.compactnotation")
+ .getClassForName(name);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Row.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Row.java
index 4a21063..9a9da53 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Row.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Row.java
@@ -1,72 +1,72 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-public class Row {
- private String id;
- private int size;
- private double ratio;
- private String description;
-
- public Row(String id) {
- super();
- this.id = id;
- }
-
- public int getSize() {
- return size;
- }
-
- public void setSize(int size) {
- this.size = size;
- }
-
- public double getRatio() {
- return ratio;
- }
-
- public void setRatio(double ratio) {
- this.ratio = ratio;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getId() {
- return id;
- }
-
- @Override
- public boolean equals(Object obj) {
- return toString().equals(obj.toString());
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- @Override
- public String toString() {
- return "Row id=" + id;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+public class Row {
+ private String id;
+ private int size;
+ private double ratio;
+ private String description;
+
+ public Row(String id) {
+ super();
+ this.id = id;
+ }
+
+ public int getSize() {
+ return size;
+ }
+
+ public void setSize(int size) {
+ this.size = size;
+ }
+
+ public double getRatio() {
+ return ratio;
+ }
+
+ public void setRatio(double ratio) {
+ this.ratio = ratio;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return toString().equals(obj.toString());
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "Row id=" + id;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Table.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Table.java
index 8ffbdea..7049199 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Table.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/Table.java
@@ -1,47 +1,47 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-import java.util.List;
-
-public class Table {
- private String id;
- private String name;
- private List<Row> rows;
-
- public Table(String id, String name) {
- super();
- this.id = id;
- this.name = name;
- }
-
- public List<Row> getRows() {
- return rows;
- }
-
- public void setRows(List<Row> rows) {
- this.rows = rows;
- }
-
- public String getId() {
- return id;
- }
-
- public String getName() {
- return name;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+import java.util.List;
+
+public class Table {
+ private String id;
+ private String name;
+ private List<Row> rows;
+
+ public Table(String id, String name) {
+ super();
+ this.id = id;
+ this.name = name;
+ }
+
+ public List<Row> getRows() {
+ return rows;
+ }
+
+ public void setRows(List<Row> rows) {
+ this.rows = rows;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/TableCompactConstructor.java b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/TableCompactConstructor.java
index 5542a34..a535b40 100644
--- a/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/TableCompactConstructor.java
+++ b/src/test/java/org/yaml/snakeyaml/extensions/compactnotation/TableCompactConstructor.java
@@ -1,25 +1,25 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.extensions.compactnotation;
-
-public class TableCompactConstructor extends PackageCompactConstructor {
-
- public TableCompactConstructor(String packageName) {
- super(packageName);
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.extensions.compactnotation;
+
+public class TableCompactConstructor extends PackageCompactConstructor {
+
+ public TableCompactConstructor(String packageName) {
+ super(packageName);
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/generics/AbstractAnimal.java b/src/test/java/org/yaml/snakeyaml/generics/AbstractAnimal.java
index e02952c..c777b90 100644
--- a/src/test/java/org/yaml/snakeyaml/generics/AbstractAnimal.java
+++ b/src/test/java/org/yaml/snakeyaml/generics/AbstractAnimal.java
@@ -1,33 +1,33 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.generics;
-
-public abstract class AbstractAnimal<T> {
- private String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public abstract T getHome();
-
- public abstract void setHome(T home);
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.generics;
+
+public abstract class AbstractAnimal<T> {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public abstract T getHome();
+
+ public abstract void setHome(T home);
+}
diff --git a/src/test/java/org/yaml/snakeyaml/generics/Bird.java b/src/test/java/org/yaml/snakeyaml/generics/Bird.java
index d33c65b..aa7dc58 100644
--- a/src/test/java/org/yaml/snakeyaml/generics/Bird.java
+++ b/src/test/java/org/yaml/snakeyaml/generics/Bird.java
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.generics;
-
-public class Bird extends AbstractAnimal<Nest> {
- private Nest home;
-
- public Nest getHome() {
- return home;
- }
-
- public void setHome(Nest home) {
- this.home = home;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.generics;
+
+public class Bird extends AbstractAnimal<Nest> {
+ private Nest home;
+
+ public Nest getHome() {
+ return home;
+ }
+
+ public void setHome(Nest home) {
+ this.home = home;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/generics/BirdTest.java b/src/test/java/org/yaml/snakeyaml/generics/BirdTest.java
index 8397f14..3c05b77 100644
--- a/src/test/java/org/yaml/snakeyaml/generics/BirdTest.java
+++ b/src/test/java/org/yaml/snakeyaml/generics/BirdTest.java
@@ -1,58 +1,58 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.generics;
-
-import java.beans.IntrospectionException;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class BirdTest extends TestCase {
-
- public void testHome() throws IntrospectionException {
- Bird bird = new Bird();
- bird.setName("Eagle");
- Nest home = new Nest();
- home = new Nest();
- home.setHeight(3);
- bird.setHome(home);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bird);
- Bird parsed;
- String javaVendor = System.getProperty("java.vm.name");
- Yaml loader = new Yaml();
- if (GenericsBugDetector.isProperIntrospection()) {
- // no global tags
- System.out.println("java.vm.name: " + javaVendor);
- assertEquals("no global tags must be emitted.", "home:\n height: 3\nname: Eagle\n",
- output);
- parsed = loader.loadAs(output, Bird.class);
-
- } else {
- // with global tags
- System.out
- .println("JDK requires global tags for JavaBean properties with Java Generics. java.vm.name: "
- + javaVendor);
- assertEquals("global tags are inevitable here.",
- "home: !!org.yaml.snakeyaml.generics.Nest\n height: 3\nname: Eagle\n", output);
- parsed = loader.loadAs(output, Bird.class);
- }
- assertEquals(bird.getName(), parsed.getName());
- assertEquals(bird.getHome().getHeight(), parsed.getHome().getHeight());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.generics;
+
+import java.beans.IntrospectionException;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class BirdTest extends TestCase {
+
+ public void testHome() throws IntrospectionException {
+ Bird bird = new Bird();
+ bird.setName("Eagle");
+ Nest home = new Nest();
+ home = new Nest();
+ home.setHeight(3);
+ bird.setHome(home);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bird);
+ Bird parsed;
+ String javaVendor = System.getProperty("java.vm.name");
+ Yaml loader = new Yaml();
+ if (GenericsBugDetector.isProperIntrospection()) {
+ // no global tags
+ System.out.println("java.vm.name: " + javaVendor);
+ assertEquals("no global tags must be emitted.", "home:\n height: 3\nname: Eagle\n",
+ output);
+ parsed = loader.loadAs(output, Bird.class);
+
+ } else {
+ // with global tags
+ System.out
+ .println("JDK requires global tags for JavaBean properties with Java Generics. java.vm.name: "
+ + javaVendor);
+ assertEquals("global tags are inevitable here.",
+ "home: !!org.yaml.snakeyaml.generics.Nest\n height: 3\nname: Eagle\n", output);
+ parsed = loader.loadAs(output, Bird.class);
+ }
+ assertEquals(bird.getName(), parsed.getName());
+ assertEquals(bird.getHome().getHeight(), parsed.getHome().getHeight());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/generics/GenericsBugDetector.java b/src/test/java/org/yaml/snakeyaml/generics/GenericsBugDetector.java
index f057f25..0b2992a 100644
--- a/src/test/java/org/yaml/snakeyaml/generics/GenericsBugDetector.java
+++ b/src/test/java/org/yaml/snakeyaml/generics/GenericsBugDetector.java
@@ -1,40 +1,40 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.generics;
-
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-
-/**
- * @see http://bugs.sun.com/view_bug.do?bug_id=6528714
- */
-public class GenericsBugDetector {
- /**
- * Check whether the proper class Nest for Bird's property 'home' is
- * recognized.
- */
- public static boolean isProperIntrospection() throws IntrospectionException {
- for (PropertyDescriptor property : Introspector.getBeanInfo(Bird.class)
- .getPropertyDescriptors()) {
- if (property.getName().equals("home")) {
- return property.getPropertyType() == Nest.class;
- }
- }
- throw new RuntimeException("Bird must contain 'home' property.");
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.generics;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+
+/**
+ * @see http://bugs.sun.com/view_bug.do?bug_id=6528714
+ */
+public class GenericsBugDetector {
+ /**
+ * Check whether the proper class Nest for Bird's property 'home' is
+ * recognized.
+ */
+ public static boolean isProperIntrospection() throws IntrospectionException {
+ for (PropertyDescriptor property : Introspector.getBeanInfo(Bird.class)
+ .getPropertyDescriptors()) {
+ if (property.getName().equals("home")) {
+ return property.getPropertyType() == Nest.class;
+ }
+ }
+ throw new RuntimeException("Bird must contain 'home' property.");
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/generics/Nest.java b/src/test/java/org/yaml/snakeyaml/generics/Nest.java
index 7512282..14e7262 100644
--- a/src/test/java/org/yaml/snakeyaml/generics/Nest.java
+++ b/src/test/java/org/yaml/snakeyaml/generics/Nest.java
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.generics;
-
-public class Nest {
- private int height;
-
- public int getHeight() {
- return height;
- }
-
- public void setHeight(int height) {
- this.height = height;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.generics;
+
+public class Nest {
+ private int height;
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/immutable/Animal.java b/src/test/java/org/yaml/snakeyaml/immutable/Animal.java
index 73f9bd0..db172ab 100644
--- a/src/test/java/org/yaml/snakeyaml/immutable/Animal.java
+++ b/src/test/java/org/yaml/snakeyaml/immutable/Animal.java
@@ -1,21 +1,21 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.immutable;
-
-public interface Animal {
- public String getName();
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.immutable;
+
+public interface Animal {
+ public String getName();
+}
diff --git a/src/test/java/org/yaml/snakeyaml/immutable/Dog.java b/src/test/java/org/yaml/snakeyaml/immutable/Dog.java
index bcb7133..cb0fabb 100644
--- a/src/test/java/org/yaml/snakeyaml/immutable/Dog.java
+++ b/src/test/java/org/yaml/snakeyaml/immutable/Dog.java
@@ -1,34 +1,34 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.immutable;
-
-public class Dog implements Animal {
- private String name;
-
- public Dog(String name) {
- super();
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void bark() {
- System.out.println("I am a " + name);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.immutable;
+
+public class Dog implements Animal {
+ private String name;
+
+ public Dog(String name) {
+ super();
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void bark() {
+ System.out.println("I am a " + name);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/immutable/HouseBean.java b/src/test/java/org/yaml/snakeyaml/immutable/HouseBean.java
index 188572c..c504f59 100644
--- a/src/test/java/org/yaml/snakeyaml/immutable/HouseBean.java
+++ b/src/test/java/org/yaml/snakeyaml/immutable/HouseBean.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.immutable;
-
-public class HouseBean {
- private String name;
- private Animal animal;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Animal getAnimal() {
- return animal;
- }
-
- public void setAnimal(Animal animal) {
- this.animal = animal;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.immutable;
+
+public class HouseBean {
+ private String name;
+ private Animal animal;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Animal getAnimal() {
+ return animal;
+ }
+
+ public void setAnimal(Animal animal) {
+ this.animal = animal;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/immutable/primitives/BunchOfPrimitives.java b/src/test/java/org/yaml/snakeyaml/immutable/primitives/BunchOfPrimitives.java
index 50e8533..9c48565 100644
--- a/src/test/java/org/yaml/snakeyaml/immutable/primitives/BunchOfPrimitives.java
+++ b/src/test/java/org/yaml/snakeyaml/immutable/primitives/BunchOfPrimitives.java
@@ -1,68 +1,68 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.immutable.primitives;
-
-public class BunchOfPrimitives {
- private int primitiveInt;
- private double primitiveDouble;
- public boolean primitiveBoolean;
-
- public BunchOfPrimitives(int primitiveInt, double primitiveDouble, boolean primitiveBoolean) {
- this.primitiveInt = primitiveInt;
- this.primitiveDouble = primitiveDouble;
- this.primitiveBoolean = primitiveBoolean;
- }
-
- /**
- * The number of parameters is the same but the type is different
- */
- public BunchOfPrimitives(int i1, int i2, int i3) {
- this.primitiveInt = i1;
- }
-
- public BunchOfPrimitives(long i1, double i2, boolean i3) {
- this((int) i1, i2, i3);
- }
-
- public int getPrimitiveInt() {
- return primitiveInt;
- }
-
- public double getPrimitiveDouble() {
- return primitiveDouble;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof BunchOfPrimitives) {
- BunchOfPrimitives bunch = (BunchOfPrimitives) obj;
- return primitiveInt == bunch.primitiveInt;
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return primitiveInt;
- }
-
- @Override
- public String toString() {
- return "BunchOfPrimitives " + primitiveInt;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.immutable.primitives;
+
+public class BunchOfPrimitives {
+ private int primitiveInt;
+ private double primitiveDouble;
+ public boolean primitiveBoolean;
+
+ public BunchOfPrimitives(int primitiveInt, double primitiveDouble, boolean primitiveBoolean) {
+ this.primitiveInt = primitiveInt;
+ this.primitiveDouble = primitiveDouble;
+ this.primitiveBoolean = primitiveBoolean;
+ }
+
+ /**
+ * The number of parameters is the same but the type is different
+ */
+ public BunchOfPrimitives(int i1, int i2, int i3) {
+ this.primitiveInt = i1;
+ }
+
+ public BunchOfPrimitives(long i1, double i2, boolean i3) {
+ this((int) i1, i2, i3);
+ }
+
+ public int getPrimitiveInt() {
+ return primitiveInt;
+ }
+
+ public double getPrimitiveDouble() {
+ return primitiveDouble;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof BunchOfPrimitives) {
+ BunchOfPrimitives bunch = (BunchOfPrimitives) obj;
+ return primitiveInt == bunch.primitiveInt;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return primitiveInt;
+ }
+
+ @Override
+ public String toString() {
+ return "BunchOfPrimitives " + primitiveInt;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/introspector/MethodPropertyTest.java b/src/test/java/org/yaml/snakeyaml/introspector/MethodPropertyTest.java
index 7b9465b..c7eb356 100644
--- a/src/test/java/org/yaml/snakeyaml/introspector/MethodPropertyTest.java
+++ b/src/test/java/org/yaml/snakeyaml/introspector/MethodPropertyTest.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.introspector;
-
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.constructor.TestBean1;
-
-public class MethodPropertyTest extends TestCase {
-
- public void testToString() throws IntrospectionException {
- for (PropertyDescriptor property : Introspector.getBeanInfo(TestBean1.class)
- .getPropertyDescriptors()) {
- if (property.getName().equals("text")) {
- MethodProperty prop = new MethodProperty(property);
- assertEquals("text of class java.lang.String", prop.toString());
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.introspector;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.constructor.TestBean1;
+
+public class MethodPropertyTest extends TestCase {
+
+ public void testToString() throws IntrospectionException {
+ for (PropertyDescriptor property : Introspector.getBeanInfo(TestBean1.class)
+ .getPropertyDescriptors()) {
+ if (property.getName().equals("text")) {
+ MethodProperty prop = new MethodProperty(property);
+ assertEquals("text of class java.lang.String", prop.toString());
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue100/Data.java b/src/test/java/org/yaml/snakeyaml/issues/issue100/Data.java
index 1e37da0..105d9a0 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue100/Data.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue100/Data.java
@@ -1,66 +1,66 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue100;
-
-public class Data {
- private String id;
- private int age;
-
- public Data() {
- this.id = null;
- this.age = 999;
- }
-
- public Data(String id, int age) {
- this.id = id;
- this.age = age;
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- @Override
- public String toString() {
- return "Data [age=" + age + ", id=" + id + "]";
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Data) {
- return toString().equals(obj.toString());
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return toString().hashCode();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue100;
+
+public class Data {
+ private String id;
+ private int age;
+
+ public Data() {
+ this.id = null;
+ this.age = 999;
+ }
+
+ public Data(String id, int age) {
+ this.id = id;
+ this.age = age;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ @Override
+ public String toString() {
+ return "Data [age=" + age + ", id=" + id + "]";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Data) {
+ return toString().equals(obj.toString());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return toString().hashCode();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue100/DataBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue100/DataBean.java
index 710e641..4d13f09 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue100/DataBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue100/DataBean.java
@@ -1,48 +1,48 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue100;
-
-public class DataBean {
- private String id;
- private Data data;
- private DataMore more;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public Data getData() {
- return data;
- }
-
- public void setData(Data data) {
- this.data = data;
- }
-
- public DataMore getMore() {
- return more;
- }
-
- public void setMore(DataMore more) {
- this.more = more;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue100;
+
+public class DataBean {
+ private String id;
+ private Data data;
+ private DataMore more;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public Data getData() {
+ return data;
+ }
+
+ public void setData(Data data) {
+ this.data = data;
+ }
+
+ public DataMore getMore() {
+ return more;
+ }
+
+ public void setMore(DataMore more) {
+ this.more = more;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue102/DataBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue102/DataBean.java
index 16ccb25..c1bc06d 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue102/DataBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue102/DataBean.java
@@ -1,50 +1,50 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue102;
-
-import java.util.List;
-import java.util.Map;
-
-public class DataBean {
- private String id;
- private List<String> list;
- private Map<String, Integer> map;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public List<String> getList() {
- return list;
- }
-
- public void setList(List<String> list) {
- this.list = list;
- }
-
- public Map<String, Integer> getMap() {
- return map;
- }
-
- public void setMap(Map<String, Integer> map) {
- this.map = map;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue102;
+
+import java.util.List;
+import java.util.Map;
+
+public class DataBean {
+ private String id;
+ private List<String> list;
+ private Map<String, Integer> map;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<String> getList() {
+ return list;
+ }
+
+ public void setList(List<String> list) {
+ this.list = list;
+ }
+
+ public Map<String, Integer> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, Integer> map) {
+ this.map = map;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue11/YamlMapTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue11/YamlMapTest.java
index a57636f..caa1112 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue11/YamlMapTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue11/YamlMapTest.java
@@ -1,146 +1,146 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue11;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Represent;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class YamlMapTest extends TestCase {
- public void testYaml() {
- Yaml yaml = new Yaml(new ExtendedConstructor(), new ExtendedRepresenter());
- String output = yaml.dump(new Custom(123));
- // System.out.println(output);
- Custom o = (Custom) yaml.load(output);
- assertEquals("123", o.getStr());
- }
-
- @SuppressWarnings("unchecked")
- public void testYamlMap() {
- Map<String, Object> data = new TreeMap<String, Object>();
- data.put("customTag", new Custom(123));
-
- Yaml yaml = new Yaml(new ExtendedConstructor(), new ExtendedRepresenter());
- String output = yaml.dump(data);
- // System.out.println(output);
- Object o = yaml.load(output);
-
- assertTrue(o instanceof Map);
- Map<String, Object> m = (Map<String, Object>) o;
- assertTrue(m.get("customTag") instanceof Custom);
- }
-
- @SuppressWarnings("unchecked")
- public void testYamlMapBean() {
- Map<String, Object> data = new TreeMap<String, Object>();
- data.put("knownClass", new Wrapper("test", new Custom(456)));
-
- Yaml yaml = new Yaml(new ExtendedConstructor(), new ExtendedRepresenter());
- String output = yaml.dump(data);
- // System.out.println(output);
- Object o = yaml.load(output);
-
- assertTrue(o instanceof Map);
- Map<String, Object> m = (Map<String, Object>) o;
- assertEquals(Wrapper.class, m.get("knownClass").getClass());
- }
-
- public static class Wrapper {
- private String a;
- private Custom b;
-
- public Wrapper(String s, Custom bb) {
- a = s;
- b = bb;
- }
-
- public Wrapper() {
- }
-
- public String getA() {
- return a;
- }
-
- public void setA(String s) {
- a = s;
- }
-
- public Custom getB() {
- return b;
- }
-
- public void setB(Custom bb) {
- b = bb;
- }
- }
-
- public static class Custom {
- final private String str;
-
- public Custom(Integer i) {
- str = i.toString();
- }
-
- public Custom(Custom c) {
- str = c.str;
- }
-
- public String toString() {
- return str;
- }
-
- public String getStr() {
- return str;
- }
- }
-
- public static class ExtendedRepresenter extends Representer {
- public ExtendedRepresenter() {
- this.representers.put(Custom.class, new RepresentCustom());
- }
-
- private class RepresentCustom implements Represent {
- public Node representData(Object data) {
- return representScalar(new Tag("!Custom"), ((Custom) data).toString());
- }
- }
- }
-
- public static class ExtendedConstructor extends Constructor {
- public ExtendedConstructor() {
- this.yamlConstructors.put(new Tag("!Custom"), new ConstructCustom());
- }
-
- private class ConstructCustom extends AbstractConstruct {
- public Object construct(Node node) {
- String str = (String) constructScalar((ScalarNode) node);
- return new Custom(new Integer(str));
- }
-
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue11;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Represent;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class YamlMapTest extends TestCase {
+ public void testYaml() {
+ Yaml yaml = new Yaml(new ExtendedConstructor(), new ExtendedRepresenter());
+ String output = yaml.dump(new Custom(123));
+ // System.out.println(output);
+ Custom o = (Custom) yaml.load(output);
+ assertEquals("123", o.getStr());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testYamlMap() {
+ Map<String, Object> data = new TreeMap<String, Object>();
+ data.put("customTag", new Custom(123));
+
+ Yaml yaml = new Yaml(new ExtendedConstructor(), new ExtendedRepresenter());
+ String output = yaml.dump(data);
+ // System.out.println(output);
+ Object o = yaml.load(output);
+
+ assertTrue(o instanceof Map);
+ Map<String, Object> m = (Map<String, Object>) o;
+ assertTrue(m.get("customTag") instanceof Custom);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testYamlMapBean() {
+ Map<String, Object> data = new TreeMap<String, Object>();
+ data.put("knownClass", new Wrapper("test", new Custom(456)));
+
+ Yaml yaml = new Yaml(new ExtendedConstructor(), new ExtendedRepresenter());
+ String output = yaml.dump(data);
+ // System.out.println(output);
+ Object o = yaml.load(output);
+
+ assertTrue(o instanceof Map);
+ Map<String, Object> m = (Map<String, Object>) o;
+ assertEquals(Wrapper.class, m.get("knownClass").getClass());
+ }
+
+ public static class Wrapper {
+ private String a;
+ private Custom b;
+
+ public Wrapper(String s, Custom bb) {
+ a = s;
+ b = bb;
+ }
+
+ public Wrapper() {
+ }
+
+ public String getA() {
+ return a;
+ }
+
+ public void setA(String s) {
+ a = s;
+ }
+
+ public Custom getB() {
+ return b;
+ }
+
+ public void setB(Custom bb) {
+ b = bb;
+ }
+ }
+
+ public static class Custom {
+ final private String str;
+
+ public Custom(Integer i) {
+ str = i.toString();
+ }
+
+ public Custom(Custom c) {
+ str = c.str;
+ }
+
+ public String toString() {
+ return str;
+ }
+
+ public String getStr() {
+ return str;
+ }
+ }
+
+ public static class ExtendedRepresenter extends Representer {
+ public ExtendedRepresenter() {
+ this.representers.put(Custom.class, new RepresentCustom());
+ }
+
+ private class RepresentCustom implements Represent {
+ public Node representData(Object data) {
+ return representScalar(new Tag("!Custom"), ((Custom) data).toString());
+ }
+ }
+ }
+
+ public static class ExtendedConstructor extends Constructor {
+ public ExtendedConstructor() {
+ this.yamlConstructors.put(new Tag("!Custom"), new ConstructCustom());
+ }
+
+ private class ConstructCustom extends AbstractConstruct {
+ public Object construct(Node node) {
+ String str = (String) constructScalar((ScalarNode) node);
+ return new Custom(new Integer(str));
+ }
+
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue115/IssueBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue115/IssueBean.java
index 76ccca5..28a1bd0 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue115/IssueBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue115/IssueBean.java
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue115;
-
-public class IssueBean {
- private ParameterizedBean<Integer, String> bean = new ParameterizedBean<Integer, String>();
-
- public ParameterizedBean<Integer, String> getBean() {
- return bean;
- }
-
- public void setBean(ParameterizedBean<Integer, String> bean) {
- this.bean = bean;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue115;
+
+public class IssueBean {
+ private ParameterizedBean<Integer, String> bean = new ParameterizedBean<Integer, String>();
+
+ public ParameterizedBean<Integer, String> getBean() {
+ return bean;
+ }
+
+ public void setBean(ParameterizedBean<Integer, String> bean) {
+ this.bean = bean;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue115/ParameterizedBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue115/ParameterizedBean.java
index 2b0a42b..99d92cc 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue115/ParameterizedBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue115/ParameterizedBean.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue115;
-
-public class ParameterizedBean<K, V> {
- private K k;
- private V v;
-
- public K getK() {
- return k;
- }
-
- public void setK(K k) {
- this.k = k;
- }
-
- public V getV() {
- return v;
- }
-
- public void setV(V v) {
- this.v = v;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue115;
+
+public class ParameterizedBean<K, V> {
+ private K k;
+ private V v;
+
+ public K getK() {
+ return k;
+ }
+
+ public void setK(K k) {
+ this.k = k;
+ }
+
+ public V getV() {
+ return v;
+ }
+
+ public void setV(V v) {
+ this.v = v;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue116/HiddenSpecial.java b/src/test/java/org/yaml/snakeyaml/issues/issue116/HiddenSpecial.java
index 20342ca..058372a 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue116/HiddenSpecial.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue116/HiddenSpecial.java
@@ -1,29 +1,29 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue116;
-
-public class HiddenSpecial {
- private int inaccessableField;
-
- public HiddenSpecial(String something) {
- this.inaccessableField = something.hashCode();
- }
-
- public int retrieveMyVerySpecialField() {
- return inaccessableField;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue116;
+
+public class HiddenSpecial {
+ private int inaccessableField;
+
+ public HiddenSpecial(String something) {
+ this.inaccessableField = something.hashCode();
+ }
+
+ public int retrieveMyVerySpecialField() {
+ return inaccessableField;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue124/Bean124.java b/src/test/java/org/yaml/snakeyaml/issues/issue124/Bean124.java
index 3ef85c9..2c4414c 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue124/Bean124.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue124/Bean124.java
@@ -1,54 +1,54 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue124;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Bean124 {
- private String a;
- private List<Integer> numbers;
-
- public Bean124() {
- this.a = "aaa";
- this.numbers = new ArrayList<Integer>(3);
- numbers.add(1);
- numbers.add(2);
- numbers.add(3);
- }
-
- public Bean124(String a, List<Integer> numbers) {
- super();
- this.a = a;
- this.numbers = numbers;
- }
-
- public String getA() {
- return a;
- }
-
- public void setA(String a) {
- this.a = a;
- }
-
- public List<Integer> getNumbers() {
- return numbers;
- }
-
- public void setNumbers(List<Integer> numbers) {
- this.numbers = numbers;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue124;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Bean124 {
+ private String a;
+ private List<Integer> numbers;
+
+ public Bean124() {
+ this.a = "aaa";
+ this.numbers = new ArrayList<Integer>(3);
+ numbers.add(1);
+ numbers.add(2);
+ numbers.add(3);
+ }
+
+ public Bean124(String a, List<Integer> numbers) {
+ super();
+ this.a = a;
+ this.numbers = numbers;
+ }
+
+ public String getA() {
+ return a;
+ }
+
+ public void setA(String a) {
+ this.a = a;
+ }
+
+ public List<Integer> getNumbers() {
+ return numbers;
+ }
+
+ public void setNumbers(List<Integer> numbers) {
+ this.numbers = numbers;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue127/Bean.java b/src/test/java/org/yaml/snakeyaml/issues/issue127/Bean.java
index 150e5b1..eb03659 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue127/Bean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue127/Bean.java
@@ -1,37 +1,37 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue127;
-
-public class Bean {
- private String a;
- private String b;
-
- public String getA() {
- return a;
- }
-
- public void setA(String a) {
- this.a = a;
- }
-
- public String getB() {
- return b;
- }
-
- public void setB(String b) {
- this.b = b;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue127;
+
+public class Bean {
+ private String a;
+ private String b;
+
+ public String getA() {
+ return a;
+ }
+
+ public void setA(String a) {
+ this.a = a;
+ }
+
+ public String getB() {
+ return b;
+ }
+
+ public void setB(String b) {
+ this.b = b;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue132/ScalarEventTagTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue132/ScalarEventTagTest.java
index 0c015c5..5ebe7fd 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue132/ScalarEventTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue132/ScalarEventTagTest.java
@@ -1,60 +1,60 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue132;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.ScalarEvent;
-import org.yaml.snakeyaml.nodes.Node;
-
-/**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=132
- */
-public class ScalarEventTagTest extends TestCase {
- public void testLoad() {
- Yaml yaml = new Yaml();
- Iterable<Event> parsed = yaml.parse(new StringReader("5"));
- List<Event> events = new ArrayList<Event>(5);
- for (Event event : parsed) {
- events.add(event);
- // System.out.println(event);
- }
- String tag = ((ScalarEvent) events.get(2)).getTag();
- assertNull("The tag should not be specified: " + tag, tag);
- }
-
- public void testDump() {
- Yaml yaml = new Yaml();
- Node intNode = yaml.represent(7);
- assertEquals("tag:yaml.org,2002:int", intNode.getTag().toString());
- // System.out.println(intNode);
- List<Event> intEvents = yaml.serialize(intNode);
- String tag = ((ScalarEvent) intEvents.get(2)).getTag();
- assertEquals("Without the tag emitter would not know how to emit '7'",
- "tag:yaml.org,2002:int", tag);
- //
- Node strNode = yaml.represent("7");
- assertEquals("tag:yaml.org,2002:str", strNode.getTag().toString());
- // System.out.println(strNode);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue132;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.ScalarEvent;
+import org.yaml.snakeyaml.nodes.Node;
+
+/**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=132
+ */
+public class ScalarEventTagTest extends TestCase {
+ public void testLoad() {
+ Yaml yaml = new Yaml();
+ Iterable<Event> parsed = yaml.parse(new StringReader("5"));
+ List<Event> events = new ArrayList<Event>(5);
+ for (Event event : parsed) {
+ events.add(event);
+ // System.out.println(event);
+ }
+ String tag = ((ScalarEvent) events.get(2)).getTag();
+ assertNull("The tag should not be specified: " + tag, tag);
+ }
+
+ public void testDump() {
+ Yaml yaml = new Yaml();
+ Node intNode = yaml.represent(7);
+ assertEquals("tag:yaml.org,2002:int", intNode.getTag().toString());
+ // System.out.println(intNode);
+ List<Event> intEvents = yaml.serialize(intNode);
+ String tag = ((ScalarEvent) intEvents.get(2)).getTag();
+ assertEquals("Without the tag emitter would not know how to emit '7'",
+ "tag:yaml.org,2002:int", tag);
+ //
+ Node strNode = yaml.represent("7");
+ assertEquals("tag:yaml.org,2002:str", strNode.getTag().toString());
+ // System.out.println(strNode);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue133/StackOverflowTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue133/StackOverflowTest.java
index 4667017..a1042c1 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue133/StackOverflowTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue133/StackOverflowTest.java
@@ -1,71 +1,71 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue133;
-
-import java.awt.Point;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.introspector.Property;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=133
- */
-public class StackOverflowTest extends TestCase {
- public void testDumpRecursiveObject() {
- try {
- Yaml yaml = new Yaml();
- // by default it must fail with StackOverflow
- yaml.dump(new Point());
- fail("getLocation() is recursive.");
- } catch (Throwable e) {
- assertNull("StackOverflow has no message: " + e.getMessage(), e.getMessage());
- }
- }
-
- /**
- * Since Point.getLocation() creates a new instance of Point class,
- * SnakeYAML will fail to dump an instance of Point if 'getLocation()' is
- * also included.
- *
- * Since Point is not really a JavaBean, we can safely skip the recursive
- * property when we dump the instance of Point.
- */
- private class PointRepresenter extends Representer {
-
- @Override
- protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
- Object propertyValue, Tag customTag) {
- if (javaBean instanceof Point && "location".equals(property.getName())) {
- return null;
- } else {
- return super
- .representJavaBeanProperty(javaBean, property, propertyValue, customTag);
- }
- }
- }
-
- public void testDump() {
- Yaml yaml = new Yaml(new PointRepresenter());
- String output = yaml.dump(new Point());
- assertEquals("!!java.awt.Point {x: 0, y: 0}\n", output);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue133;
+
+import java.awt.Point;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.introspector.Property;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=133
+ */
+public class StackOverflowTest extends TestCase {
+ public void testDumpRecursiveObject() {
+ try {
+ Yaml yaml = new Yaml();
+ // by default it must fail with StackOverflow
+ yaml.dump(new Point());
+ fail("getLocation() is recursive.");
+ } catch (Throwable e) {
+ assertNull("StackOverflow has no message: " + e.getMessage(), e.getMessage());
+ }
+ }
+
+ /**
+ * Since Point.getLocation() creates a new instance of Point class,
+ * SnakeYAML will fail to dump an instance of Point if 'getLocation()' is
+ * also included.
+ *
+ * Since Point is not really a JavaBean, we can safely skip the recursive
+ * property when we dump the instance of Point.
+ */
+ private class PointRepresenter extends Representer {
+
+ @Override
+ protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
+ Object propertyValue, Tag customTag) {
+ if (javaBean instanceof Point && "location".equals(property.getName())) {
+ return null;
+ } else {
+ return super
+ .representJavaBeanProperty(javaBean, property, propertyValue, customTag);
+ }
+ }
+ }
+
+ public void testDump() {
+ Yaml yaml = new Yaml(new PointRepresenter());
+ String output = yaml.dump(new Point());
+ assertEquals("!!java.awt.Point {x: 0, y: 0}\n", output);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue24/LineNumberTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue24/LineNumberTest.java
index 653ea45..96a5ba0 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue24/LineNumberTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue24/LineNumberTest.java
@@ -1,40 +1,40 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue24;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=24
- */
-public class LineNumberTest extends TestCase {
- public void test1() {
- String resource = Util.getLocalResource("issues/issue24-1.yaml");
- // System.out.println(resource);
- Yaml yaml = new Yaml();
- try {
- yaml.load(resource);
- fail();
- } catch (Exception e) {
- assertTrue(e.toString(), e.toString().contains("line 3"));
- assertTrue(e.toString(), e.toString().contains("column 12"));
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue24;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=24
+ */
+public class LineNumberTest extends TestCase {
+ public void test1() {
+ String resource = Util.getLocalResource("issues/issue24-1.yaml");
+ // System.out.println(resource);
+ Yaml yaml = new Yaml();
+ try {
+ yaml.load(resource);
+ fail();
+ } catch (Exception e) {
+ assertTrue(e.toString(), e.toString().contains("line 3"));
+ assertTrue(e.toString(), e.toString().contains("column 12"));
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue29/BigJavaBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue29/BigJavaBean.java
index 754149d..fc1e62b 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue29/BigJavaBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue29/BigJavaBean.java
@@ -1,127 +1,127 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue29;
-
-import java.util.List;
-import java.util.Map;
-
-public class BigJavaBean {
- private String name;
- private String address;
- private String description;
- private int id;
- private List<Integer> numbers;
- private Map<String, String> data;
-
- public BigJavaBean() {
- }
-
- public BigJavaBean(int id, String name, String address, String description) {
- super();
- this.name = name;
- this.address = address;
- this.description = description;
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getAddress() {
- return address;
- }
-
- public String getDescription() {
- return description;
- }
-
- public int getId() {
- return id;
- }
-
- public List<Integer> getNumbers() {
- return numbers;
- }
-
- public void setNumbers(List<Integer> numbers) {
- this.numbers = numbers;
- }
-
- public Map<String, String> getData() {
- return data;
- }
-
- public void setData(Map<String, String> data) {
- this.data = data;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((address == null) ? 0 : address.hashCode());
- result = prime * result + ((data == null) ? 0 : data.hashCode());
- result = prime * result + ((description == null) ? 0 : description.hashCode());
- result = prime * result + id;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((numbers == null) ? 0 : numbers.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- BigJavaBean other = (BigJavaBean) obj;
- if (address == null) {
- if (other.address != null)
- return false;
- } else if (!address.equals(other.address))
- return false;
- if (data == null) {
- if (other.data != null)
- return false;
- } else if (!data.equals(other.data))
- return false;
- if (description == null) {
- if (other.description != null)
- return false;
- } else if (!description.equals(other.description))
- return false;
- if (id != other.id)
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- if (numbers == null) {
- if (other.numbers != null)
- return false;
- } else if (!numbers.equals(other.numbers))
- return false;
- return true;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue29;
+
+import java.util.List;
+import java.util.Map;
+
+public class BigJavaBean {
+ private String name;
+ private String address;
+ private String description;
+ private int id;
+ private List<Integer> numbers;
+ private Map<String, String> data;
+
+ public BigJavaBean() {
+ }
+
+ public BigJavaBean(int id, String name, String address, String description) {
+ super();
+ this.name = name;
+ this.address = address;
+ this.description = description;
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public List<Integer> getNumbers() {
+ return numbers;
+ }
+
+ public void setNumbers(List<Integer> numbers) {
+ this.numbers = numbers;
+ }
+
+ public Map<String, String> getData() {
+ return data;
+ }
+
+ public void setData(Map<String, String> data) {
+ this.data = data;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((address == null) ? 0 : address.hashCode());
+ result = prime * result + ((data == null) ? 0 : data.hashCode());
+ result = prime * result + ((description == null) ? 0 : description.hashCode());
+ result = prime * result + id;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ result = prime * result + ((numbers == null) ? 0 : numbers.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ BigJavaBean other = (BigJavaBean) obj;
+ if (address == null) {
+ if (other.address != null)
+ return false;
+ } else if (!address.equals(other.address))
+ return false;
+ if (data == null) {
+ if (other.data != null)
+ return false;
+ } else if (!data.equals(other.data))
+ return false;
+ if (description == null) {
+ if (other.description != null)
+ return false;
+ } else if (!description.equals(other.description))
+ return false;
+ if (id != other.id)
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (numbers == null) {
+ if (other.numbers != null)
+ return false;
+ } else if (!numbers.equals(other.numbers))
+ return false;
+ return true;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStyleTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStyleTest.java
index df25c3d..9589d71 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStyleTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStyleTest.java
@@ -1,106 +1,106 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue29;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=29
- */
-public class FlexibleScalarStyleTest extends TestCase {
- public void testLong() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.FOLDED);
- Yaml yaml = new Yaml(options);
- String result = yaml
- .dump("qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
- + "qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
- + "qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n "
- + "qqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq\n");
- // System.out.println(result);
- assertTrue(result.startsWith(">\n"));
- assertEquals(
- ">\n qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq\n qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n qqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq\n",
- result);
- }
-
- public void testNoFoldedScalar() {
- DumperOptions options = new DumperOptions();
- options.setWidth(30);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(getData());
- // System.out.println(output);
- String etalon = Util.getLocalResource("representer/scalar-style1.yaml");
- assertEquals(etalon, output);
- }
-
- public void testCustomScalarStyle() {
- DumperOptions options = new DumperOptions();
- options.setWidth(30);
- Yaml yaml = new Yaml(new MyRepresenter(), options);
- String output = yaml.dump(getData());
- // System.out.println(output);
- String etalon = Util.getLocalResource("representer/scalar-style2.yaml");
- assertEquals(etalon, output);
- }
-
- private Map<String, String> getData() {
- Map<String, String> map = new LinkedHashMap<String, String>();
- map.put("name", "Steve Jobs");
- map.put("address", "Name\nStreet Number\nCountry");
- map.put("description",
- "1111111111 2222222222 3333333333 4444444444 5555555555 6666666666 7777777777 8888888888 9999999999 0000000000");
- return map;
- }
-
- private class MyRepresenter extends Representer {
-
- public MyRepresenter() {
- super();
- this.representers.put(String.class, new FlexibleRepresent());
- }
-
- private class FlexibleRepresent extends RepresentString {
- public Node representData(Object data) {
- ScalarNode node = (ScalarNode) super.representData(data);
- if (node.getStyle() == null) {
- // if Plain scalar style
- if (node.getValue().length() < 25) {
- return node;
- } else {
- // Folded scalar style
- return new ScalarNode(node.getTag(), node.getValue(), node.getStartMark(),
- node.getEndMark(), '>');
- }
- } else {
- return node;
- }
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue29;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=29
+ */
+public class FlexibleScalarStyleTest extends TestCase {
+ public void testLong() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.FOLDED);
+ Yaml yaml = new Yaml(options);
+ String result = yaml
+ .dump("qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
+ + "qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq "
+ + "qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n "
+ + "qqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq\n");
+ // System.out.println(result);
+ assertTrue(result.startsWith(">\n"));
+ assertEquals(
+ ">\n qqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqq\n qqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqq 111111111111111111111111\n qqqqqqqqqqqqqqqqqqqqqqqqqqqqq qqqqqqqqqqqqqqqqqqqqqqqqqqq\n",
+ result);
+ }
+
+ public void testNoFoldedScalar() {
+ DumperOptions options = new DumperOptions();
+ options.setWidth(30);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(getData());
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("representer/scalar-style1.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testCustomScalarStyle() {
+ DumperOptions options = new DumperOptions();
+ options.setWidth(30);
+ Yaml yaml = new Yaml(new MyRepresenter(), options);
+ String output = yaml.dump(getData());
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("representer/scalar-style2.yaml");
+ assertEquals(etalon, output);
+ }
+
+ private Map<String, String> getData() {
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ map.put("name", "Steve Jobs");
+ map.put("address", "Name\nStreet Number\nCountry");
+ map.put("description",
+ "1111111111 2222222222 3333333333 4444444444 5555555555 6666666666 7777777777 8888888888 9999999999 0000000000");
+ return map;
+ }
+
+ private class MyRepresenter extends Representer {
+
+ public MyRepresenter() {
+ super();
+ this.representers.put(String.class, new FlexibleRepresent());
+ }
+
+ private class FlexibleRepresent extends RepresentString {
+ public Node representData(Object data) {
+ ScalarNode node = (ScalarNode) super.representData(data);
+ if (node.getStyle() == null) {
+ // if Plain scalar style
+ if (node.getValue().length() < 25) {
+ return node;
+ } else {
+ // Folded scalar style
+ return new ScalarNode(node.getTag(), node.getValue(), node.getStartMark(),
+ node.getEndMark(), '>');
+ }
+ } else {
+ return node;
+ }
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStylesInJavaBeanTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStylesInJavaBeanTest.java
index d57f6c5..d3eddf2 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStylesInJavaBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue29/FlexibleScalarStylesInJavaBeanTest.java
@@ -1,148 +1,148 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue29;
-
-import java.beans.IntrospectionException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.introspector.BeanAccess;
-import org.yaml.snakeyaml.introspector.Property;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class FlexibleScalarStylesInJavaBeanTest extends TestCase {
- public void testDifferentStyles() {
- BigJavaBean bean1 = new BigJavaBean(1, "simple", "line 1\nline2\nzipcode", "short text1");
- List<Integer> numbers1 = new ArrayList<Integer>(Arrays.asList(1, 2, 3));
- bean1.setNumbers(numbers1);
- Map<String, String> data1 = new HashMap<String, String>();
- data1.put("key1", "value1");
- data1.put("key2", "value2");
- bean1.setData(data1);
- //
- BigJavaBean bean2 = new BigJavaBean(1, "second", "line 111\nline 222\nzipcode 12345\n\n",
- "info: semicolon is used");
- List<Integer> numbers2 = new ArrayList<Integer>(Arrays.asList(4, 5, 6, 777, 888, 999, 1000));
- bean2.setNumbers(numbers2);
- Map<String, String> data2 = new HashMap<String, String>();
- data2.put("key21", "value12");
- data2.put("key22", "value with\ntwo lines");
- bean2.setData(data2);
- //
- List<BigJavaBean> list = new ArrayList<BigJavaBean>();
- list.add(bean1);
- list.add(bean2);
- Yaml yaml = new Yaml(new MyRepresenter());
- yaml.setBeanAccess(BeanAccess.FIELD);
- String output = yaml.dump(list);
- // System.out.println(output);
- // parse back
- @SuppressWarnings("unchecked")
- List<BigJavaBean> parsed = (List<BigJavaBean>) yaml.load(output);
- assertEquals(2, parsed.size());
- assertEquals(bean1, parsed.get(0));
- assertEquals(bean2, parsed.get(1));
-
- }
-
- private class MyRepresenter extends Representer {
- /*
- * Change the default order. Important data goes first.
- */
- @Override
- protected Set<Property> getProperties(Class<? extends Object> type)
- throws IntrospectionException {
- if (type.isAssignableFrom(BigJavaBean.class)) {
- Set<Property> standard = super.getProperties(type);
- Set<Property> sorted = new TreeSet<Property>(new PropertyComparator());
- sorted.addAll(standard);
- return sorted;
- } else {
- return super.getProperties(type);
- }
- }
-
- private class PropertyComparator implements Comparator<Property> {
- public int compare(Property o1, Property o2) {
- // important go first
- List<String> order = new ArrayList<String>(Arrays.asList("id", "name",
- "description", "address"));
- for (String name : order) {
- int c = compareByName(o1, o2, name);
- if (c != 0) {
- return c;
- }
- }
- // all the rest
- return o1.compareTo(o2);
- }
-
- private int compareByName(Property o1, Property o2, String name) {
- if (o1.getName().equals(name)) {
- return -1;
- } else if (o2.getName().equals(name)) {
- return 1;
- }
- return 0;// compare further
- }
- }
-
- @Override
- protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
- Object propertyValue, Tag customTag) {
- if (javaBean instanceof BigJavaBean) {
- BigJavaBean bean = (BigJavaBean) javaBean;
- NodeTuple standard = super.representJavaBeanProperty(javaBean, property,
- propertyValue, customTag);
- if (property.getName().equals("numbers")) {
- // when the list is small, make it block collection style
- if (bean.getNumbers().size() < 5) {
- SequenceNode n = (SequenceNode) standard.getValueNode();
- return new NodeTuple(standard.getKeyNode(), new SequenceNode(n.getTag(),
- true, n.getValue(), n.getStartMark(), n.getEndMark(), false));
- }
- }
- if (property.getName().equals("description")) {
- // if description contains ':' use folded scalar style and
- // not single quoted scalar style
- if (bean.getDescription().indexOf(':') > 0) {
- ScalarNode n = (ScalarNode) standard.getValueNode();
- return new NodeTuple(standard.getKeyNode(), new ScalarNode(n.getTag(),
- n.getValue(), n.getStartMark(), n.getEndMark(), '>'));
- }
- }
- return standard;
- } else {
- return super
- .representJavaBeanProperty(javaBean, property, propertyValue, customTag);
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue29;
+
+import java.beans.IntrospectionException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.introspector.BeanAccess;
+import org.yaml.snakeyaml.introspector.Property;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class FlexibleScalarStylesInJavaBeanTest extends TestCase {
+ public void testDifferentStyles() {
+ BigJavaBean bean1 = new BigJavaBean(1, "simple", "line 1\nline2\nzipcode", "short text1");
+ List<Integer> numbers1 = new ArrayList<Integer>(Arrays.asList(1, 2, 3));
+ bean1.setNumbers(numbers1);
+ Map<String, String> data1 = new HashMap<String, String>();
+ data1.put("key1", "value1");
+ data1.put("key2", "value2");
+ bean1.setData(data1);
+ //
+ BigJavaBean bean2 = new BigJavaBean(1, "second", "line 111\nline 222\nzipcode 12345\n\n",
+ "info: semicolon is used");
+ List<Integer> numbers2 = new ArrayList<Integer>(Arrays.asList(4, 5, 6, 777, 888, 999, 1000));
+ bean2.setNumbers(numbers2);
+ Map<String, String> data2 = new HashMap<String, String>();
+ data2.put("key21", "value12");
+ data2.put("key22", "value with\ntwo lines");
+ bean2.setData(data2);
+ //
+ List<BigJavaBean> list = new ArrayList<BigJavaBean>();
+ list.add(bean1);
+ list.add(bean2);
+ Yaml yaml = new Yaml(new MyRepresenter());
+ yaml.setBeanAccess(BeanAccess.FIELD);
+ String output = yaml.dump(list);
+ // System.out.println(output);
+ // parse back
+ @SuppressWarnings("unchecked")
+ List<BigJavaBean> parsed = (List<BigJavaBean>) yaml.load(output);
+ assertEquals(2, parsed.size());
+ assertEquals(bean1, parsed.get(0));
+ assertEquals(bean2, parsed.get(1));
+
+ }
+
+ private class MyRepresenter extends Representer {
+ /*
+ * Change the default order. Important data goes first.
+ */
+ @Override
+ protected Set<Property> getProperties(Class<? extends Object> type)
+ throws IntrospectionException {
+ if (type.isAssignableFrom(BigJavaBean.class)) {
+ Set<Property> standard = super.getProperties(type);
+ Set<Property> sorted = new TreeSet<Property>(new PropertyComparator());
+ sorted.addAll(standard);
+ return sorted;
+ } else {
+ return super.getProperties(type);
+ }
+ }
+
+ private class PropertyComparator implements Comparator<Property> {
+ public int compare(Property o1, Property o2) {
+ // important go first
+ List<String> order = new ArrayList<String>(Arrays.asList("id", "name",
+ "description", "address"));
+ for (String name : order) {
+ int c = compareByName(o1, o2, name);
+ if (c != 0) {
+ return c;
+ }
+ }
+ // all the rest
+ return o1.compareTo(o2);
+ }
+
+ private int compareByName(Property o1, Property o2, String name) {
+ if (o1.getName().equals(name)) {
+ return -1;
+ } else if (o2.getName().equals(name)) {
+ return 1;
+ }
+ return 0;// compare further
+ }
+ }
+
+ @Override
+ protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
+ Object propertyValue, Tag customTag) {
+ if (javaBean instanceof BigJavaBean) {
+ BigJavaBean bean = (BigJavaBean) javaBean;
+ NodeTuple standard = super.representJavaBeanProperty(javaBean, property,
+ propertyValue, customTag);
+ if (property.getName().equals("numbers")) {
+ // when the list is small, make it block collection style
+ if (bean.getNumbers().size() < 5) {
+ SequenceNode n = (SequenceNode) standard.getValueNode();
+ return new NodeTuple(standard.getKeyNode(), new SequenceNode(n.getTag(),
+ true, n.getValue(), n.getStartMark(), n.getEndMark(), false));
+ }
+ }
+ if (property.getName().equals("description")) {
+ // if description contains ':' use folded scalar style and
+ // not single quoted scalar style
+ if (bean.getDescription().indexOf(':') > 0) {
+ ScalarNode n = (ScalarNode) standard.getValueNode();
+ return new NodeTuple(standard.getKeyNode(), new ScalarNode(n.getTag(),
+ n.getValue(), n.getStartMark(), n.getEndMark(), '>'));
+ }
+ }
+ return standard;
+ } else {
+ return super
+ .representJavaBeanProperty(javaBean, property, propertyValue, customTag);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue38/BigNumberIdTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue38/BigNumberIdTest.java
index 076c60f..4bbc4d3 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue38/BigNumberIdTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue38/BigNumberIdTest.java
@@ -1,47 +1,47 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue38;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=38
- */
-public class BigNumberIdTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testBigNumberFormat() {
- List<Bean> list = new ArrayList<Bean>(2000);
- for (int i = 1; i < 1010; i++) {
- Bean value = new Bean(i);
- list.add(value);
- list.add(value);
- }
- Yaml yaml = new Yaml();
- String output = yaml.dump(list);
- // System.out.println(output);
- //
- List<Bean> list2 = (List<Bean>) yaml.load(output);
- for (Bean bean : list2) {
- assertTrue(bean.getValue() > 0);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue38;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=38
+ */
+public class BigNumberIdTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testBigNumberFormat() {
+ List<Bean> list = new ArrayList<Bean>(2000);
+ for (int i = 1; i < 1010; i++) {
+ Bean value = new Bean(i);
+ list.add(value);
+ list.add(value);
+ }
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(list);
+ // System.out.println(output);
+ //
+ List<Bean> list2 = (List<Bean>) yaml.load(output);
+ for (Bean bean : list2) {
+ assertTrue(bean.getValue() > 0);
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue46/FileTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue46/FileTest.java
index ffcb2fd..684b4e1 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue46/FileTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue46/FileTest.java
@@ -1,64 +1,64 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue46;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Represent;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * Issue 46: Dump a java.io.File object
- */
-public class FileTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void test() {
- File file = new File("src/test/resources/examples/list-bean-1.yaml");
- assertTrue(file.exists());
- Yaml yaml = new Yaml(new MyRepresenter());
- Map<String, File> map = new HashMap<String, File>();
- map.put("one", file);
- String output = yaml.dump(map);
- // System.out.println(output);
- assertTrue(output, output.startsWith("{one: !!java.io.File '"));
- assertTrue(output, output.endsWith("list-bean-1.yaml'}\n"));
- Map<String, File> parsed = (Map<String, File>) yaml.load(output);
- File file2 = parsed.get("one");
- assertTrue(file2.getAbsolutePath(), file2.getAbsolutePath().endsWith("list-bean-1.yaml"));
- }
-
- public class MyRepresenter extends Representer {
- public MyRepresenter() {
- this.representers.put(File.class, new FileRepresenter());
- }
-
- public class FileRepresenter implements Represent {
- public Node representData(Object data) {
- File file = (File) data;
- Node scalar = representScalar(new Tag("!!java.io.File"), file.getAbsolutePath());
- return scalar;
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue46;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Represent;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * Issue 46: Dump a java.io.File object
+ */
+public class FileTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void test() {
+ File file = new File("src/test/resources/examples/list-bean-1.yaml");
+ assertTrue(file.exists());
+ Yaml yaml = new Yaml(new MyRepresenter());
+ Map<String, File> map = new HashMap<String, File>();
+ map.put("one", file);
+ String output = yaml.dump(map);
+ // System.out.println(output);
+ assertTrue(output, output.startsWith("{one: !!java.io.File '"));
+ assertTrue(output, output.endsWith("list-bean-1.yaml'}\n"));
+ Map<String, File> parsed = (Map<String, File>) yaml.load(output);
+ File file2 = parsed.get("one");
+ assertTrue(file2.getAbsolutePath(), file2.getAbsolutePath().endsWith("list-bean-1.yaml"));
+ }
+
+ public class MyRepresenter extends Representer {
+ public MyRepresenter() {
+ this.representers.put(File.class, new FileRepresenter());
+ }
+
+ public class FileRepresenter implements Represent {
+ public Node representData(Object data) {
+ File file = (File) data;
+ Node scalar = representScalar(new Tag("!!java.io.File"), file.getAbsolutePath());
+ return scalar;
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue56/CodeBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue56/CodeBean.java
index f25b0a4..336ab81 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue56/CodeBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue56/CodeBean.java
@@ -1,57 +1,57 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue56;
-
-public class CodeBean {
- private String country;
- private String type;
- private String value;
- public static int counter;
-
- public CodeBean() {
- counter++;
- }
-
- public String getCountry() {
- return country;
- }
-
- public void setCountry(String country) {
- this.country = country;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- @Override
- public String toString() {
- return "CodeBean: " + getValue();
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue56;
+
+public class CodeBean {
+ private String country;
+ private String type;
+ private String value;
+ public static int counter;
+
+ public CodeBean() {
+ counter++;
+ }
+
+ public String getCountry() {
+ return country;
+ }
+
+ public void setCountry(String country) {
+ this.country = country;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return "CodeBean: " + getValue();
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue56/PerlTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue56/PerlTest.java
index 36e712a..5655667 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue56/PerlTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue56/PerlTest.java
@@ -1,115 +1,115 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue56;
-
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Construct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class PerlTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testMaps() {
- Yaml yaml = new Yaml(new CustomConstructor());
- String input = Util.getLocalResource("issues/issue56-1.yaml");
- int counter = 0;
- for (Object obj : yaml.loadAll(input)) {
- // System.out.println(obj);
- Map<String, Object> map = (Map<String, Object>) obj;
- Integer oid = (Integer) map.get("oid");
- assertTrue(oid > 10000);
- counter++;
- }
- assertEquals(4, counter);
- assertEquals(0, CodeBean.counter);
- }
-
- private class CustomConstructor extends SafeConstructor {
- public CustomConstructor() {
- // define tags which begin with !org.yaml.
- String prefix = "!de.oddb.org,2007/ODDB";
- this.yamlMultiConstructors.put(prefix, new ConstructYamlMap());
- }
- }
-
- @SuppressWarnings("unchecked")
- public void testJavaBeanWithTypeDescription() {
- Constructor c = new CustomBeanConstructor();
- TypeDescription descr = new TypeDescription(CodeBean.class, new Tag(
- "!de.oddb.org,2007/ODDB::Util::Code"));
- c.addTypeDescription(descr);
- Yaml yaml = new Yaml(c);
- String input = Util.getLocalResource("issues/issue56-1.yaml");
- int counter = 0;
- for (Object obj : yaml.loadAll(input)) {
- // System.out.println(obj);
- Map<String, Object> map = (Map<String, Object>) obj;
- Integer oid = (Integer) map.get("oid");
- assertTrue(oid > 10000);
- counter++;
- }
- assertEquals(4, counter);
- assertEquals(55, CodeBean.counter);
- }
-
- @SuppressWarnings("unchecked")
- public void testJavaBean() {
- Constructor c = new CustomBeanConstructor();
- Yaml yaml = new Yaml(c);
- String input = Util.getLocalResource("issues/issue56-1.yaml");
- int counter = 0;
- for (Object obj : yaml.loadAll(input)) {
- // System.out.println(obj);
- Map<String, Object> map = (Map<String, Object>) obj;
- Integer oid = (Integer) map.get("oid");
- assertTrue(oid > 10000);
- counter++;
- }
- assertEquals(4, counter);
- assertEquals(55, CodeBean.counter);
- }
-
- private class CustomBeanConstructor extends Constructor {
- public CustomBeanConstructor() {
- // define tags which begin with !org.yaml.
- String prefix = "!de.oddb.org,2007/ODDB";
- this.yamlMultiConstructors.put(prefix, new ConstructYamlMap());
- }
-
- protected Construct getConstructor(Node node) {
- if (node.getTag().equals(new Tag("!de.oddb.org,2007/ODDB::Util::Code"))) {
- node.setUseClassConstructor(true);
- node.setType(CodeBean.class);
- }
- return super.getConstructor(node);
- }
- }
-
- @Override
- protected void setUp() {
- CodeBean.counter = 0;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue56;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Construct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.constructor.SafeConstructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class PerlTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testMaps() {
+ Yaml yaml = new Yaml(new CustomConstructor());
+ String input = Util.getLocalResource("issues/issue56-1.yaml");
+ int counter = 0;
+ for (Object obj : yaml.loadAll(input)) {
+ // System.out.println(obj);
+ Map<String, Object> map = (Map<String, Object>) obj;
+ Integer oid = (Integer) map.get("oid");
+ assertTrue(oid > 10000);
+ counter++;
+ }
+ assertEquals(4, counter);
+ assertEquals(0, CodeBean.counter);
+ }
+
+ private class CustomConstructor extends SafeConstructor {
+ public CustomConstructor() {
+ // define tags which begin with !org.yaml.
+ String prefix = "!de.oddb.org,2007/ODDB";
+ this.yamlMultiConstructors.put(prefix, new ConstructYamlMap());
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testJavaBeanWithTypeDescription() {
+ Constructor c = new CustomBeanConstructor();
+ TypeDescription descr = new TypeDescription(CodeBean.class, new Tag(
+ "!de.oddb.org,2007/ODDB::Util::Code"));
+ c.addTypeDescription(descr);
+ Yaml yaml = new Yaml(c);
+ String input = Util.getLocalResource("issues/issue56-1.yaml");
+ int counter = 0;
+ for (Object obj : yaml.loadAll(input)) {
+ // System.out.println(obj);
+ Map<String, Object> map = (Map<String, Object>) obj;
+ Integer oid = (Integer) map.get("oid");
+ assertTrue(oid > 10000);
+ counter++;
+ }
+ assertEquals(4, counter);
+ assertEquals(55, CodeBean.counter);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testJavaBean() {
+ Constructor c = new CustomBeanConstructor();
+ Yaml yaml = new Yaml(c);
+ String input = Util.getLocalResource("issues/issue56-1.yaml");
+ int counter = 0;
+ for (Object obj : yaml.loadAll(input)) {
+ // System.out.println(obj);
+ Map<String, Object> map = (Map<String, Object>) obj;
+ Integer oid = (Integer) map.get("oid");
+ assertTrue(oid > 10000);
+ counter++;
+ }
+ assertEquals(4, counter);
+ assertEquals(55, CodeBean.counter);
+ }
+
+ private class CustomBeanConstructor extends Constructor {
+ public CustomBeanConstructor() {
+ // define tags which begin with !org.yaml.
+ String prefix = "!de.oddb.org,2007/ODDB";
+ this.yamlMultiConstructors.put(prefix, new ConstructYamlMap());
+ }
+
+ protected Construct getConstructor(Node node) {
+ if (node.getTag().equals(new Tag("!de.oddb.org,2007/ODDB::Util::Code"))) {
+ node.setUseClassConstructor(true);
+ node.setType(CodeBean.class);
+ }
+ return super.getConstructor(node);
+ }
+ }
+
+ @Override
+ protected void setUp() {
+ CodeBean.counter = 0;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue60/CustomOrderTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue60/CustomOrderTest.java
index 9dd9fce..d0aea8a 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue60/CustomOrderTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue60/CustomOrderTest.java
@@ -1,85 +1,85 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue60;
-
-import java.beans.IntrospectionException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.introspector.BeanAccess;
-import org.yaml.snakeyaml.introspector.Property;
-import org.yaml.snakeyaml.introspector.PropertyUtils;
-import org.yaml.snakeyaml.representer.Representer;
-
-//issue 59
-public class CustomOrderTest extends TestCase {
-
- public void testReversedOrder() {
- Representer repr = new Representer();
- repr.setPropertyUtils(new ReversedPropertyUtils());
- Yaml yaml = new Yaml(repr);
- String output = yaml.dump(getBean());
- // System.out.println(output);
- assertEquals(Util.getLocalResource("issues/issue59-1.yaml"), output);
- }
-
- private class ReversedPropertyUtils extends PropertyUtils {
- @Override
- protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess)
- throws IntrospectionException {
- Set<Property> result = new TreeSet<Property>(Collections.reverseOrder());
- result.addAll(super.createPropertySet(type, bAccess));
- return result;
- }
- }
-
- public void testUnsorted() {
- Representer repr = new Representer();
- repr.setPropertyUtils(new UnsortedPropertyUtils());
- Yaml yaml = new Yaml(repr);
- String output = yaml.dump(getBean());
- // System.out.println(output);
- assertEquals(Util.getLocalResource("issues/issue59-2.yaml"), output);
- }
-
- private class UnsortedPropertyUtils extends PropertyUtils {
- @Override
- protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess)
- throws IntrospectionException {
- Set<Property> result = new LinkedHashSet<Property>(getPropertiesMap(type,
- BeanAccess.FIELD).values());
- result.remove(result.iterator().next());// drop 'listInt' property
- return result;
- }
- }
-
- private SkipBean getBean() {
- SkipBean bean = new SkipBean();
- bean.setText("foo");
- bean.setListDate(null);
- bean.setListInt(Arrays.asList(new Integer[] { null, 1, 2, 3 }));
- bean.setListStr(Arrays.asList(new String[] { "bar", null, "foo", null }));
- return bean;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue60;
+
+import java.beans.IntrospectionException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.introspector.BeanAccess;
+import org.yaml.snakeyaml.introspector.Property;
+import org.yaml.snakeyaml.introspector.PropertyUtils;
+import org.yaml.snakeyaml.representer.Representer;
+
+//issue 59
+public class CustomOrderTest extends TestCase {
+
+ public void testReversedOrder() {
+ Representer repr = new Representer();
+ repr.setPropertyUtils(new ReversedPropertyUtils());
+ Yaml yaml = new Yaml(repr);
+ String output = yaml.dump(getBean());
+ // System.out.println(output);
+ assertEquals(Util.getLocalResource("issues/issue59-1.yaml"), output);
+ }
+
+ private class ReversedPropertyUtils extends PropertyUtils {
+ @Override
+ protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess)
+ throws IntrospectionException {
+ Set<Property> result = new TreeSet<Property>(Collections.reverseOrder());
+ result.addAll(super.createPropertySet(type, bAccess));
+ return result;
+ }
+ }
+
+ public void testUnsorted() {
+ Representer repr = new Representer();
+ repr.setPropertyUtils(new UnsortedPropertyUtils());
+ Yaml yaml = new Yaml(repr);
+ String output = yaml.dump(getBean());
+ // System.out.println(output);
+ assertEquals(Util.getLocalResource("issues/issue59-2.yaml"), output);
+ }
+
+ private class UnsortedPropertyUtils extends PropertyUtils {
+ @Override
+ protected Set<Property> createPropertySet(Class<? extends Object> type, BeanAccess bAccess)
+ throws IntrospectionException {
+ Set<Property> result = new LinkedHashSet<Property>(getPropertiesMap(type,
+ BeanAccess.FIELD).values());
+ result.remove(result.iterator().next());// drop 'listInt' property
+ return result;
+ }
+ }
+
+ private SkipBean getBean() {
+ SkipBean bean = new SkipBean();
+ bean.setText("foo");
+ bean.setListDate(null);
+ bean.setListInt(Arrays.asList(new Integer[] { null, 1, 2, 3 }));
+ bean.setListStr(Arrays.asList(new String[] { "bar", null, "foo", null }));
+ return bean;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBean.java
index 39f6d38..ddf15a2 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBean.java
@@ -1,91 +1,91 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue60;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class SkipBean {
-
- private List<Integer> listInt;
- private List<String> listStr;
- private List<Date> listDate;
- private List<File> empty = new ArrayList<File>(0);
- private Map<String, Integer> map = new HashMap<String, Integer>(0);
- private String text;
- private Integer number;
-
- public List<Integer> getListInt() {
- return listInt;
- }
-
- public void setListInt(List<Integer> listInt) {
- this.listInt = listInt;
- }
-
- public List<String> getListStr() {
- return listStr;
- }
-
- public void setListStr(List<String> listStr) {
- this.listStr = listStr;
- }
-
- public List<Date> getListDate() {
- return listDate;
- }
-
- public void setListDate(List<Date> listDate) {
- this.listDate = listDate;
- }
-
- public String getText() {
- return text;
- }
-
- public void setText(String text) {
- this.text = text;
- }
-
- public Integer getNumber() {
- return number;
- }
-
- public void setNumber(Integer number) {
- this.number = number;
- }
-
- public List<File> getEmpty() {
- return empty;
- }
-
- public void setEmpty(List<File> empty) {
- this.empty = empty;
- }
-
- public Map<String, Integer> getMap() {
- return map;
- }
-
- public void setMap(Map<String, Integer> map) {
- this.map = map;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue60;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class SkipBean {
+
+ private List<Integer> listInt;
+ private List<String> listStr;
+ private List<Date> listDate;
+ private List<File> empty = new ArrayList<File>(0);
+ private Map<String, Integer> map = new HashMap<String, Integer>(0);
+ private String text;
+ private Integer number;
+
+ public List<Integer> getListInt() {
+ return listInt;
+ }
+
+ public void setListInt(List<Integer> listInt) {
+ this.listInt = listInt;
+ }
+
+ public List<String> getListStr() {
+ return listStr;
+ }
+
+ public void setListStr(List<String> listStr) {
+ this.listStr = listStr;
+ }
+
+ public List<Date> getListDate() {
+ return listDate;
+ }
+
+ public void setListDate(List<Date> listDate) {
+ this.listDate = listDate;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public Integer getNumber() {
+ return number;
+ }
+
+ public void setNumber(Integer number) {
+ this.number = number;
+ }
+
+ public List<File> getEmpty() {
+ return empty;
+ }
+
+ public void setEmpty(List<File> empty) {
+ this.empty = empty;
+ }
+
+ public Map<String, Integer> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<String, Integer> map) {
+ this.map = map;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBeanTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBeanTest.java
index 069f406..66f600b 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue60/SkipBeanTest.java
@@ -1,99 +1,99 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue60;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.introspector.Property;
-import org.yaml.snakeyaml.nodes.CollectionNode;
-import org.yaml.snakeyaml.nodes.MappingNode;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeTuple;
-import org.yaml.snakeyaml.nodes.SequenceNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class SkipBeanTest extends TestCase {
-
- public void testSkipNull() {
- Yaml yaml = new Yaml(new SkipNullRepresenter());
- String output = yaml.dump(getBean());
- // System.out.println(output);
- assertEquals(Util.getLocalResource("issues/issue60-1.yaml"), output);
- }
-
- private class SkipNullRepresenter extends Representer {
- @Override
- protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
- Object propertyValue, Tag customTag) {
- if (propertyValue == null) {
- return null;
- } else {
- return super
- .representJavaBeanProperty(javaBean, property, propertyValue, customTag);
- }
- }
- }
-
- public void testSkipEmptyCollections() {
- Yaml yaml = new Yaml(new SkipEmptyRepresenter());
- String output = yaml.dump(getBean());
- // System.out.println(output);
- assertEquals(Util.getLocalResource("issues/issue60-2.yaml"), output);
- }
-
- private class SkipEmptyRepresenter extends Representer {
- @Override
- protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
- Object propertyValue, Tag customTag) {
- NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue,
- customTag);
- Node valueNode = tuple.getValueNode();
- if (Tag.NULL.equals(valueNode.getTag())) {
- return null;// skip 'null' values
- }
- if (valueNode instanceof CollectionNode) {
- if (Tag.SEQ.equals(valueNode.getTag())) {
- SequenceNode seq = (SequenceNode) valueNode;
- if (seq.getValue().isEmpty()) {
- return null;// skip empty lists
- }
- }
- if (Tag.MAP.equals(valueNode.getTag())) {
- MappingNode seq = (MappingNode) valueNode;
- if (seq.getValue().isEmpty()) {
- return null;// skip empty maps
- }
- }
- }
- return tuple;
- }
- }
-
- private SkipBean getBean() {
- SkipBean bean = new SkipBean();
- bean.setText("foo");
- bean.setListDate(null);
- bean.setListInt(Arrays.asList(new Integer[] { null, 1, 2, 3 }));
- bean.setListStr(Arrays.asList(new String[] { "bar", null, "foo", null }));
- return bean;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue60;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.introspector.Property;
+import org.yaml.snakeyaml.nodes.CollectionNode;
+import org.yaml.snakeyaml.nodes.MappingNode;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeTuple;
+import org.yaml.snakeyaml.nodes.SequenceNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class SkipBeanTest extends TestCase {
+
+ public void testSkipNull() {
+ Yaml yaml = new Yaml(new SkipNullRepresenter());
+ String output = yaml.dump(getBean());
+ // System.out.println(output);
+ assertEquals(Util.getLocalResource("issues/issue60-1.yaml"), output);
+ }
+
+ private class SkipNullRepresenter extends Representer {
+ @Override
+ protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
+ Object propertyValue, Tag customTag) {
+ if (propertyValue == null) {
+ return null;
+ } else {
+ return super
+ .representJavaBeanProperty(javaBean, property, propertyValue, customTag);
+ }
+ }
+ }
+
+ public void testSkipEmptyCollections() {
+ Yaml yaml = new Yaml(new SkipEmptyRepresenter());
+ String output = yaml.dump(getBean());
+ // System.out.println(output);
+ assertEquals(Util.getLocalResource("issues/issue60-2.yaml"), output);
+ }
+
+ private class SkipEmptyRepresenter extends Representer {
+ @Override
+ protected NodeTuple representJavaBeanProperty(Object javaBean, Property property,
+ Object propertyValue, Tag customTag) {
+ NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue,
+ customTag);
+ Node valueNode = tuple.getValueNode();
+ if (Tag.NULL.equals(valueNode.getTag())) {
+ return null;// skip 'null' values
+ }
+ if (valueNode instanceof CollectionNode) {
+ if (Tag.SEQ.equals(valueNode.getTag())) {
+ SequenceNode seq = (SequenceNode) valueNode;
+ if (seq.getValue().isEmpty()) {
+ return null;// skip empty lists
+ }
+ }
+ if (Tag.MAP.equals(valueNode.getTag())) {
+ MappingNode seq = (MappingNode) valueNode;
+ if (seq.getValue().isEmpty()) {
+ return null;// skip empty maps
+ }
+ }
+ }
+ return tuple;
+ }
+ }
+
+ private SkipBean getBean() {
+ SkipBean bean = new SkipBean();
+ bean.setText("foo");
+ bean.setListDate(null);
+ bean.setListInt(Arrays.asList(new Integer[] { null, 1, 2, 3 }));
+ bean.setListStr(Arrays.asList(new String[] { "bar", null, "foo", null }));
+ return bean;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericListBeanTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericListBeanTest.java
index 6538d25..810da04 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericListBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericListBeanTest.java
@@ -1,118 +1,118 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue61;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-public class GenericListBeanTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testGenericList() {
- Yaml yaml = new Yaml();
- ListProvider<String> listProvider = new ListProvider<String>();
- listProvider.getList().add("foo");
- listProvider.getList().add("bar");
- String s = yaml.dumpAsMap(listProvider);
- // System.out.println(s);
- assertEquals("list:\n- foo\n- bar\n", s);
- // parse
- Yaml loader = new Yaml();
- ListProvider<String> listProvider2 = loader.loadAs(s, ListProvider.class);
- assertEquals("foo", listProvider2.getList().get(0));
- assertEquals("bar", listProvider2.getList().get(1));
- assertEquals(listProvider, listProvider2);
- }
-
- @SuppressWarnings("rawtypes")
- public void testGenericBean() {
- Yaml yaml = new Yaml();
- ListProvider<Bean> listProvider = new ListProvider<Bean>();
- Bean foo = new Bean();
- foo.setName("foo");
- listProvider.getList().add(foo);
- Bean bar = new Bean();
- bar.setName("bar");
- bar.setNumber(3);
- listProvider.getList().add(bar);
- String s = yaml.dumpAsMap(listProvider);
- // System.out.println(s);
- String etalon = Util.getLocalResource("issues/issue61-1.yaml");
- assertEquals(etalon, s);
- // parse
- Yaml loader = new Yaml();
- ListProvider listProvider2 = loader.loadAs(s, ListProvider.class);
- Bean foo2 = (Bean) listProvider2.getList().get(0);
- assertEquals("foo", foo2.getName());
- assertEquals(0, foo2.getNumber());
- Bean bar2 = (Bean) listProvider2.getList().get(1);
- assertEquals("bar", bar2.getName());
- assertEquals(3, bar2.getNumber());
- }
-
- public static class ListProvider<T> {
- private List<T> list = new ArrayList<T>();
-
- public List<T> getList() {
- return list;
- }
-
- public void setList(List<T> list) {
- this.list = list;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ListProvider) {
- return list.equals(((ListProvider) obj).getList());
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return list.hashCode();
- }
- }
-
- public static class Bean {
- private String name;
- private int number;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue61;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+public class GenericListBeanTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testGenericList() {
+ Yaml yaml = new Yaml();
+ ListProvider<String> listProvider = new ListProvider<String>();
+ listProvider.getList().add("foo");
+ listProvider.getList().add("bar");
+ String s = yaml.dumpAsMap(listProvider);
+ // System.out.println(s);
+ assertEquals("list:\n- foo\n- bar\n", s);
+ // parse
+ Yaml loader = new Yaml();
+ ListProvider<String> listProvider2 = loader.loadAs(s, ListProvider.class);
+ assertEquals("foo", listProvider2.getList().get(0));
+ assertEquals("bar", listProvider2.getList().get(1));
+ assertEquals(listProvider, listProvider2);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void testGenericBean() {
+ Yaml yaml = new Yaml();
+ ListProvider<Bean> listProvider = new ListProvider<Bean>();
+ Bean foo = new Bean();
+ foo.setName("foo");
+ listProvider.getList().add(foo);
+ Bean bar = new Bean();
+ bar.setName("bar");
+ bar.setNumber(3);
+ listProvider.getList().add(bar);
+ String s = yaml.dumpAsMap(listProvider);
+ // System.out.println(s);
+ String etalon = Util.getLocalResource("issues/issue61-1.yaml");
+ assertEquals(etalon, s);
+ // parse
+ Yaml loader = new Yaml();
+ ListProvider listProvider2 = loader.loadAs(s, ListProvider.class);
+ Bean foo2 = (Bean) listProvider2.getList().get(0);
+ assertEquals("foo", foo2.getName());
+ assertEquals(0, foo2.getNumber());
+ Bean bar2 = (Bean) listProvider2.getList().get(1);
+ assertEquals("bar", bar2.getName());
+ assertEquals(3, bar2.getNumber());
+ }
+
+ public static class ListProvider<T> {
+ private List<T> list = new ArrayList<T>();
+
+ public List<T> getList() {
+ return list;
+ }
+
+ public void setList(List<T> list) {
+ this.list = list;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ListProvider) {
+ return list.equals(((ListProvider) obj).getList());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return list.hashCode();
+ }
+ }
+
+ public static class Bean {
+ private String name;
+ private int number;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericMapBeanTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericMapBeanTest.java
index d0f090e..1814723 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericMapBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue61/GenericMapBeanTest.java
@@ -1,118 +1,118 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue61;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-public class GenericMapBeanTest extends TestCase {
- @SuppressWarnings("unchecked")
- public void testGenericMap() {
- Yaml yaml = new Yaml();
- MapProvider<String, Integer> listProvider = new MapProvider<String, Integer>();
- listProvider.getMap().put("foo", 17);
- listProvider.getMap().put("bar", 19);
- String s = yaml.dumpAsMap(listProvider);
- // System.out.println(s);
- assertEquals("map:\n foo: 17\n bar: 19\n", s);
- // parse
- Yaml loader = new Yaml();
- MapProvider<String, Integer> listProvider2 = loader.loadAs(s, MapProvider.class);
- assertEquals(new Integer(17), listProvider2.getMap().get("foo"));
- assertEquals(new Integer(19), listProvider2.getMap().get("bar"));
- assertEquals(listProvider, listProvider2);
- }
-
- @SuppressWarnings("rawtypes")
- public void testGenericBean() {
- Yaml yaml = new Yaml();
- MapProvider<String, Bean> listProvider = new MapProvider<String, Bean>();
- Bean foo = new Bean();
- foo.setName("foo");
- listProvider.getMap().put("foo", foo);
- Bean bar = new Bean();
- bar.setName("bar");
- bar.setNumber(3);
- listProvider.getMap().put("bar", bar);
- String s = yaml.dumpAsMap(listProvider);
- // System.out.println(s);
- String etalon = Util.getLocalResource("issues/issue61-2.yaml");
- assertEquals(etalon, s);
- // parse
- Yaml loader = new Yaml();
- MapProvider listProvider2 = loader.loadAs(s, MapProvider.class);
- Bean foo2 = (Bean) listProvider2.getMap().get("foo");
- assertEquals("foo", foo2.getName());
- assertEquals(0, foo2.getNumber());
- Bean bar2 = (Bean) listProvider2.getMap().get("bar");
- assertEquals("bar", bar2.getName());
- assertEquals(3, bar2.getNumber());
- }
-
- public static class MapProvider<K, V> {
- private Map<K, V> map = new HashMap<K, V>();
-
- public Map<K, V> getMap() {
- return map;
- }
-
- public void setMap(Map<K, V> map) {
- this.map = map;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof MapProvider) {
- return map.equals(((MapProvider) obj).getMap());
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return map.hashCode();
- }
- }
-
- public static class Bean {
- private String name;
- private int number;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue61;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+public class GenericMapBeanTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ public void testGenericMap() {
+ Yaml yaml = new Yaml();
+ MapProvider<String, Integer> listProvider = new MapProvider<String, Integer>();
+ listProvider.getMap().put("foo", 17);
+ listProvider.getMap().put("bar", 19);
+ String s = yaml.dumpAsMap(listProvider);
+ // System.out.println(s);
+ assertEquals("map:\n foo: 17\n bar: 19\n", s);
+ // parse
+ Yaml loader = new Yaml();
+ MapProvider<String, Integer> listProvider2 = loader.loadAs(s, MapProvider.class);
+ assertEquals(new Integer(17), listProvider2.getMap().get("foo"));
+ assertEquals(new Integer(19), listProvider2.getMap().get("bar"));
+ assertEquals(listProvider, listProvider2);
+ }
+
+ @SuppressWarnings("rawtypes")
+ public void testGenericBean() {
+ Yaml yaml = new Yaml();
+ MapProvider<String, Bean> listProvider = new MapProvider<String, Bean>();
+ Bean foo = new Bean();
+ foo.setName("foo");
+ listProvider.getMap().put("foo", foo);
+ Bean bar = new Bean();
+ bar.setName("bar");
+ bar.setNumber(3);
+ listProvider.getMap().put("bar", bar);
+ String s = yaml.dumpAsMap(listProvider);
+ // System.out.println(s);
+ String etalon = Util.getLocalResource("issues/issue61-2.yaml");
+ assertEquals(etalon, s);
+ // parse
+ Yaml loader = new Yaml();
+ MapProvider listProvider2 = loader.loadAs(s, MapProvider.class);
+ Bean foo2 = (Bean) listProvider2.getMap().get("foo");
+ assertEquals("foo", foo2.getName());
+ assertEquals(0, foo2.getNumber());
+ Bean bar2 = (Bean) listProvider2.getMap().get("bar");
+ assertEquals("bar", bar2.getName());
+ assertEquals(3, bar2.getNumber());
+ }
+
+ public static class MapProvider<K, V> {
+ private Map<K, V> map = new HashMap<K, V>();
+
+ public Map<K, V> getMap() {
+ return map;
+ }
+
+ public void setMap(Map<K, V> map) {
+ this.map = map;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof MapProvider) {
+ return map.equals(((MapProvider) obj).getMap());
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return map.hashCode();
+ }
+ }
+
+ public static class Bean {
+ private String name;
+ private int number;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue67/NonAsciiCharsInClassNameTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue67/NonAsciiCharsInClassNameTest.java
index 0e620f4..c70f1a5 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue67/NonAsciiCharsInClassNameTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue67/NonAsciiCharsInClassNameTest.java
@@ -1,133 +1,133 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue67;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.LoaderOptions;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-import org.yaml.snakeyaml.scanner.ScannerException;
-
-public class NonAsciiCharsInClassNameTest extends TestCase {
- private String PREFIX = "!!org.yaml.snakeyaml.issues.issue67.NonAsciiCharsInClassNameTest$";
-
- public void testDump() {
- Académico obj = new Académico();
- obj.setId(1);
- obj.setName("Foo bar baz");
- Yaml yaml = new Yaml();
- String result = yaml.dump(obj);
- assertEquals(PREFIX + "Acad%C3%A9mico {\n id: 1, name: Foo bar baz}\n", result);
- }
-
- public void testLoad() {
- Yaml yaml = new Yaml();
- Académico obj = (Académico) yaml.load(PREFIX + "Acad%C3%A9mico {id: 3, name: Foo bar}");
- assertEquals(3, obj.getId());
- assertEquals("Foo bar", obj.getName());
- }
-
- public void testLoadInvalidPattern() {
- try {
- Yaml yaml = new Yaml();
- yaml.load(PREFIX + "Acad%WZ%A9mico {id: 3, name: Foo bar}");
- fail("Illegal hex characters in escape (%) pattern must not be accepted.");
- } catch (Exception e) {
- assertEquals(
- "while scanning a tag; expected URI escape sequence of 2 hexadecimal numbers, but found W(87) and Z(90)",
- e.getMessage());
- }
- }
-
- public void testLoadInvalidPatternTooShort() {
- try {
- LoaderOptions options = new LoaderOptions();
- Yaml yaml = new Yaml(options);
- yaml.load(PREFIX + "Acad%9%A9mico {id: 3, name: Foo bar}");
- fail("Illegal hex characters in escape (%) pattern must not be accepted.");
- } catch (ScannerException e) {
- assertEquals(
- "while scanning a tag; expected URI escape sequence of 2 hexadecimal numbers, but found 9(57) and %(37)",
- e.getMessage());
- assertEquals(Util.getLocalResource("issues/issue67-error1.txt"), e.toString());
- }
- }
-
- public void testLoadInvalidUtf8() {
- try {
- LoaderOptions options = new LoaderOptions();
- Yaml yaml = new Yaml(options);
- yaml.load(PREFIX + "Acad%C0mico {id: 3, name: Foo bar}");
- fail("Illegal UTF-8 must not be accepted.");
- } catch (ScannerException e) {
- assertEquals("while scanning a tag; expected URI in UTF-8: Input length = 1",
- e.getMessage());
- assertEquals(Util.getLocalResource("issues/issue67-error2.txt"), e.toString());
- }
- }
-
- public static class Académico {
- public int getId() {
- return id;
- }
-
- public void setId(int id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- private int id;
- private String name;
- }
-
- public void testDumpCustomTag() {
- Académico obj = new Académico();
- obj.setId(123);
- obj.setName("Foo bar 123");
- Representer repr = new Representer();
- repr.addClassTag(Académico.class, new Tag("!foo"));
- Yaml yaml = new Yaml(repr);
- String result = yaml.dump(obj);
- assertEquals("!foo {id: 123, name: Foo bar 123}\n", result);
- }
-
- public void testDumpEscapedTag() {
- Académico obj = new Académico();
- obj.setId(123);
- obj.setName("Foo bar 123");
- Representer repr = new Representer();
- repr.addClassTag(Académico.class, new Tag("!Académico"));
- Yaml yaml = new Yaml(repr);
- String result = yaml.dump(obj);
- assertEquals("!Acad%C3%A9mico {id: 123, name: Foo bar 123}\n", result);
- }
-
- public void testTag() {
- Tag tag = new Tag("!java/javabean:foo.Bar");
- assertEquals("!java/javabean:foo.Bar", tag.getValue());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue67;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.LoaderOptions;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+import org.yaml.snakeyaml.scanner.ScannerException;
+
+public class NonAsciiCharsInClassNameTest extends TestCase {
+ private String PREFIX = "!!org.yaml.snakeyaml.issues.issue67.NonAsciiCharsInClassNameTest$";
+
+ public void testDump() {
+ Académico obj = new Académico();
+ obj.setId(1);
+ obj.setName("Foo bar baz");
+ Yaml yaml = new Yaml();
+ String result = yaml.dump(obj);
+ assertEquals(PREFIX + "Acad%C3%A9mico {\n id: 1, name: Foo bar baz}\n", result);
+ }
+
+ public void testLoad() {
+ Yaml yaml = new Yaml();
+ Académico obj = (Académico) yaml.load(PREFIX + "Acad%C3%A9mico {id: 3, name: Foo bar}");
+ assertEquals(3, obj.getId());
+ assertEquals("Foo bar", obj.getName());
+ }
+
+ public void testLoadInvalidPattern() {
+ try {
+ Yaml yaml = new Yaml();
+ yaml.load(PREFIX + "Acad%WZ%A9mico {id: 3, name: Foo bar}");
+ fail("Illegal hex characters in escape (%) pattern must not be accepted.");
+ } catch (Exception e) {
+ assertEquals(
+ "while scanning a tag; expected URI escape sequence of 2 hexadecimal numbers, but found W(87) and Z(90)",
+ e.getMessage());
+ }
+ }
+
+ public void testLoadInvalidPatternTooShort() {
+ try {
+ LoaderOptions options = new LoaderOptions();
+ Yaml yaml = new Yaml(options);
+ yaml.load(PREFIX + "Acad%9%A9mico {id: 3, name: Foo bar}");
+ fail("Illegal hex characters in escape (%) pattern must not be accepted.");
+ } catch (ScannerException e) {
+ assertEquals(
+ "while scanning a tag; expected URI escape sequence of 2 hexadecimal numbers, but found 9(57) and %(37)",
+ e.getMessage());
+ assertEquals(Util.getLocalResource("issues/issue67-error1.txt"), e.toString());
+ }
+ }
+
+ public void testLoadInvalidUtf8() {
+ try {
+ LoaderOptions options = new LoaderOptions();
+ Yaml yaml = new Yaml(options);
+ yaml.load(PREFIX + "Acad%C0mico {id: 3, name: Foo bar}");
+ fail("Illegal UTF-8 must not be accepted.");
+ } catch (ScannerException e) {
+ assertEquals("while scanning a tag; expected URI in UTF-8: Input length = 1",
+ e.getMessage());
+ assertEquals(Util.getLocalResource("issues/issue67-error2.txt"), e.toString());
+ }
+ }
+
+ public static class Académico {
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ private int id;
+ private String name;
+ }
+
+ public void testDumpCustomTag() {
+ Académico obj = new Académico();
+ obj.setId(123);
+ obj.setName("Foo bar 123");
+ Representer repr = new Representer();
+ repr.addClassTag(Académico.class, new Tag("!foo"));
+ Yaml yaml = new Yaml(repr);
+ String result = yaml.dump(obj);
+ assertEquals("!foo {id: 123, name: Foo bar 123}\n", result);
+ }
+
+ public void testDumpEscapedTag() {
+ Académico obj = new Académico();
+ obj.setId(123);
+ obj.setName("Foo bar 123");
+ Representer repr = new Representer();
+ repr.addClassTag(Académico.class, new Tag("!Académico"));
+ Yaml yaml = new Yaml(repr);
+ String result = yaml.dump(obj);
+ assertEquals("!Acad%C3%A9mico {id: 123, name: Foo bar 123}\n", result);
+ }
+
+ public void testTag() {
+ Tag tag = new Tag("!java/javabean:foo.Bar");
+ assertEquals("!java/javabean:foo.Bar", tag.getValue());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue68/NonAsciiCharacterTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue68/NonAsciiCharacterTest.java
index b42a049..b53607a 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue68/NonAsciiCharacterTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue68/NonAsciiCharacterTest.java
@@ -1,73 +1,73 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue68;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.YamlDocument;
-
-public class NonAsciiCharacterTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testLoad() {
- Yaml yaml = new Yaml();
- Map<String, Map<String, String>> obj = (Map<String, Map<String, String>>) yaml
- .load("test.string: {en: И}");
- assertEquals(1, obj.size());
- assertEquals("Map: " + obj.toString(), "И", obj.get("test.string").get("en"));
- }
-
- public void testLoadFromFileWithWrongEncoding() {
- try {
- Yaml yaml = new Yaml();
- InputStream input = new FileInputStream("src/test/resources/issues/issue68.txt");
- Object text = yaml.load(new InputStreamReader(input, "Cp1252"));
- input.close();
- fail("Invalid UTF-8 must not be accepted: " + text.toString());
- } catch (Exception e) {
- assertEquals("special characters are not allowed", e.getMessage());
- }
- }
-
- public void testLoadFromFile() throws UnsupportedEncodingException, FileNotFoundException {
- Yaml yaml = new Yaml();
- InputStream input = new FileInputStream("src/test/resources/issues/issue68.txt");
- String text = (String) yaml.load(new InputStreamReader(input, "UTF-8"));
- assertEquals("И жить торопится и чувствовать спешит...", text);
- }
-
- public void testLoadFromInputStream() throws IOException {
- InputStream input;
- input = YamlDocument.class.getClassLoader().getResourceAsStream("issues/issue68.txt");
- if (input == null) {
- throw new RuntimeException("Can not find issues/issue68.txt");
- }
- Yaml yaml = new Yaml();
- String text = (String) yaml.load(input);// UTF-8 by default
- assertEquals("И жить торопится и чувствовать спешит...", text);
- input.close();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue68;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.YamlDocument;
+
+public class NonAsciiCharacterTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testLoad() {
+ Yaml yaml = new Yaml();
+ Map<String, Map<String, String>> obj = (Map<String, Map<String, String>>) yaml
+ .load("test.string: {en: И}");
+ assertEquals(1, obj.size());
+ assertEquals("Map: " + obj.toString(), "И", obj.get("test.string").get("en"));
+ }
+
+ public void testLoadFromFileWithWrongEncoding() {
+ try {
+ Yaml yaml = new Yaml();
+ InputStream input = new FileInputStream("src/test/resources/issues/issue68.txt");
+ Object text = yaml.load(new InputStreamReader(input, "Cp1252"));
+ input.close();
+ fail("Invalid UTF-8 must not be accepted: " + text.toString());
+ } catch (Exception e) {
+ assertEquals("special characters are not allowed", e.getMessage());
+ }
+ }
+
+ public void testLoadFromFile() throws UnsupportedEncodingException, FileNotFoundException {
+ Yaml yaml = new Yaml();
+ InputStream input = new FileInputStream("src/test/resources/issues/issue68.txt");
+ String text = (String) yaml.load(new InputStreamReader(input, "UTF-8"));
+ assertEquals("И жить торопится и чувствовать спешит...", text);
+ }
+
+ public void testLoadFromInputStream() throws IOException {
+ InputStream input;
+ input = YamlDocument.class.getClassLoader().getResourceAsStream("issues/issue68.txt");
+ if (input == null) {
+ throw new RuntimeException("Can not find issues/issue68.txt");
+ }
+ Yaml yaml = new Yaml();
+ String text = (String) yaml.load(input);// UTF-8 by default
+ assertEquals("И жить торопится и чувствовать спешит...", text);
+ input.close();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue72/CollectionTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue72/CollectionTest.java
index 3980bd4..cbb71d4 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue72/CollectionTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue72/CollectionTest.java
@@ -1,88 +1,88 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue72;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class CollectionTest extends TestCase {
-
- public void testCollectionList() {
- CollectionList bean = new CollectionList();
- Yaml yaml = new Yaml();
- String doc = yaml.dumpAsMap(bean);
- // System.out.println(doc);
- Yaml beanLoader = new Yaml();
- CollectionList parsed = beanLoader.loadAs(doc, CollectionList.class);
- assertTrue(parsed.getNames().contains("aaa"));
- assertTrue(parsed.getNames().contains("bbb"));
- assertEquals(2, parsed.getNames().size());
- }
-
- public static class CollectionList {
- private Collection<String> names;
-
- public CollectionList() {
- names = new ArrayList<String>();
- names.add("aaa");
- names.add("bbb");
- }
-
- public Collection<String> getNames() {
- return names;
- }
-
- public void setNames(Collection<String> names) {
- this.names = names;
- }
- }
-
- public void testCollectionSet() {
- CollectionSet bean = new CollectionSet();
- Yaml yaml = new Yaml();
- String doc = yaml.dumpAsMap(bean);
- // System.out.println(doc);
- Yaml beanLoader = new Yaml();
- CollectionSet parsed = beanLoader.loadAs(doc, CollectionSet.class);
- assertTrue(parsed.getRoles().contains(11));
- assertTrue(parsed.getRoles().contains(13));
- assertEquals(2, parsed.getRoles().size());
- }
-
- public static class CollectionSet {
- private Collection<Integer> roles;
-
- public CollectionSet() {
- roles = new HashSet<Integer>();
- roles.add(11);
- roles.add(13);
- }
-
- public Collection<Integer> getRoles() {
- return roles;
- }
-
- public void setRoles(Collection<Integer> roles) {
- this.roles = roles;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue72;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class CollectionTest extends TestCase {
+
+ public void testCollectionList() {
+ CollectionList bean = new CollectionList();
+ Yaml yaml = new Yaml();
+ String doc = yaml.dumpAsMap(bean);
+ // System.out.println(doc);
+ Yaml beanLoader = new Yaml();
+ CollectionList parsed = beanLoader.loadAs(doc, CollectionList.class);
+ assertTrue(parsed.getNames().contains("aaa"));
+ assertTrue(parsed.getNames().contains("bbb"));
+ assertEquals(2, parsed.getNames().size());
+ }
+
+ public static class CollectionList {
+ private Collection<String> names;
+
+ public CollectionList() {
+ names = new ArrayList<String>();
+ names.add("aaa");
+ names.add("bbb");
+ }
+
+ public Collection<String> getNames() {
+ return names;
+ }
+
+ public void setNames(Collection<String> names) {
+ this.names = names;
+ }
+ }
+
+ public void testCollectionSet() {
+ CollectionSet bean = new CollectionSet();
+ Yaml yaml = new Yaml();
+ String doc = yaml.dumpAsMap(bean);
+ // System.out.println(doc);
+ Yaml beanLoader = new Yaml();
+ CollectionSet parsed = beanLoader.loadAs(doc, CollectionSet.class);
+ assertTrue(parsed.getRoles().contains(11));
+ assertTrue(parsed.getRoles().contains(13));
+ assertEquals(2, parsed.getRoles().size());
+ }
+
+ public static class CollectionSet {
+ private Collection<Integer> roles;
+
+ public CollectionSet() {
+ roles = new HashSet<Integer>();
+ roles.add(11);
+ roles.add(13);
+ }
+
+ public Collection<Integer> getRoles() {
+ return roles;
+ }
+
+ public void setRoles(Collection<Integer> roles) {
+ this.roles = roles;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue74/ArrayBeanTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue74/ArrayBeanTest.java
index e7558c6..b2e8682 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue74/ArrayBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue74/ArrayBeanTest.java
@@ -1,151 +1,151 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue74;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-public class ArrayBeanTest extends TestCase {
-
- public void testArrayProperty() {
- ArrayMember[] members = new ArrayMember[3];
- members[0] = new ArrayMember("Foo", 21);
- members[1] = new ArrayMember("Bar", 23);
- members[2] = new ArrayMember("Hue Long Hair", 25);
- ArrayBean bean = new ArrayBean();
- bean.setId("ID123");
- bean.setNumber(7);
- bean.setMembers(members);
- bean.openMembers = new ArrayMember[] { new ArrayMember("OpenFoo", 1000),
- new ArrayMember("OpenBar", 2000) };
- List<ArrayMember> list = new ArrayList<ArrayMember>(2);
- list.add(new ArrayMember("John", 111));
- list.add(new ArrayMember("Tony", 222));
- bean.setList(list);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(bean);
- // System.out.println(output);
- assertEquals(Util.getLocalResource("issues/issue74-array1.txt"), output);
- Yaml beanLoader = new Yaml();
- ArrayBean parsed = beanLoader.loadAs(output, ArrayBean.class);
- // System.out.println(parsed);
- assertEquals(3, parsed.getMembers().length);
- assertEquals(2, parsed.openMembers.length);
- assertEquals(2, parsed.getList().size());
- assertEquals("ID123", parsed.getId());
- assertEquals(7, parsed.getNumber());
- for (ArrayMember member : parsed.getMembers()) {
- assertTrue((member.getAge() >= 21) && (member.getAge() <= 25));
- }
- }
-
- public static class ArrayBean {
- private String id;
- private int number;
- private ArrayMember[] members;
- public ArrayMember[] openMembers;
- private List<ArrayMember> list;
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
-
- public ArrayMember[] getMembers() {
- return members;
- }
-
- public void setMembers(ArrayMember[] members) {
- this.members = members;
- }
-
- public List<ArrayMember> getList() {
- return list;
- }
-
- public void setList(List<ArrayMember> list) {
- this.list = list;
- }
- }
-
- public static class ArrayMember {
- private String name;
- private int age;
-
- public ArrayMember(String name, int age) {
- this.name = name;
- this.age = age;
- }
-
- public ArrayMember() {
- this.name = "NoName";
- this.age = 0;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int getAge() {
- return age;
- }
-
- public void setAge(int age) {
- this.age = age;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof ArrayMember) {
- ArrayMember m = (ArrayMember) obj;
- return age == m.age;
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return age;
- }
-
- @Override
- public String toString() {
- return "ArrayMember age=" + age;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue74;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+public class ArrayBeanTest extends TestCase {
+
+ public void testArrayProperty() {
+ ArrayMember[] members = new ArrayMember[3];
+ members[0] = new ArrayMember("Foo", 21);
+ members[1] = new ArrayMember("Bar", 23);
+ members[2] = new ArrayMember("Hue Long Hair", 25);
+ ArrayBean bean = new ArrayBean();
+ bean.setId("ID123");
+ bean.setNumber(7);
+ bean.setMembers(members);
+ bean.openMembers = new ArrayMember[] { new ArrayMember("OpenFoo", 1000),
+ new ArrayMember("OpenBar", 2000) };
+ List<ArrayMember> list = new ArrayList<ArrayMember>(2);
+ list.add(new ArrayMember("John", 111));
+ list.add(new ArrayMember("Tony", 222));
+ bean.setList(list);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(bean);
+ // System.out.println(output);
+ assertEquals(Util.getLocalResource("issues/issue74-array1.txt"), output);
+ Yaml beanLoader = new Yaml();
+ ArrayBean parsed = beanLoader.loadAs(output, ArrayBean.class);
+ // System.out.println(parsed);
+ assertEquals(3, parsed.getMembers().length);
+ assertEquals(2, parsed.openMembers.length);
+ assertEquals(2, parsed.getList().size());
+ assertEquals("ID123", parsed.getId());
+ assertEquals(7, parsed.getNumber());
+ for (ArrayMember member : parsed.getMembers()) {
+ assertTrue((member.getAge() >= 21) && (member.getAge() <= 25));
+ }
+ }
+
+ public static class ArrayBean {
+ private String id;
+ private int number;
+ private ArrayMember[] members;
+ public ArrayMember[] openMembers;
+ private List<ArrayMember> list;
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public ArrayMember[] getMembers() {
+ return members;
+ }
+
+ public void setMembers(ArrayMember[] members) {
+ this.members = members;
+ }
+
+ public List<ArrayMember> getList() {
+ return list;
+ }
+
+ public void setList(List<ArrayMember> list) {
+ this.list = list;
+ }
+ }
+
+ public static class ArrayMember {
+ private String name;
+ private int age;
+
+ public ArrayMember(String name, int age) {
+ this.name = name;
+ this.age = age;
+ }
+
+ public ArrayMember() {
+ this.name = "NoName";
+ this.age = 0;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof ArrayMember) {
+ ArrayMember m = (ArrayMember) obj;
+ return age == m.age;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return age;
+ }
+
+ @Override
+ public String toString() {
+ return "ArrayMember age=" + age;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue8/Person.java b/src/test/java/org/yaml/snakeyaml/issues/issue8/Person.java
index 842b728..16352fd 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue8/Person.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue8/Person.java
@@ -1,77 +1,77 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue8;
-
-import java.io.Serializable;
-
-/**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=8
- */
-public class Person implements Serializable {
- private static final long serialVersionUID = 1L;
- private String firstName;
- private String lastName;
- private int hatSize;
-
- public Person() {
- }
-
- public Person(String firstName, String lastName, int hatSize) {
- this.firstName = firstName;
- this.lastName = lastName;
- this.hatSize = hatSize;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public int getHatSize() {
- return hatSize;
- }
-
- public void setHatSize(int hatSize) {
- this.hatSize = hatSize;
- }
-
- @Override
- public boolean equals(Object object) {
- if (object instanceof Person) {
- Person person = (Person) object;
- return firstName.equals(person.firstName) && lastName.equals(person.lastName)
- && hatSize == person.hatSize;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return 1;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue8;
+
+import java.io.Serializable;
+
+/**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=8
+ */
+public class Person implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private String firstName;
+ private String lastName;
+ private int hatSize;
+
+ public Person() {
+ }
+
+ public Person(String firstName, String lastName, int hatSize) {
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.hatSize = hatSize;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public int getHatSize() {
+ return hatSize;
+ }
+
+ public void setHatSize(int hatSize) {
+ this.hatSize = hatSize;
+ }
+
+ @Override
+ public boolean equals(Object object) {
+ if (object instanceof Person) {
+ Person person = (Person) object;
+ return firstName.equals(person.firstName) && lastName.equals(person.lastName)
+ && hatSize == person.hatSize;
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 1;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue8/PrattleRepresenterTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue8/PrattleRepresenterTest.java
index 31f076d..326cc10 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue8/PrattleRepresenterTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue8/PrattleRepresenterTest.java
@@ -1,67 +1,67 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue8;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=8
- */
-public class PrattleRepresenterTest extends TestCase {
- public void test() {
- Yaml yaml = new Yaml();
- Person person = new Person("Alan", "Gutierrez", 9);
- String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
- assertEquals(etalon, yaml.dump(person));
- assertEquals(etalon, yaml.dump(person));
- }
-
- public void test2beans() {
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- Person person = new Person("Alan", "Gutierrez", 9);
- String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
- assertEquals(etalon, yaml.dump(person));
- Horse horse = new Horse("Tom", person);
- String etalon2 = "!!org.yaml.snakeyaml.issues.issue8.PrattleRepresenterTest$Horse\nname: Tom\nowner: {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
- assertEquals(etalon2, yaml.dump(horse));
- }
-
- public static class Horse {
- private String name;
- private Person owner;
-
- public Horse(String name, Person owner) {
- super();
- this.name = name;
- this.owner = owner;
- }
-
- public String getName() {
- return name;
- }
-
- public Person getOwner() {
- return owner;
- }
-
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue8;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=8
+ */
+public class PrattleRepresenterTest extends TestCase {
+ public void test() {
+ Yaml yaml = new Yaml();
+ Person person = new Person("Alan", "Gutierrez", 9);
+ String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
+ assertEquals(etalon, yaml.dump(person));
+ assertEquals(etalon, yaml.dump(person));
+ }
+
+ public void test2beans() {
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ Person person = new Person("Alan", "Gutierrez", 9);
+ String etalon = "!!org.yaml.snakeyaml.issues.issue8.Person {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
+ assertEquals(etalon, yaml.dump(person));
+ Horse horse = new Horse("Tom", person);
+ String etalon2 = "!!org.yaml.snakeyaml.issues.issue8.PrattleRepresenterTest$Horse\nname: Tom\nowner: {firstName: Alan, hatSize: 9, lastName: Gutierrez}\n";
+ assertEquals(etalon2, yaml.dump(horse));
+ }
+
+ public static class Horse {
+ private String name;
+ private Person owner;
+
+ public Horse(String name, Person owner) {
+ super();
+ this.name = name;
+ this.owner = owner;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Person getOwner() {
+ return owner;
+ }
+
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean1.java b/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean1.java
index 10ee847..d94472c 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean1.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean1.java
@@ -1,59 +1,59 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue9;
-
-import org.springframework.core.style.ToStringCreator;
-
-public class Bean1 implements IBean {
-
- private String strVal = "BEAN_1";
-
- private int intVal = 1;
-
- public Bean1() {
- super();
- }
-
- public Bean1(int intVal) {
- this.intVal = intVal;
- }
-
- public String getStrVal() {
- return strVal;
- }
-
- public void setStrVal(String strVal) {
- this.strVal = strVal;
- }
-
- public int getIntVal() {
- return intVal;
- }
-
- public void setIntVal(int intVal) {
- this.intVal = intVal;
- }
-
- @Override
- public String toString() {
- ToStringCreator builder = new ToStringCreator(this);
- builder.append(this.strVal);
- builder.append(this.intVal);
- return builder.toString();
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue9;
+
+import org.springframework.core.style.ToStringCreator;
+
+public class Bean1 implements IBean {
+
+ private String strVal = "BEAN_1";
+
+ private int intVal = 1;
+
+ public Bean1() {
+ super();
+ }
+
+ public Bean1(int intVal) {
+ this.intVal = intVal;
+ }
+
+ public String getStrVal() {
+ return strVal;
+ }
+
+ public void setStrVal(String strVal) {
+ this.strVal = strVal;
+ }
+
+ public int getIntVal() {
+ return intVal;
+ }
+
+ public void setIntVal(int intVal) {
+ this.intVal = intVal;
+ }
+
+ @Override
+ public String toString() {
+ ToStringCreator builder = new ToStringCreator(this);
+ builder.append(this.strVal);
+ builder.append(this.intVal);
+ return builder.toString();
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean2.java b/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean2.java
index 67de07e..187de65 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean2.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue9/Bean2.java
@@ -1,55 +1,55 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue9;
-
-import org.springframework.core.style.ToStringCreator;
-
-public class Bean2 implements IBean {
-
- private String strVal = "BEAN_2";
-
- private int intVal = 2;
-
- public Bean2() {
- super();
- }
-
- public String getStrVal() {
- return strVal;
- }
-
- public void setStrVal(String strVal) {
- this.strVal = strVal;
- }
-
- public int getIntVal() {
- return intVal;
- }
-
- public void setIntVal(int intVal) {
- this.intVal = intVal;
- }
-
- @Override
- public String toString() {
- ToStringCreator builder = new ToStringCreator(this);
- builder.append(this.strVal);
- builder.append(this.intVal);
- return builder.toString();
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue9;
+
+import org.springframework.core.style.ToStringCreator;
+
+public class Bean2 implements IBean {
+
+ private String strVal = "BEAN_2";
+
+ private int intVal = 2;
+
+ public Bean2() {
+ super();
+ }
+
+ public String getStrVal() {
+ return strVal;
+ }
+
+ public void setStrVal(String strVal) {
+ this.strVal = strVal;
+ }
+
+ public int getIntVal() {
+ return intVal;
+ }
+
+ public void setIntVal(int intVal) {
+ this.intVal = intVal;
+ }
+
+ @Override
+ public String toString() {
+ ToStringCreator builder = new ToStringCreator(this);
+ builder.append(this.strVal);
+ builder.append(this.intVal);
+ return builder.toString();
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor.java b/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor.java
index 44f43fe..351a87f 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue9;
-
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.NodeId;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class BeanConstructor extends Constructor {
-
- public BeanConstructor() {
- super(BeanHolder.class);
- yamlConstructors.put(new Tag(Bean1.class), new Bean1ScalarConstructor());
- yamlConstructors.put(new Tag(BeanHolder.class), new BeanHolderScalarConstructor());
- }
-
- private class Bean1ScalarConstructor extends ConstructScalar {
- @Override
- public Object construct(Node node) {
- ScalarNode snode = (ScalarNode) node;
- if (snode.getValue().length() == 0) {
- return new Bean1();
- } else {
- return new Bean1(new Integer(snode.getValue()));
- }
- }
- }
-
- private class BeanHolderScalarConstructor extends ConstructScalar {
- @Override
- public Object construct(Node node) {
- if (node.getNodeId() == NodeId.scalar) {
- ScalarNode n = (ScalarNode) node;
- String value = n.getValue();
- int i = 3;
- if (value.length() != 0) {
- i = Integer.parseInt(value);
- }
- return new BeanHolder(new Bean1(i));
- } else {
- return new BeanHolder();
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue9;
+
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.NodeId;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class BeanConstructor extends Constructor {
+
+ public BeanConstructor() {
+ super(BeanHolder.class);
+ yamlConstructors.put(new Tag(Bean1.class), new Bean1ScalarConstructor());
+ yamlConstructors.put(new Tag(BeanHolder.class), new BeanHolderScalarConstructor());
+ }
+
+ private class Bean1ScalarConstructor extends ConstructScalar {
+ @Override
+ public Object construct(Node node) {
+ ScalarNode snode = (ScalarNode) node;
+ if (snode.getValue().length() == 0) {
+ return new Bean1();
+ } else {
+ return new Bean1(new Integer(snode.getValue()));
+ }
+ }
+ }
+
+ private class BeanHolderScalarConstructor extends ConstructScalar {
+ @Override
+ public Object construct(Node node) {
+ if (node.getNodeId() == NodeId.scalar) {
+ ScalarNode n = (ScalarNode) node;
+ String value = n.getValue();
+ int i = 3;
+ if (value.length() != 0) {
+ i = Integer.parseInt(value);
+ }
+ return new BeanHolder(new Bean1(i));
+ } else {
+ return new BeanHolder();
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor3.java b/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor3.java
index f0a4a3e..d57f3f0 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor3.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanConstructor3.java
@@ -1,35 +1,35 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue9;
-
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class BeanConstructor3 extends Constructor {
-
- public BeanConstructor3() {
- yamlConstructors.put(new Tag(BeanHolder.class), new BeanHolderScalarConstructor());
- }
-
- private class BeanHolderScalarConstructor extends ConstructScalar {
- @Override
- public Object construct(Node node) {
- return new BeanHolder();
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue9;
+
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class BeanConstructor3 extends Constructor {
+
+ public BeanConstructor3() {
+ yamlConstructors.put(new Tag(BeanHolder.class), new BeanHolderScalarConstructor());
+ }
+
+ private class BeanHolderScalarConstructor extends ConstructScalar {
+ @Override
+ public Object construct(Node node) {
+ return new BeanHolder();
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanHolder.java b/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanHolder.java
index b096c08..d78f535 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanHolder.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue9/BeanHolder.java
@@ -1,48 +1,48 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue9;
-
-import org.springframework.core.style.ToStringCreator;
-
-public class BeanHolder {
-
- private IBean bean = new Bean1();
-
- public BeanHolder() {
- super();
- }
-
- public BeanHolder(IBean bean) {
- super();
- this.bean = bean;
- }
-
- public IBean getBean() {
- return bean;
- }
-
- public void setBean(IBean bean) {
- this.bean = bean;
- }
-
- @Override
- public String toString() {
- ToStringCreator builder = new ToStringCreator(this);
- builder.append(this.bean);
- return builder.toString();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue9;
+
+import org.springframework.core.style.ToStringCreator;
+
+public class BeanHolder {
+
+ private IBean bean = new Bean1();
+
+ public BeanHolder() {
+ super();
+ }
+
+ public BeanHolder(IBean bean) {
+ super();
+ this.bean = bean;
+ }
+
+ public IBean getBean() {
+ return bean;
+ }
+
+ public void setBean(IBean bean) {
+ this.bean = bean;
+ }
+
+ @Override
+ public String toString() {
+ ToStringCreator builder = new ToStringCreator(this);
+ builder.append(this.bean);
+ return builder.toString();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue9/IBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue9/IBean.java
index 608ea86..3516dfd 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue9/IBean.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue9/IBean.java
@@ -1,28 +1,28 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue9;
-
-public interface IBean {
-
- public abstract String getStrVal();
-
- public abstract void setStrVal(String strVal);
-
- public abstract int getIntVal();
-
- public abstract void setIntVal(int intVal);
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue9;
+
+public interface IBean {
+
+ public abstract String getStrVal();
+
+ public abstract void setStrVal(String strVal);
+
+ public abstract int getIntVal();
+
+ public abstract void setIntVal(int intVal);
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue9/NopropTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue9/NopropTest.java
index 901578f..4598730 100644
--- a/src/test/java/org/yaml/snakeyaml/issues/issue9/NopropTest.java
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue9/NopropTest.java
@@ -1,151 +1,151 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.issues.issue9;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class NopropTest extends TestCase {
-
- public void testOK01() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1\n intVal : 11\n strVal : HALLO_1 ";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("HALLO_1", beanHolder.getBean().getStrVal());
- assertEquals(11, beanHolder.getBean().getIntVal());
- }
-
- public void testOK02() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean2\n intVal : 22\n strVal : HALLO_2 ";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("HALLO_2", beanHolder.getBean().getStrVal());
- assertEquals(22, beanHolder.getBean().getIntVal());
- }
-
- public void testOK03() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1\n intVal : 1";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(1, beanHolder.getBean().getIntVal());
- }
-
- public void testOK04() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean2\n intVal : 22";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("BEAN_2", beanHolder.getBean().getStrVal());
- assertEquals(22, beanHolder.getBean().getIntVal());
- }
-
- public void testOK05() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1\n strVal : HALLO_1 ";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("HALLO_1", beanHolder.getBean().getStrVal());
- assertEquals(1, beanHolder.getBean().getIntVal());
- }
-
- public void testOK06() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean2\n strVal : HALLO_2 ";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("HALLO_2", beanHolder.getBean().getStrVal());
- assertEquals(2, beanHolder.getBean().getIntVal());
- }
-
- public void testEmptyBean() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1";
- Iterator<Object> docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(1, beanHolder.getBean().getIntVal());
- }
-
- public void testEmptyBean2() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1 {}";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(1, beanHolder.getBean().getIntVal());
- }
-
- public void testEmptyDoc() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder";
- Iterator<Object> docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(3, beanHolder.getBean().getIntVal());
- }
-
- public void testEmptyDoc2() {
- String yaml = "---";
- Iterator<Object> docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertNotNull(beanHolder);
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(3, beanHolder.getBean().getIntVal());
- // only space is also null
- yaml = "--- ";
- docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- beanHolder = (BeanHolder) docs.next();
- assertNotNull(beanHolder);
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(3, beanHolder.getBean().getIntVal());
- // only space is also null
- yaml = "--- '23'";
- docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- beanHolder = (BeanHolder) docs.next();
- assertNotNull(beanHolder);
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(23, beanHolder.getBean().getIntVal());
- }
-
- public void testEmptyDoc3() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder";
- Iterator<Object> docs = new Yaml(new BeanConstructor3()).loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(1, beanHolder.getBean().getIntVal());
- }
-
- public void testNonBean() {
- String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1 123";
- Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
- assertTrue(docs.hasNext());
- BeanHolder beanHolder = (BeanHolder) docs.next();
- assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
- assertEquals(123, beanHolder.getBean().getIntVal());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.issues.issue9;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class NopropTest extends TestCase {
+
+ public void testOK01() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1\n intVal : 11\n strVal : HALLO_1 ";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("HALLO_1", beanHolder.getBean().getStrVal());
+ assertEquals(11, beanHolder.getBean().getIntVal());
+ }
+
+ public void testOK02() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean2\n intVal : 22\n strVal : HALLO_2 ";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("HALLO_2", beanHolder.getBean().getStrVal());
+ assertEquals(22, beanHolder.getBean().getIntVal());
+ }
+
+ public void testOK03() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1\n intVal : 1";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(1, beanHolder.getBean().getIntVal());
+ }
+
+ public void testOK04() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean2\n intVal : 22";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("BEAN_2", beanHolder.getBean().getStrVal());
+ assertEquals(22, beanHolder.getBean().getIntVal());
+ }
+
+ public void testOK05() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1\n strVal : HALLO_1 ";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("HALLO_1", beanHolder.getBean().getStrVal());
+ assertEquals(1, beanHolder.getBean().getIntVal());
+ }
+
+ public void testOK06() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean2\n strVal : HALLO_2 ";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("HALLO_2", beanHolder.getBean().getStrVal());
+ assertEquals(2, beanHolder.getBean().getIntVal());
+ }
+
+ public void testEmptyBean() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1";
+ Iterator<Object> docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(1, beanHolder.getBean().getIntVal());
+ }
+
+ public void testEmptyBean2() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1 {}";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(1, beanHolder.getBean().getIntVal());
+ }
+
+ public void testEmptyDoc() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder";
+ Iterator<Object> docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(3, beanHolder.getBean().getIntVal());
+ }
+
+ public void testEmptyDoc2() {
+ String yaml = "---";
+ Iterator<Object> docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertNotNull(beanHolder);
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(3, beanHolder.getBean().getIntVal());
+ // only space is also null
+ yaml = "--- ";
+ docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ beanHolder = (BeanHolder) docs.next();
+ assertNotNull(beanHolder);
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(3, beanHolder.getBean().getIntVal());
+ // only space is also null
+ yaml = "--- '23'";
+ docs = new Yaml(new BeanConstructor()).loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ beanHolder = (BeanHolder) docs.next();
+ assertNotNull(beanHolder);
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(23, beanHolder.getBean().getIntVal());
+ }
+
+ public void testEmptyDoc3() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder";
+ Iterator<Object> docs = new Yaml(new BeanConstructor3()).loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(1, beanHolder.getBean().getIntVal());
+ }
+
+ public void testNonBean() {
+ String yaml = "--- !!org.yaml.snakeyaml.issues.issue9.BeanHolder\nbean : !!org.yaml.snakeyaml.issues.issue9.Bean1 123";
+ Iterator<Object> docs = new Yaml().loadAll(yaml).iterator();
+ assertTrue(docs.hasNext());
+ BeanHolder beanHolder = (BeanHolder) docs.next();
+ assertEquals("BEAN_1", beanHolder.getBean().getStrVal());
+ assertEquals(123, beanHolder.getBean().getIntVal());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/ConstructEmptyBeanTest.java b/src/test/java/org/yaml/snakeyaml/javabeans/ConstructEmptyBeanTest.java
index d82e66f..5116f68 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/ConstructEmptyBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/ConstructEmptyBeanTest.java
@@ -1,132 +1,132 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-import java.io.Serializable;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class ConstructEmptyBeanTest extends TestCase {
- /**
- * standard Yaml
- */
- public void testEmptyBean() {
- Yaml yaml = new Yaml();
- EmptyBean bean = (EmptyBean) yaml
- .load("!!org.yaml.snakeyaml.javabeans.ConstructEmptyBeanTest$EmptyBean {}");
- assertNotNull(bean);
- assertNull(bean.getFirstName());
- assertEquals(5, bean.getHatSize());
- }
-
- /**
- * global tag is correct (but ignored)
- */
- public void testEmptyBean1() {
- Yaml beanLoader = new Yaml();
- EmptyBean bean = beanLoader.loadAs(
- "!!org.yaml.snakeyaml.javabeans.ConstructEmptyBeanTest$EmptyBean {}",
- EmptyBean.class);
- assertNotNull(bean);
- assertNull(bean.getFirstName());
- assertEquals(5, bean.getHatSize());
- }
-
- /**
- * global tag is ignored
- */
- public void testEmptyBean2() {
- Yaml beanLoader = new Yaml();
- EmptyBean bean = beanLoader.loadAs("!!Bla-bla-bla {}", EmptyBean.class);
- assertNotNull(bean);
- assertNull(bean.getFirstName());
- assertEquals(5, bean.getHatSize());
- }
-
- /**
- * no tag
- */
- public void testEmptyBean3() {
- Yaml beanLoader = new Yaml();
- EmptyBean bean = beanLoader.loadAs("{ }", EmptyBean.class);
- assertNotNull(bean);
- assertNull(bean.getFirstName());
- assertEquals(5, bean.getHatSize());
- }
-
- /**
- * empty document
- */
- public void testEmptyBean4() {
- Yaml beanLoader = new Yaml();
- EmptyBean bean = beanLoader.loadAs("", EmptyBean.class);
- assertNull(bean);
- }
-
- /**
- * local tag is ignored
- */
- public void testEmptyBean5() {
- Yaml beanLoader = new Yaml();
- EmptyBean bean = beanLoader.loadAs("!Bla-bla-bla {}", EmptyBean.class);
- assertNotNull(bean);
- assertNull(bean.getFirstName());
- assertEquals(5, bean.getHatSize());
- }
-
- /**
- * invalid document
- */
- public void testEmptyBean6() {
- Yaml beanLoader = new Yaml();
- try {
- beanLoader.loadAs("{", EmptyBean.class);
- fail("Invalid document provided.");
- } catch (Exception e) {
- assertEquals(
- "while parsing a flow node; expected the node content, but found StreamEnd",
- e.getMessage());
- }
- }
-
- public static class EmptyBean implements Serializable {
- private static final long serialVersionUID = -8001155967276657180L;
- private String firstName;
- private int hatSize = 5;
-
- public EmptyBean() {
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public int getHatSize() {
- return hatSize;
- }
-
- public void setHatSize(int hatSize) {
- this.hatSize = hatSize;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+import java.io.Serializable;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class ConstructEmptyBeanTest extends TestCase {
+ /**
+ * standard Yaml
+ */
+ public void testEmptyBean() {
+ Yaml yaml = new Yaml();
+ EmptyBean bean = (EmptyBean) yaml
+ .load("!!org.yaml.snakeyaml.javabeans.ConstructEmptyBeanTest$EmptyBean {}");
+ assertNotNull(bean);
+ assertNull(bean.getFirstName());
+ assertEquals(5, bean.getHatSize());
+ }
+
+ /**
+ * global tag is correct (but ignored)
+ */
+ public void testEmptyBean1() {
+ Yaml beanLoader = new Yaml();
+ EmptyBean bean = beanLoader.loadAs(
+ "!!org.yaml.snakeyaml.javabeans.ConstructEmptyBeanTest$EmptyBean {}",
+ EmptyBean.class);
+ assertNotNull(bean);
+ assertNull(bean.getFirstName());
+ assertEquals(5, bean.getHatSize());
+ }
+
+ /**
+ * global tag is ignored
+ */
+ public void testEmptyBean2() {
+ Yaml beanLoader = new Yaml();
+ EmptyBean bean = beanLoader.loadAs("!!Bla-bla-bla {}", EmptyBean.class);
+ assertNotNull(bean);
+ assertNull(bean.getFirstName());
+ assertEquals(5, bean.getHatSize());
+ }
+
+ /**
+ * no tag
+ */
+ public void testEmptyBean3() {
+ Yaml beanLoader = new Yaml();
+ EmptyBean bean = beanLoader.loadAs("{ }", EmptyBean.class);
+ assertNotNull(bean);
+ assertNull(bean.getFirstName());
+ assertEquals(5, bean.getHatSize());
+ }
+
+ /**
+ * empty document
+ */
+ public void testEmptyBean4() {
+ Yaml beanLoader = new Yaml();
+ EmptyBean bean = beanLoader.loadAs("", EmptyBean.class);
+ assertNull(bean);
+ }
+
+ /**
+ * local tag is ignored
+ */
+ public void testEmptyBean5() {
+ Yaml beanLoader = new Yaml();
+ EmptyBean bean = beanLoader.loadAs("!Bla-bla-bla {}", EmptyBean.class);
+ assertNotNull(bean);
+ assertNull(bean.getFirstName());
+ assertEquals(5, bean.getHatSize());
+ }
+
+ /**
+ * invalid document
+ */
+ public void testEmptyBean6() {
+ Yaml beanLoader = new Yaml();
+ try {
+ beanLoader.loadAs("{", EmptyBean.class);
+ fail("Invalid document provided.");
+ } catch (Exception e) {
+ assertEquals(
+ "while parsing a flow node; expected the node content, but found StreamEnd",
+ e.getMessage());
+ }
+ }
+
+ public static class EmptyBean implements Serializable {
+ private static final long serialVersionUID = -8001155967276657180L;
+ private String firstName;
+ private int hatSize = 5;
+
+ public EmptyBean() {
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public int getHatSize() {
+ return hatSize;
+ }
+
+ public void setHatSize(int hatSize) {
+ this.hatSize = hatSize;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/Door.java b/src/test/java/org/yaml/snakeyaml/javabeans/Door.java
index 574df79..b45985e 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/Door.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/Door.java
@@ -1,68 +1,68 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-public class Door {
- private String id;
- private int height;
-
- public Door(String id, int height) {
- this.id = id;
- this.height = height;
- }
-
- public Door() {
- this.height = 3;
- }
-
- public int getHeight() {
- return height;
- }
-
- public void setHeight(int height) {
- this.height = height;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Door) {
- Door door = (Door) obj;
- return id.equals(door.id);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return id.hashCode();
- }
-
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- @Override
- public String toString() {
- return "Door id=" + id;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+public class Door {
+ private String id;
+ private int height;
+
+ public Door(String id, int height) {
+ this.id = id;
+ this.height = height;
+ }
+
+ public Door() {
+ this.height = 3;
+ }
+
+ public int getHeight() {
+ return height;
+ }
+
+ public void setHeight(int height) {
+ this.height = height;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Door) {
+ Door door = (Door) obj;
+ return id.equals(door.id);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return id.hashCode();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public String toString() {
+ return "Door id=" + id;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/FrontDoor.java b/src/test/java/org/yaml/snakeyaml/javabeans/FrontDoor.java
index b354c04..f861a76 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/FrontDoor.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/FrontDoor.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-public class FrontDoor extends Door {
- private String keytype;
-
- public FrontDoor() {
- super();
- }
-
- public FrontDoor(String id, int height) {
- super(id, height);
- }
-
- public String getKeytype() {
- return keytype;
- }
-
- public void setKeytype(String keytype) {
- this.keytype = keytype;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+public class FrontDoor extends Door {
+ private String keytype;
+
+ public FrontDoor() {
+ super();
+ }
+
+ public FrontDoor(String id, int height) {
+ super(id, height);
+ }
+
+ public String getKeytype() {
+ return keytype;
+ }
+
+ public void setKeytype(String keytype) {
+ this.keytype = keytype;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/House.java b/src/test/java/org/yaml/snakeyaml/javabeans/House.java
index 867be43..d1c4eee 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/House.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/House.java
@@ -1,69 +1,69 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-import java.util.List;
-import java.util.Map;
-
-public class House {
- private String street;
- private int number;
- private List<Room> rooms;
- private FrontDoor frontDoor;
- private Map<String, String> reminders;
-
- public String getStreet() {
- return street;
- }
-
- public void setStreet(String street) {
- this.street = street;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
-
- public List<Room> getRooms() {
- return rooms;
- }
-
- public void setRooms(List<Room> rooms) {
- this.rooms = rooms;
- }
-
- public FrontDoor getFrontDoor() {
- return frontDoor;
- }
-
- public void setFrontDoor(FrontDoor frontDoor) {
- this.frontDoor = frontDoor;
- }
-
- public Map<String, String> getReminders() {
- return reminders;
- }
-
- public void setReminders(Map<String, String> reminders) {
- this.reminders = reminders;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+import java.util.List;
+import java.util.Map;
+
+public class House {
+ private String street;
+ private int number;
+ private List<Room> rooms;
+ private FrontDoor frontDoor;
+ private Map<String, String> reminders;
+
+ public String getStreet() {
+ return street;
+ }
+
+ public void setStreet(String street) {
+ this.street = street;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public List<Room> getRooms() {
+ return rooms;
+ }
+
+ public void setRooms(List<Room> rooms) {
+ this.rooms = rooms;
+ }
+
+ public FrontDoor getFrontDoor() {
+ return frontDoor;
+ }
+
+ public void setFrontDoor(FrontDoor frontDoor) {
+ this.frontDoor = frontDoor;
+ }
+
+ public Map<String, String> getReminders() {
+ return reminders;
+ }
+
+ public void setReminders(Map<String, String> reminders) {
+ this.reminders = reminders;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/HouseTest.java b/src/test/java/org/yaml/snakeyaml/javabeans/HouseTest.java
index 6a4fa5e..c8348ae 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/HouseTest.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/HouseTest.java
@@ -1,145 +1,145 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.TreeMap;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class HouseTest extends TestCase {
- /**
- * no root global tag
- */
- public void testDump1() {
- House house = new House();
- FrontDoor frontDoor = new FrontDoor("qaz1", 5);
- frontDoor.setKeytype("qwerty123");
- house.setFrontDoor(frontDoor);
- List<Room> rooms = new ArrayList<Room>();
- rooms.add(new Room("Hall"));
- rooms.add(new Room("Kitchen"));
- house.setRooms(rooms);
- Map<String, String> reminders = new TreeMap<String, String>();
- reminders.put("today", "do nothig");
- reminders.put("tomorrow", "go shoping");
- house.setReminders(reminders);
- house.setNumber(1);
- house.setStreet("Wall Street");
- Yaml beanDumper = new Yaml();
- String yaml = beanDumper.dumpAsMap(house);
- String etalon = Util.getLocalResource("javabeans/house-dump1.yaml");
- assertEquals(etalon, yaml);
- // load
- Yaml beanLoader = new Yaml();
- House loadedHouse = beanLoader.loadAs(yaml, House.class);
- assertNotNull(loadedHouse);
- assertEquals("Wall Street", loadedHouse.getStreet());
- // dump again
- String yaml3 = beanDumper.dumpAsMap(loadedHouse);
- assertEquals(yaml, yaml3);
- }
-
- /**
- * with global root class tag (global tag should be avoided)
- */
- public void testDump3() {
- House house = new House();
- FrontDoor frontDoor = new FrontDoor("qaz1", 5);
- frontDoor.setKeytype("qwerty123");
- house.setFrontDoor(frontDoor);
- List<Room> rooms = new ArrayList<Room>();
- rooms.add(new Room("Hall"));
- rooms.add(new Room("Kitchen"));
- house.setRooms(rooms);
- Map<String, String> reminders = new TreeMap<String, String>();
- reminders.put("today", "do nothig");
- reminders.put("tomorrow", "go shoping");
- house.setReminders(reminders);
- house.setNumber(1);
- house.setStreet("Wall Street");
- Yaml beanDumper = new Yaml();
- String yaml = beanDumper.dumpAsMap(house);
- String etalon = Util.getLocalResource("javabeans/house-dump3.yaml");
- assertEquals(etalon, yaml);
- // load
- TypeDescription description = new TypeDescription(House.class);
- description.putListPropertyType("rooms", Room.class);
- Yaml beanLoader = new Yaml(new Constructor(description));
- House loadedHouse = (House) beanLoader.load(yaml);
- House loadedHouse2 = (House) beanLoader.loadAs(yaml, House.class);
- assertNotNull(loadedHouse);
- assertFalse(loadedHouse == loadedHouse2);
- assertEquals("Wall Street", loadedHouse.getStreet());
- assertEquals(1, loadedHouse.getNumber());
- assertEquals(1, loadedHouse2.getNumber());
- FrontDoor fdoor = loadedHouse.getFrontDoor();
- assertEquals(frontDoor.getId(), fdoor.getId());
- assertEquals(frontDoor.getHeight(), fdoor.getHeight());
- assertEquals(frontDoor.getKeytype(), fdoor.getKeytype());
- assertEquals(frontDoor, fdoor);
- assertEquals(reminders, loadedHouse.getReminders());
- List<Room> loadedRooms = loadedHouse.getRooms();
- assertEquals(rooms, loadedRooms);
- // dump again
- String yaml3 = beanDumper.dumpAsMap(loadedHouse);
- assertEquals(yaml, yaml3);
- }
-
- /**
- * with global root class tag (global tag should be avoided)
- */
- public void testDump2() {
- House house = new House();
- FrontDoor frontDoor = new FrontDoor("qaz1", 5);
- frontDoor.setKeytype("qwerty123");
- house.setFrontDoor(frontDoor);
- List<Room> rooms = new ArrayList<Room>();
- rooms.add(new Room("Hall"));
- rooms.add(new Room("Kitchen"));
- house.setRooms(rooms);
- Map<String, String> reminders = new TreeMap<String, String>();
- reminders.put("today", "do nothig");
- reminders.put("tomorrow", "go shoping");
- house.setReminders(reminders);
- house.setNumber(1);
- house.setStreet("Wall Street");
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.BLOCK);
- Yaml beanDumper = new Yaml(options);
- String yaml = beanDumper.dump(house);
- String etalon = Util.getLocalResource("javabeans/house-dump2.yaml");
- assertEquals(etalon, yaml);
- // load
- Yaml beanLoader = new Yaml();
- House loadedHouse = beanLoader.loadAs(yaml, House.class);
- assertNotNull(loadedHouse);
- assertEquals("Wall Street", loadedHouse.getStreet());
- // dump again
- String yaml3 = beanDumper.dump(loadedHouse);
- assertEquals(yaml, yaml3);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class HouseTest extends TestCase {
+ /**
+ * no root global tag
+ */
+ public void testDump1() {
+ House house = new House();
+ FrontDoor frontDoor = new FrontDoor("qaz1", 5);
+ frontDoor.setKeytype("qwerty123");
+ house.setFrontDoor(frontDoor);
+ List<Room> rooms = new ArrayList<Room>();
+ rooms.add(new Room("Hall"));
+ rooms.add(new Room("Kitchen"));
+ house.setRooms(rooms);
+ Map<String, String> reminders = new TreeMap<String, String>();
+ reminders.put("today", "do nothig");
+ reminders.put("tomorrow", "go shoping");
+ house.setReminders(reminders);
+ house.setNumber(1);
+ house.setStreet("Wall Street");
+ Yaml beanDumper = new Yaml();
+ String yaml = beanDumper.dumpAsMap(house);
+ String etalon = Util.getLocalResource("javabeans/house-dump1.yaml");
+ assertEquals(etalon, yaml);
+ // load
+ Yaml beanLoader = new Yaml();
+ House loadedHouse = beanLoader.loadAs(yaml, House.class);
+ assertNotNull(loadedHouse);
+ assertEquals("Wall Street", loadedHouse.getStreet());
+ // dump again
+ String yaml3 = beanDumper.dumpAsMap(loadedHouse);
+ assertEquals(yaml, yaml3);
+ }
+
+ /**
+ * with global root class tag (global tag should be avoided)
+ */
+ public void testDump3() {
+ House house = new House();
+ FrontDoor frontDoor = new FrontDoor("qaz1", 5);
+ frontDoor.setKeytype("qwerty123");
+ house.setFrontDoor(frontDoor);
+ List<Room> rooms = new ArrayList<Room>();
+ rooms.add(new Room("Hall"));
+ rooms.add(new Room("Kitchen"));
+ house.setRooms(rooms);
+ Map<String, String> reminders = new TreeMap<String, String>();
+ reminders.put("today", "do nothig");
+ reminders.put("tomorrow", "go shoping");
+ house.setReminders(reminders);
+ house.setNumber(1);
+ house.setStreet("Wall Street");
+ Yaml beanDumper = new Yaml();
+ String yaml = beanDumper.dumpAsMap(house);
+ String etalon = Util.getLocalResource("javabeans/house-dump3.yaml");
+ assertEquals(etalon, yaml);
+ // load
+ TypeDescription description = new TypeDescription(House.class);
+ description.putListPropertyType("rooms", Room.class);
+ Yaml beanLoader = new Yaml(new Constructor(description));
+ House loadedHouse = (House) beanLoader.load(yaml);
+ House loadedHouse2 = (House) beanLoader.loadAs(yaml, House.class);
+ assertNotNull(loadedHouse);
+ assertFalse(loadedHouse == loadedHouse2);
+ assertEquals("Wall Street", loadedHouse.getStreet());
+ assertEquals(1, loadedHouse.getNumber());
+ assertEquals(1, loadedHouse2.getNumber());
+ FrontDoor fdoor = loadedHouse.getFrontDoor();
+ assertEquals(frontDoor.getId(), fdoor.getId());
+ assertEquals(frontDoor.getHeight(), fdoor.getHeight());
+ assertEquals(frontDoor.getKeytype(), fdoor.getKeytype());
+ assertEquals(frontDoor, fdoor);
+ assertEquals(reminders, loadedHouse.getReminders());
+ List<Room> loadedRooms = loadedHouse.getRooms();
+ assertEquals(rooms, loadedRooms);
+ // dump again
+ String yaml3 = beanDumper.dumpAsMap(loadedHouse);
+ assertEquals(yaml, yaml3);
+ }
+
+ /**
+ * with global root class tag (global tag should be avoided)
+ */
+ public void testDump2() {
+ House house = new House();
+ FrontDoor frontDoor = new FrontDoor("qaz1", 5);
+ frontDoor.setKeytype("qwerty123");
+ house.setFrontDoor(frontDoor);
+ List<Room> rooms = new ArrayList<Room>();
+ rooms.add(new Room("Hall"));
+ rooms.add(new Room("Kitchen"));
+ house.setRooms(rooms);
+ Map<String, String> reminders = new TreeMap<String, String>();
+ reminders.put("today", "do nothig");
+ reminders.put("tomorrow", "go shoping");
+ house.setReminders(reminders);
+ house.setNumber(1);
+ house.setStreet("Wall Street");
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.BLOCK);
+ Yaml beanDumper = new Yaml(options);
+ String yaml = beanDumper.dump(house);
+ String etalon = Util.getLocalResource("javabeans/house-dump2.yaml");
+ assertEquals(etalon, yaml);
+ // load
+ Yaml beanLoader = new Yaml();
+ House loadedHouse = beanLoader.loadAs(yaml, House.class);
+ assertNotNull(loadedHouse);
+ assertEquals("Wall Street", loadedHouse.getStreet());
+ // dump again
+ String yaml3 = beanDumper.dump(loadedHouse);
+ assertEquals(yaml, yaml3);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java b/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java
index 6d4668d..5a9ba4d 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/LongTest.java
@@ -1,74 +1,74 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class LongTest extends TestCase {
- public void testLongFail() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
- Yaml yaml = new Yaml(options);
- Foo foo = new Foo();
- String output = yaml.dump(foo);
- // System.out.println(output);
- try {
- yaml.load(output);
- } catch (Exception e) {
- assertTrue(e.getMessage(), e.getMessage().contains("argument type mismatch"));
- }
- }
-
- public static class Foo {
- private Long bar = Long.valueOf(42L);
-
- public Long getBar() {
- return bar;
- }
-
- public void setBar(Long bar) {
- this.bar = bar;
- }
- }
-
- public void testLongRepresenter() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
- Representer repr = new Representer();
- repr.addClassTag(Long.class, new Tag("!!java.lang.Long"));
- Yaml yaml = new Yaml(repr, options);
-
- Foo foo = new Foo();
- String output = yaml.dump(foo);
- // System.out.println(output);
- Foo foo2 = (Foo) yaml.load(output);
- assertEquals(new Long(42L), foo2.getBar());
- }
-
- public void testLongConstructor() {
- String doc = "!!org.yaml.snakeyaml.javabeans.LongTest$Foo\n\"bar\": !!int \"42\"";
- // System.out.println(doc);
- Yaml yaml = new Yaml();
- Foo foo2 = (Foo) yaml.load(doc);
- assertEquals(new Long(42L), foo2.getBar());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class LongTest extends TestCase {
+ public void testLongFail() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
+ Yaml yaml = new Yaml(options);
+ Foo foo = new Foo();
+ String output = yaml.dump(foo);
+ // System.out.println(output);
+ try {
+ yaml.load(output);
+ } catch (Exception e) {
+ assertTrue(e.getMessage(), e.getMessage().contains("argument type mismatch"));
+ }
+ }
+
+ public static class Foo {
+ private Long bar = Long.valueOf(42L);
+
+ public Long getBar() {
+ return bar;
+ }
+
+ public void setBar(Long bar) {
+ this.bar = bar;
+ }
+ }
+
+ public void testLongRepresenter() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
+ Representer repr = new Representer();
+ repr.addClassTag(Long.class, new Tag("!!java.lang.Long"));
+ Yaml yaml = new Yaml(repr, options);
+
+ Foo foo = new Foo();
+ String output = yaml.dump(foo);
+ // System.out.println(output);
+ Foo foo2 = (Foo) yaml.load(output);
+ assertEquals(new Long(42L), foo2.getBar());
+ }
+
+ public void testLongConstructor() {
+ String doc = "!!org.yaml.snakeyaml.javabeans.LongTest$Foo\n\"bar\": !!int \"42\"";
+ // System.out.println(doc);
+ Yaml yaml = new Yaml();
+ Foo foo2 = (Foo) yaml.load(doc);
+ assertEquals(new Long(42L), foo2.getBar());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/Room.java b/src/test/java/org/yaml/snakeyaml/javabeans/Room.java
index 20bdb5d..605241b 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/Room.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/Room.java
@@ -1,58 +1,58 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-public class Room {
- private String name;
-
- public Room() {
- this.name = "Bedroom";
- }
-
- public Room(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Room) {
- Room room = (Room) obj;
- return name.equals(room.name);
- } else {
- return false;
- }
- }
-
- @Override
- public int hashCode() {
- return name.hashCode();
- }
-
- @Override
- public String toString() {
- return "Room name=" + name;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+public class Room {
+ private String name;
+
+ public Room() {
+ this.name = "Bedroom";
+ }
+
+ public Room(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj instanceof Room) {
+ Room room = (Room) obj;
+ return name.equals(room.name);
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return "Room name=" + name;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/Shape.java b/src/test/java/org/yaml/snakeyaml/javabeans/Shape.java
index 8d16c9a..a718a66 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/Shape.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/Shape.java
@@ -1,22 +1,22 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-public interface Shape {
-
- public int process();
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+public interface Shape {
+
+ public int process();
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/StringArrayTest.java b/src/test/java/org/yaml/snakeyaml/javabeans/StringArrayTest.java
index 592afa2..008f717 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/StringArrayTest.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/StringArrayTest.java
@@ -1,71 +1,71 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-public class StringArrayTest extends TestCase {
- public void testStrings() {
- A a = new A();
- a.setNames(new String[] { "aaa", "bbb", "ccc" });
- Yaml yaml = new Yaml();
- String output = yaml.dump(a);
- assertEquals("!!org.yaml.snakeyaml.javabeans.StringArrayTest$A\nnames: [aaa, bbb, ccc]\n",
- output);
- A b = (A) yaml.load(output);
- assertTrue(Arrays.equals(a.getNames(), b.getNames()));
- }
-
- public void testStringsPretty() {
- A a = new A();
- a.setNames(new String[] { "aaa", "bbb", "ccc" });
- DumperOptions options = new DumperOptions();
- options.setPrettyFlow(true);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(a);
- assertEquals(
- "!!org.yaml.snakeyaml.javabeans.StringArrayTest$A\nnames: [\n aaa,\n bbb,\n ccc]\n",
- output);
- A b = (A) yaml.load(output);
- assertTrue(Arrays.equals(a.getNames(), b.getNames()));
- }
-
- public static class A {
- String[] names;
-
- public String[] getNames() {
- return names;
- }
-
- public void setNames(String[] names) {
- this.names = names;
- }
-
- public String getName(int index) {
- return names[index];
- }
-
- public void setName(int index, String name) {
- this.names[index] = name;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+public class StringArrayTest extends TestCase {
+ public void testStrings() {
+ A a = new A();
+ a.setNames(new String[] { "aaa", "bbb", "ccc" });
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(a);
+ assertEquals("!!org.yaml.snakeyaml.javabeans.StringArrayTest$A\nnames: [aaa, bbb, ccc]\n",
+ output);
+ A b = (A) yaml.load(output);
+ assertTrue(Arrays.equals(a.getNames(), b.getNames()));
+ }
+
+ public void testStringsPretty() {
+ A a = new A();
+ a.setNames(new String[] { "aaa", "bbb", "ccc" });
+ DumperOptions options = new DumperOptions();
+ options.setPrettyFlow(true);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(a);
+ assertEquals(
+ "!!org.yaml.snakeyaml.javabeans.StringArrayTest$A\nnames: [\n aaa,\n bbb,\n ccc]\n",
+ output);
+ A b = (A) yaml.load(output);
+ assertTrue(Arrays.equals(a.getNames(), b.getNames()));
+ }
+
+ public static class A {
+ String[] names;
+
+ public String[] getNames() {
+ return names;
+ }
+
+ public void setNames(String[] names) {
+ this.names = names;
+ }
+
+ public String getName(int index) {
+ return names[index];
+ }
+
+ public void setName(int index, String name) {
+ this.names[index] = name;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/Triangle.java b/src/test/java/org/yaml/snakeyaml/javabeans/Triangle.java
index fa0029e..82095d6 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/Triangle.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/Triangle.java
@@ -1,33 +1,33 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-public class Triangle implements Shape {
- private String name;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public int process() {
- return 7;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+public class Triangle implements Shape {
+ private String name;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public int process() {
+ return 7;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBean.java b/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBean.java
index 8989162..0746371 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBean.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBean.java
@@ -1,43 +1,43 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-public class TriangleBean {
- private String name;
- private Shape shape;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Shape getShape() {
- return shape;
- }
-
- public void setShape(Shape shape) {
- this.shape = shape;
- }
-
- @Override
- public String toString() {
- return "TriangleBean name=" + name;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+public class TriangleBean {
+ private String name;
+ private Shape shape;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Shape getShape() {
+ return shape;
+ }
+
+ public void setShape(Shape shape) {
+ this.shape = shape;
+ }
+
+ @Override
+ public String toString() {
+ return "TriangleBean name=" + name;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBeanTest.java b/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBeanTest.java
index e3f0157..184bfb1 100644
--- a/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBeanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/javabeans/TriangleBeanTest.java
@@ -1,71 +1,71 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.javabeans;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class TriangleBeanTest extends TestCase {
-
- public void testGetTriangle() {
- Triangle triangle = new Triangle();
- triangle.setName("Triangle25");
- TriangleBean bean = new TriangleBean();
- bean.setShape(triangle);
- bean.setName("Bean25");
- Yaml beanDumper = new Yaml();
- String output = beanDumper.dumpAsMap(bean);
- assertEquals(
- "name: Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle\n name: Triangle25\n",
- output);
- Yaml beanLoader = new Yaml();
- TriangleBean loadedBean = beanLoader.loadAs(output, TriangleBean.class);
- assertNotNull(loadedBean);
- assertEquals("Bean25", loadedBean.getName());
- assertEquals(7, loadedBean.getShape().process());
- }
-
- public void testClassNotFound() {
- String output = "name: Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle777\n name: Triangle25\n";
- Yaml beanLoader = new Yaml();
- try {
- beanLoader.loadAs(output, TriangleBean.class);
- fail("Class not found expected.");
- } catch (Exception e) {
- assertEquals(
- "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.TriangleBean; exception=Cannot create property=shape for JavaBean=TriangleBean name=Bean25; null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.Triangle777; exception=Class not found: org.yaml.snakeyaml.javabeans.Triangle777",
- e.getMessage());
- }
- }
-
- /**
- * Runtime class has less priority then an explicit tag
- */
- public void testClassAndTag() {
- String output = "name: !!whatever Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle\n name: Triangle25\n";
- Yaml beanLoader = new Yaml();
- try {
- beanLoader.loadAs(output, TriangleBean.class);
- fail("Runtime class has less priority then an explicit tag");
- } catch (Exception e) {
- assertEquals(
- "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.TriangleBean; exception=Cannot create property=name for JavaBean=TriangleBean name=null; null; Can't construct a java object for tag:yaml.org,2002:whatever; exception=Class not found: whatever",
- e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.javabeans;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class TriangleBeanTest extends TestCase {
+
+ public void testGetTriangle() {
+ Triangle triangle = new Triangle();
+ triangle.setName("Triangle25");
+ TriangleBean bean = new TriangleBean();
+ bean.setShape(triangle);
+ bean.setName("Bean25");
+ Yaml beanDumper = new Yaml();
+ String output = beanDumper.dumpAsMap(bean);
+ assertEquals(
+ "name: Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle\n name: Triangle25\n",
+ output);
+ Yaml beanLoader = new Yaml();
+ TriangleBean loadedBean = beanLoader.loadAs(output, TriangleBean.class);
+ assertNotNull(loadedBean);
+ assertEquals("Bean25", loadedBean.getName());
+ assertEquals(7, loadedBean.getShape().process());
+ }
+
+ public void testClassNotFound() {
+ String output = "name: Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle777\n name: Triangle25\n";
+ Yaml beanLoader = new Yaml();
+ try {
+ beanLoader.loadAs(output, TriangleBean.class);
+ fail("Class not found expected.");
+ } catch (Exception e) {
+ assertEquals(
+ "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.TriangleBean; exception=Cannot create property=shape for JavaBean=TriangleBean name=Bean25; null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.Triangle777; exception=Class not found: org.yaml.snakeyaml.javabeans.Triangle777",
+ e.getMessage());
+ }
+ }
+
+ /**
+ * Runtime class has less priority then an explicit tag
+ */
+ public void testClassAndTag() {
+ String output = "name: !!whatever Bean25\nshape: !!org.yaml.snakeyaml.javabeans.Triangle\n name: Triangle25\n";
+ Yaml beanLoader = new Yaml();
+ try {
+ beanLoader.loadAs(output, TriangleBean.class);
+ fail("Runtime class has less priority then an explicit tag");
+ } catch (Exception e) {
+ assertEquals(
+ "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.javabeans.TriangleBean; exception=Cannot create property=name for JavaBean=TriangleBean name=null; null; Can't construct a java object for tag:yaml.org,2002:whatever; exception=Class not found: whatever",
+ e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/lowlevel/LowLevelApiTest.java b/src/test/java/org/yaml/snakeyaml/lowlevel/LowLevelApiTest.java
index 3a34fa1..ad62fea 100644
--- a/src/test/java/org/yaml/snakeyaml/lowlevel/LowLevelApiTest.java
+++ b/src/test/java/org/yaml/snakeyaml/lowlevel/LowLevelApiTest.java
@@ -1,66 +1,66 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.lowlevel;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.ScalarEvent;
-import org.yaml.snakeyaml.nodes.Node;
-
-public class LowLevelApiTest extends TestCase {
-
- public void testLowLevel() {
- List<Object> list = new ArrayList<Object>();
- list.add(1);
- list.add("abc");
- Map<String, String> map = new HashMap<String, String>();
- map.put("name", "Tolstoy");
- map.put("book", "War and People");
- list.add(map);
- Yaml yaml = new Yaml();
- String etalon = yaml.dump(list);
- // System.out.println(etalon);
- //
- Node node = yaml.represent(list);
- // System.out.println(node);
- assertEquals(
- "Representation tree from an object and from its YAML document must be the same.",
- yaml.compose(new StringReader(etalon)).toString(), node.toString());
- //
- List<Event> events = yaml.serialize(node);
- int i = 0;
- for (Event etalonEvent : yaml.parse(new StringReader(etalon))) {
- Event ev1 = events.get(i++);
- assertEquals(etalonEvent.getClass(), ev1.getClass());
- if (etalonEvent instanceof ScalarEvent) {
- ScalarEvent scalar1 = (ScalarEvent) etalonEvent;
- ScalarEvent scalar2 = (ScalarEvent) ev1;
- assertEquals(scalar1.getAnchor(), scalar2.getAnchor());
- assertEquals(scalar1.getValue(), scalar2.getValue());
- }
- }
- assertEquals(i, events.size());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.lowlevel;
+
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.ScalarEvent;
+import org.yaml.snakeyaml.nodes.Node;
+
+public class LowLevelApiTest extends TestCase {
+
+ public void testLowLevel() {
+ List<Object> list = new ArrayList<Object>();
+ list.add(1);
+ list.add("abc");
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("name", "Tolstoy");
+ map.put("book", "War and People");
+ list.add(map);
+ Yaml yaml = new Yaml();
+ String etalon = yaml.dump(list);
+ // System.out.println(etalon);
+ //
+ Node node = yaml.represent(list);
+ // System.out.println(node);
+ assertEquals(
+ "Representation tree from an object and from its YAML document must be the same.",
+ yaml.compose(new StringReader(etalon)).toString(), node.toString());
+ //
+ List<Event> events = yaml.serialize(node);
+ int i = 0;
+ for (Event etalonEvent : yaml.parse(new StringReader(etalon))) {
+ Event ev1 = events.get(i++);
+ assertEquals(etalonEvent.getClass(), ev1.getClass());
+ if (etalonEvent instanceof ScalarEvent) {
+ ScalarEvent scalar1 = (ScalarEvent) etalonEvent;
+ ScalarEvent scalar2 = (ScalarEvent) ev1;
+ assertEquals(scalar1.getAnchor(), scalar2.getAnchor());
+ assertEquals(scalar1.getValue(), scalar2.getValue());
+ }
+ }
+ assertEquals(i, events.size());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/nodes/MappingNodeTest.java b/src/test/java/org/yaml/snakeyaml/nodes/MappingNodeTest.java
index d3708d6..f85083f 100644
--- a/src/test/java/org/yaml/snakeyaml/nodes/MappingNodeTest.java
+++ b/src/test/java/org/yaml/snakeyaml/nodes/MappingNodeTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import junit.framework.TestCase;
-
-public class MappingNodeTest extends TestCase {
-
- public void testNullValue() {
- try {
- new MappingNode(new Tag("!tag"), true, null, null, null, false);
- fail("Value is required.");
- } catch (Exception e) {
- assertEquals("value in a Node is required.", e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import junit.framework.TestCase;
+
+public class MappingNodeTest extends TestCase {
+
+ public void testNullValue() {
+ try {
+ new MappingNode(new Tag("!tag"), true, null, null, null, false);
+ fail("Value is required.");
+ } catch (Exception e) {
+ assertEquals("value in a Node is required.", e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/nodes/NodeTest.java b/src/test/java/org/yaml/snakeyaml/nodes/NodeTest.java
index f997449..df7d9a4 100644
--- a/src/test/java/org/yaml/snakeyaml/nodes/NodeTest.java
+++ b/src/test/java/org/yaml/snakeyaml/nodes/NodeTest.java
@@ -1,52 +1,52 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-
-public class NodeTest extends TestCase {
-
- public void testNode() {
- try {
- new ScalarNode(new Tag("!foo"), null, null, null, '"');
- fail("Value must be required.");
- } catch (Exception e) {
- assertEquals("value in a Node is required.", e.getMessage());
- }
- }
-
- public void testSetTag() {
- try {
- ScalarNode node = new ScalarNode(new Tag("!foo"), "Value1", null, null, '"');
- node.setTag((Tag) null);
- fail("Value must be required.");
- } catch (Exception e) {
- assertEquals("tag in a Node is required.", e.getMessage());
- }
- }
-
- public void testGetEndMark() {
- Mark mark1 = new Mark("name", 5, 2, 12, "afd asd asd", 7);
- Mark mark2 = new Mark("name", 6, 3, 13, "afd asd asd", 8);
- Node node = new ScalarNode(new Tag("!foo"), "bla-bla", mark1, mark2, '"');
- assertEquals(mark1, node.getStartMark());
- assertEquals(mark2, node.getEndMark());
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+
+public class NodeTest extends TestCase {
+
+ public void testNode() {
+ try {
+ new ScalarNode(new Tag("!foo"), null, null, null, '"');
+ fail("Value must be required.");
+ } catch (Exception e) {
+ assertEquals("value in a Node is required.", e.getMessage());
+ }
+ }
+
+ public void testSetTag() {
+ try {
+ ScalarNode node = new ScalarNode(new Tag("!foo"), "Value1", null, null, '"');
+ node.setTag((Tag) null);
+ fail("Value must be required.");
+ } catch (Exception e) {
+ assertEquals("tag in a Node is required.", e.getMessage());
+ }
+ }
+
+ public void testGetEndMark() {
+ Mark mark1 = new Mark("name", 5, 2, 12, "afd asd asd", 7);
+ Mark mark2 = new Mark("name", 6, 3, 13, "afd asd asd", 8);
+ Node node = new ScalarNode(new Tag("!foo"), "bla-bla", mark1, mark2, '"');
+ assertEquals(mark1, node.getStartMark());
+ assertEquals(mark2, node.getEndMark());
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/nodes/NodeTupleTest.java b/src/test/java/org/yaml/snakeyaml/nodes/NodeTupleTest.java
index cb057ca..ddaa663 100644
--- a/src/test/java/org/yaml/snakeyaml/nodes/NodeTupleTest.java
+++ b/src/test/java/org/yaml/snakeyaml/nodes/NodeTupleTest.java
@@ -1,52 +1,52 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import junit.framework.TestCase;
-
-public class NodeTupleTest extends TestCase {
-
- public void testNodeTuple1() {
- Node node = new ScalarNode(new Tag("!tag"), "value1", null, null, null);
- try {
- new NodeTuple(null, node);
- fail("Node must be provided.");
- } catch (Exception e) {
- assertEquals("Nodes must be provided.", e.getMessage());
- }
- }
-
- public void testNodeTuple2() {
- Node node = new ScalarNode(new Tag("!tag"), "value1", null, null, null);
- try {
- new NodeTuple(node, null);
- fail("Node must be provided.");
- } catch (Exception e) {
- assertEquals("Nodes must be provided.", e.getMessage());
- }
- }
-
- public void testToString() {
- Node key = new ScalarNode(Tag.STR, "key1", null, null, null);
- Node value = new ScalarNode(Tag.STR, "value1", null, null, null);
- NodeTuple tuple = new NodeTuple(key, value);
- assertEquals(
- "<NodeTuple keyNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=key1)>; valueNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=value1)>>",
- tuple.toString());
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import junit.framework.TestCase;
+
+public class NodeTupleTest extends TestCase {
+
+ public void testNodeTuple1() {
+ Node node = new ScalarNode(new Tag("!tag"), "value1", null, null, null);
+ try {
+ new NodeTuple(null, node);
+ fail("Node must be provided.");
+ } catch (Exception e) {
+ assertEquals("Nodes must be provided.", e.getMessage());
+ }
+ }
+
+ public void testNodeTuple2() {
+ Node node = new ScalarNode(new Tag("!tag"), "value1", null, null, null);
+ try {
+ new NodeTuple(node, null);
+ fail("Node must be provided.");
+ } catch (Exception e) {
+ assertEquals("Nodes must be provided.", e.getMessage());
+ }
+ }
+
+ public void testToString() {
+ Node key = new ScalarNode(Tag.STR, "key1", null, null, null);
+ Node value = new ScalarNode(Tag.STR, "value1", null, null, null);
+ NodeTuple tuple = new NodeTuple(key, value);
+ assertEquals(
+ "<NodeTuple keyNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=key1)>; valueNode=<org.yaml.snakeyaml.nodes.ScalarNode (tag=tag:yaml.org,2002:str, value=value1)>>",
+ tuple.toString());
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/nodes/ScalarNodeTest.java b/src/test/java/org/yaml/snakeyaml/nodes/ScalarNodeTest.java
index 64b531c..4740a83 100644
--- a/src/test/java/org/yaml/snakeyaml/nodes/ScalarNodeTest.java
+++ b/src/test/java/org/yaml/snakeyaml/nodes/ScalarNodeTest.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import junit.framework.TestCase;
-
-public class ScalarNodeTest extends TestCase {
-
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- public void testGetNodeId() {
- Node node = new ScalarNode(new Tag("str"), "text", null, null, '>');
- assertEquals(NodeId.scalar, node.getNodeId());
- }
-
- public void testToString() {
- Node node = new ScalarNode(new Tag("str"), "text", null, null, '>');
- assertTrue(node.toString().contains("ScalarNode"));
- assertTrue(node.toString().contains("tag="));
- assertTrue(node.toString().contains("value="));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import junit.framework.TestCase;
+
+public class ScalarNodeTest extends TestCase {
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ public void testGetNodeId() {
+ Node node = new ScalarNode(new Tag("str"), "text", null, null, '>');
+ assertEquals(NodeId.scalar, node.getNodeId());
+ }
+
+ public void testToString() {
+ Node node = new ScalarNode(new Tag("str"), "text", null, null, '>');
+ assertTrue(node.toString().contains("ScalarNode"));
+ assertTrue(node.toString().contains("tag="));
+ assertTrue(node.toString().contains("value="));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/nodes/SequenceNodeTest.java b/src/test/java/org/yaml/snakeyaml/nodes/SequenceNodeTest.java
index 46ba168..80de1f9 100644
--- a/src/test/java/org/yaml/snakeyaml/nodes/SequenceNodeTest.java
+++ b/src/test/java/org/yaml/snakeyaml/nodes/SequenceNodeTest.java
@@ -1,39 +1,39 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import java.util.ArrayList;
-
-import junit.framework.TestCase;
-
-public class SequenceNodeTest extends TestCase {
-
- public void testGetNodeId() {
- SequenceNode node = new SequenceNode(new Tag("!foo"), true, new ArrayList<Node>(), null,
- null, true);
- assertEquals(NodeId.sequence, node.getNodeId());
- }
-
- public void testNullValue() {
- try {
- new SequenceNode(new Tag("!foo"), true, null, null, null, true);
- fail("Value is required.");
- } catch (Exception e) {
- assertEquals("value in a Node is required.", e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import java.util.ArrayList;
+
+import junit.framework.TestCase;
+
+public class SequenceNodeTest extends TestCase {
+
+ public void testGetNodeId() {
+ SequenceNode node = new SequenceNode(new Tag("!foo"), true, new ArrayList<Node>(), null,
+ null, true);
+ assertEquals(NodeId.sequence, node.getNodeId());
+ }
+
+ public void testNullValue() {
+ try {
+ new SequenceNode(new Tag("!foo"), true, null, null, null, true);
+ fail("Value is required.");
+ } catch (Exception e) {
+ assertEquals("value in a Node is required.", e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/nodes/TagTest.java b/src/test/java/org/yaml/snakeyaml/nodes/TagTest.java
index 6b9df71..3797b3b 100644
--- a/src/test/java/org/yaml/snakeyaml/nodes/TagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/nodes/TagTest.java
@@ -1,124 +1,124 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import junit.framework.TestCase;
-
-public class TagTest extends TestCase {
-
- public void testCreate() {
- try {
- new Tag((String) null);
- fail();
- } catch (Exception e) {
- assertEquals("Tag must be provided.", e.getMessage());
- }
- try {
- new Tag("");
- fail();
- } catch (Exception e) {
- assertEquals("Tag must not be empty.", e.getMessage());
- }
- try {
- new Tag("!Dice ");
- fail();
- } catch (Exception e) {
- assertEquals("Tag must not contain leading or trailing spaces.", e.getMessage());
- }
- Tag tag = new Tag(TagTest.class);
- assertEquals(Tag.PREFIX + "org.yaml.snakeyaml.nodes.TagTest", tag.getValue());
- }
-
- public void testCreate2() {
- try {
- new Tag((Class<?>) null);
- fail();
- } catch (Exception e) {
- assertEquals("Class for tag must be provided.", e.getMessage());
- }
- }
-
- public void testGetClassName() {
- Tag tag = new Tag(Tag.PREFIX + "org.yaml.snakeyaml.nodes.TagTest");
- assertEquals("org.yaml.snakeyaml.nodes.TagTest", tag.getClassName());
- }
-
- public void testGetClassNameError() {
- try {
- Tag tag = new Tag("!TagTest");
- tag.getClassName();
- fail("Class name is only available for global tag");
- } catch (Exception e) {
- assertEquals("Invalid tag: !TagTest", e.getMessage());
- }
- }
-
- public void testLength() {
- String t = Tag.PREFIX + "org.yaml.snakeyaml.nodes.TagTest";
- Tag tag = new Tag(t);
- assertEquals(t.length(), tag.getLength());
- }
-
- public void testToString() {
- Tag tag = new Tag("!car");
- assertEquals("!car", tag.toString());
- }
-
- public void testUri1() {
- Tag tag = new Tag("!Académico");
- assertEquals("!Acad%C3%A9mico", tag.toString());
- }
-
- public void testUri2() {
- Tag tag = new Tag("!ruby/object:Test::Module::Sub2");
- assertEquals("!ruby/object:Test::Module::Sub2", tag.getValue());
- }
-
- public void testUri3() throws URISyntaxException {
- Tag tag = new Tag(new URI("!!java/javabean:foo.Bar"));
- assertEquals("!!java/javabean:foo.Bar", tag.toString());
- }
-
- public void testNullUri() throws URISyntaxException {
- try {
- new Tag((URI) null);
- fail("URI for tag must not be null.");
- } catch (Exception e) {
- assertEquals("URI for tag must be provided.", e.getMessage());
- }
- }
-
- public void testCompare() {
- Tag tag = new Tag("!car");
- assertEquals(0, tag.compareTo(new Tag("!car")));
- }
-
- public void testEqualsObject() {
- Tag tag = new Tag("!car");
- assertEquals(tag, tag);
- // TODO should be removed when tags as Strings are not used (2.0?)
- assertTrue("Temporarily allow compare Tag and String.", tag.equals("!car"));
- assertFalse("Temporarily allow compare Tag and String.", tag.equals("!foo"));
- assertEquals(tag, new Tag("!car"));
- assertFalse(tag.equals(new Tag("!!str")));
- assertFalse(tag.equals(null));
- assertFalse(tag.equals(25));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import junit.framework.TestCase;
+
+public class TagTest extends TestCase {
+
+ public void testCreate() {
+ try {
+ new Tag((String) null);
+ fail();
+ } catch (Exception e) {
+ assertEquals("Tag must be provided.", e.getMessage());
+ }
+ try {
+ new Tag("");
+ fail();
+ } catch (Exception e) {
+ assertEquals("Tag must not be empty.", e.getMessage());
+ }
+ try {
+ new Tag("!Dice ");
+ fail();
+ } catch (Exception e) {
+ assertEquals("Tag must not contain leading or trailing spaces.", e.getMessage());
+ }
+ Tag tag = new Tag(TagTest.class);
+ assertEquals(Tag.PREFIX + "org.yaml.snakeyaml.nodes.TagTest", tag.getValue());
+ }
+
+ public void testCreate2() {
+ try {
+ new Tag((Class<?>) null);
+ fail();
+ } catch (Exception e) {
+ assertEquals("Class for tag must be provided.", e.getMessage());
+ }
+ }
+
+ public void testGetClassName() {
+ Tag tag = new Tag(Tag.PREFIX + "org.yaml.snakeyaml.nodes.TagTest");
+ assertEquals("org.yaml.snakeyaml.nodes.TagTest", tag.getClassName());
+ }
+
+ public void testGetClassNameError() {
+ try {
+ Tag tag = new Tag("!TagTest");
+ tag.getClassName();
+ fail("Class name is only available for global tag");
+ } catch (Exception e) {
+ assertEquals("Invalid tag: !TagTest", e.getMessage());
+ }
+ }
+
+ public void testLength() {
+ String t = Tag.PREFIX + "org.yaml.snakeyaml.nodes.TagTest";
+ Tag tag = new Tag(t);
+ assertEquals(t.length(), tag.getLength());
+ }
+
+ public void testToString() {
+ Tag tag = new Tag("!car");
+ assertEquals("!car", tag.toString());
+ }
+
+ public void testUri1() {
+ Tag tag = new Tag("!Académico");
+ assertEquals("!Acad%C3%A9mico", tag.toString());
+ }
+
+ public void testUri2() {
+ Tag tag = new Tag("!ruby/object:Test::Module::Sub2");
+ assertEquals("!ruby/object:Test::Module::Sub2", tag.getValue());
+ }
+
+ public void testUri3() throws URISyntaxException {
+ Tag tag = new Tag(new URI("!!java/javabean:foo.Bar"));
+ assertEquals("!!java/javabean:foo.Bar", tag.toString());
+ }
+
+ public void testNullUri() throws URISyntaxException {
+ try {
+ new Tag((URI) null);
+ fail("URI for tag must not be null.");
+ } catch (Exception e) {
+ assertEquals("URI for tag must be provided.", e.getMessage());
+ }
+ }
+
+ public void testCompare() {
+ Tag tag = new Tag("!car");
+ assertEquals(0, tag.compareTo(new Tag("!car")));
+ }
+
+ public void testEqualsObject() {
+ Tag tag = new Tag("!car");
+ assertEquals(tag, tag);
+ // TODO should be removed when tags as Strings are not used (2.0?)
+ assertTrue("Temporarily allow compare Tag and String.", tag.equals("!car"));
+ assertFalse("Temporarily allow compare Tag and String.", tag.equals("!foo"));
+ assertEquals(tag, new Tag("!car"));
+ assertFalse(tag.equals(new Tag("!!str")));
+ assertFalse(tag.equals(null));
+ assertFalse(tag.equals(25));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/nodes/TagsTest.java b/src/test/java/org/yaml/snakeyaml/nodes/TagsTest.java
index fec1c29..1a3ad98 100644
--- a/src/test/java/org/yaml/snakeyaml/nodes/TagsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/nodes/TagsTest.java
@@ -1,58 +1,58 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.nodes;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-public class TagsTest extends TestCase {
-
- public void testGetGlobalTagForClass() {
- assertEquals(new Tag("tag:yaml.org,2002:java.lang.String"), new Tag(String.class));
- assertEquals(new Tag("tag:yaml.org,2002:org.yaml.snakeyaml.nodes.TagsTest"), new Tag(
- TagsTest.class));
- }
-
- /**
- * test fix for issue 18 -
- * http://code.google.com/p/snakeyaml/issues/detail?id=18
- */
- public void testLong() {
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
- Yaml yaml = new Yaml(options);
- Foo foo = new Foo();
- String output = yaml.dump(foo);
- // System.out.println(output);
- Foo foo2 = (Foo) yaml.load(output);
- assertEquals(new Long(42L), foo2.getBar());
- }
-
- public static class Foo {
- private Long bar = Long.valueOf(42L);
-
- public Long getBar() {
- return bar;
- }
-
- public void setBar(Long bar) {
- this.bar = bar;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.nodes;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+public class TagsTest extends TestCase {
+
+ public void testGetGlobalTagForClass() {
+ assertEquals(new Tag("tag:yaml.org,2002:java.lang.String"), new Tag(String.class));
+ assertEquals(new Tag("tag:yaml.org,2002:org.yaml.snakeyaml.nodes.TagsTest"), new Tag(
+ TagsTest.class));
+ }
+
+ /**
+ * test fix for issue 18 -
+ * http://code.google.com/p/snakeyaml/issues/detail?id=18
+ */
+ public void testLong() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
+ Yaml yaml = new Yaml(options);
+ Foo foo = new Foo();
+ String output = yaml.dump(foo);
+ // System.out.println(output);
+ Foo foo2 = (Foo) yaml.load(output);
+ assertEquals(new Long(42L), foo2.getBar());
+ }
+
+ public static class Foo {
+ private Long bar = Long.valueOf(42L);
+
+ public Long getBar() {
+ return bar;
+ }
+
+ public void setBar(Long bar) {
+ this.bar = bar;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/parser/ParserImplTest.java b/src/test/java/org/yaml/snakeyaml/parser/ParserImplTest.java
index 935cad5..c1b8b33 100644
--- a/src/test/java/org/yaml/snakeyaml/parser/ParserImplTest.java
+++ b/src/test/java/org/yaml/snakeyaml/parser/ParserImplTest.java
@@ -1,95 +1,95 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.parser;
-
-import java.util.LinkedList;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.events.DocumentEndEvent;
-import org.yaml.snakeyaml.events.DocumentStartEvent;
-import org.yaml.snakeyaml.events.Event;
-import org.yaml.snakeyaml.events.ImplicitTuple;
-import org.yaml.snakeyaml.events.MappingEndEvent;
-import org.yaml.snakeyaml.events.MappingStartEvent;
-import org.yaml.snakeyaml.events.ScalarEvent;
-import org.yaml.snakeyaml.events.SequenceEndEvent;
-import org.yaml.snakeyaml.events.SequenceStartEvent;
-import org.yaml.snakeyaml.events.StreamEndEvent;
-import org.yaml.snakeyaml.events.StreamStartEvent;
-import org.yaml.snakeyaml.reader.StreamReader;
-
-public class ParserImplTest extends TestCase {
-
- public void testGetEvent() {
- String data = "string: abcd";
- StreamReader reader = new StreamReader(data);
- Parser parser = new ParserImpl(reader);
- Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
- LinkedList<Event> etalonEvents = new LinkedList<Event>();
- etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
- etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
- etalonEvents.add(new MappingStartEvent(null, null, true, dummyMark, dummyMark,
- Boolean.FALSE));
- etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "string",
- dummyMark, dummyMark, (char) 0));
- etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "abcd",
- dummyMark, dummyMark, (char) 0));
- etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
- etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
- etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
- while (parser.checkEvent(null)) {
- Event event = parser.getEvent();
- if (etalonEvents.isEmpty()) {
- fail("unexpected event: " + event);
- }
- assertEquals(etalonEvents.removeFirst(), event);
- }
- assertFalse("Must contain no more events: " + parser.getEvent(), parser.checkEvent(null));
- }
-
- public void testGetEvent2() {
- String data = "american:\n - Boston Red Sox";
- StreamReader reader = new StreamReader(data);
- Parser parser = new ParserImpl(reader);
- Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
- LinkedList<Event> etalonEvents = new LinkedList<Event>();
- etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
- etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
- etalonEvents
- .add(new MappingStartEvent(null, null, true, dummyMark, dummyMark, Boolean.TRUE));
- etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "american",
- dummyMark, dummyMark, (char) 0));
- etalonEvents.add(new SequenceStartEvent(null, null, true, dummyMark, dummyMark,
- Boolean.FALSE));
- etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false),
- "Boston Red Sox", dummyMark, dummyMark, (char) 0));
- etalonEvents.add(new SequenceEndEvent(dummyMark, dummyMark));
- etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
- etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
- etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
- while (parser.checkEvent(null)) {
- Event event = parser.getEvent();
- if (etalonEvents.isEmpty()) {
- fail("unexpected event: " + event);
- }
- assertEquals(etalonEvents.removeFirst(), event);
- }
- assertFalse("Must contain no more events: " + parser.getEvent(), parser.checkEvent(null));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.parser;
+
+import java.util.LinkedList;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.events.DocumentEndEvent;
+import org.yaml.snakeyaml.events.DocumentStartEvent;
+import org.yaml.snakeyaml.events.Event;
+import org.yaml.snakeyaml.events.ImplicitTuple;
+import org.yaml.snakeyaml.events.MappingEndEvent;
+import org.yaml.snakeyaml.events.MappingStartEvent;
+import org.yaml.snakeyaml.events.ScalarEvent;
+import org.yaml.snakeyaml.events.SequenceEndEvent;
+import org.yaml.snakeyaml.events.SequenceStartEvent;
+import org.yaml.snakeyaml.events.StreamEndEvent;
+import org.yaml.snakeyaml.events.StreamStartEvent;
+import org.yaml.snakeyaml.reader.StreamReader;
+
+public class ParserImplTest extends TestCase {
+
+ public void testGetEvent() {
+ String data = "string: abcd";
+ StreamReader reader = new StreamReader(data);
+ Parser parser = new ParserImpl(reader);
+ Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
+ LinkedList<Event> etalonEvents = new LinkedList<Event>();
+ etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
+ etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
+ etalonEvents.add(new MappingStartEvent(null, null, true, dummyMark, dummyMark,
+ Boolean.FALSE));
+ etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "string",
+ dummyMark, dummyMark, (char) 0));
+ etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "abcd",
+ dummyMark, dummyMark, (char) 0));
+ etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
+ etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
+ etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
+ while (parser.checkEvent(null)) {
+ Event event = parser.getEvent();
+ if (etalonEvents.isEmpty()) {
+ fail("unexpected event: " + event);
+ }
+ assertEquals(etalonEvents.removeFirst(), event);
+ }
+ assertFalse("Must contain no more events: " + parser.getEvent(), parser.checkEvent(null));
+ }
+
+ public void testGetEvent2() {
+ String data = "american:\n - Boston Red Sox";
+ StreamReader reader = new StreamReader(data);
+ Parser parser = new ParserImpl(reader);
+ Mark dummyMark = new Mark("dummy", 0, 0, 0, "", 0);
+ LinkedList<Event> etalonEvents = new LinkedList<Event>();
+ etalonEvents.add(new StreamStartEvent(dummyMark, dummyMark));
+ etalonEvents.add(new DocumentStartEvent(dummyMark, dummyMark, false, null, null));
+ etalonEvents
+ .add(new MappingStartEvent(null, null, true, dummyMark, dummyMark, Boolean.TRUE));
+ etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false), "american",
+ dummyMark, dummyMark, (char) 0));
+ etalonEvents.add(new SequenceStartEvent(null, null, true, dummyMark, dummyMark,
+ Boolean.FALSE));
+ etalonEvents.add(new ScalarEvent(null, null, new ImplicitTuple(true, false),
+ "Boston Red Sox", dummyMark, dummyMark, (char) 0));
+ etalonEvents.add(new SequenceEndEvent(dummyMark, dummyMark));
+ etalonEvents.add(new MappingEndEvent(dummyMark, dummyMark));
+ etalonEvents.add(new DocumentEndEvent(dummyMark, dummyMark, false));
+ etalonEvents.add(new StreamEndEvent(dummyMark, dummyMark));
+ while (parser.checkEvent(null)) {
+ Event event = parser.getEvent();
+ if (etalonEvents.isEmpty()) {
+ fail("unexpected event: " + event);
+ }
+ assertEquals(etalonEvents.removeFirst(), event);
+ }
+ assertFalse("Must contain no more events: " + parser.getEvent(), parser.checkEvent(null));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/reader/IoReaderTest.java b/src/test/java/org/yaml/snakeyaml/reader/IoReaderTest.java
index b88a67b..b3d360d 100644
--- a/src/test/java/org/yaml/snakeyaml/reader/IoReaderTest.java
+++ b/src/test/java/org/yaml/snakeyaml/reader/IoReaderTest.java
@@ -1,50 +1,50 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.reader;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class IoReaderTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testCheckPrintable() throws IOException {
- Yaml yaml = new Yaml();
- Reader reader = new FileReader("src/test/resources/specification/example2_1.yaml");
- List<String> list = (List<String>) yaml.load(reader);
- reader.close();
- assertEquals(3, list.size());
- }
-
- /**
- * test input which is longer then internal buffer - 1k
- */
- public void testBigInput() throws IOException {
- Yaml yaml = new Yaml();
- Reader reader = new FileReader("src/test/resources/reader/large.yaml");
- @SuppressWarnings("unchecked")
- List<Object> list = (List<Object>) yaml.load(reader);
- reader.close();
- assertEquals(37, list.size());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.reader;
+
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class IoReaderTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testCheckPrintable() throws IOException {
+ Yaml yaml = new Yaml();
+ Reader reader = new FileReader("src/test/resources/specification/example2_1.yaml");
+ List<String> list = (List<String>) yaml.load(reader);
+ reader.close();
+ assertEquals(3, list.size());
+ }
+
+ /**
+ * test input which is longer then internal buffer - 1k
+ */
+ public void testBigInput() throws IOException {
+ Yaml yaml = new Yaml();
+ Reader reader = new FileReader("src/test/resources/reader/large.yaml");
+ @SuppressWarnings("unchecked")
+ List<Object> list = (List<Object>) yaml.load(reader);
+ reader.close();
+ assertEquals(37, list.size());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/reader/ReaderBomTest.java b/src/test/java/org/yaml/snakeyaml/reader/ReaderBomTest.java
index 10c0447..a0243b4 100644
--- a/src/test/java/org/yaml/snakeyaml/reader/ReaderBomTest.java
+++ b/src/test/java/org/yaml/snakeyaml/reader/ReaderBomTest.java
@@ -1,117 +1,117 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.reader;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.nio.charset.Charset;
-
-import junit.framework.TestCase;
-
-public class ReaderBomTest extends TestCase {
-
- public void testReader() {
- Reader input = new StringReader("test");
- StreamReader reader = new StreamReader(input);
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('e', reader.peek());
- reader.forward(1);
- assertEquals('s', reader.peek());
- reader.forward(1);
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('\u0000', reader.peek());
- }
-
- public void testNoBom() throws IOException {
- byte[] data = "test".getBytes("UTF-8");
- ByteArrayInputStream input = new ByteArrayInputStream(data);
- Reader r = new UnicodeReader(input);
- StreamReader reader = new StreamReader(r);
- assertEquals('t', reader.peek());
- assertEquals(Charset.forName("UTF-8"), reader.getEncoding());
- reader.forward(1);
- assertEquals('e', reader.peek());
- reader.forward(1);
- assertEquals('s', reader.peek());
- reader.forward(1);
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('\u0000', reader.peek());
- r.close();
- }
-
- public void testUtf8Bom() throws IOException {
- File file = new File("src/test/resources/reader/utf-8.txt");
- assertTrue("Test file not found: " + file.getAbsolutePath(), file.exists());
- InputStream input = new FileInputStream(file);
- StreamReader reader = new StreamReader(new UnicodeReader(input));
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('e', reader.peek());
- reader.forward(1);
- assertEquals('s', reader.peek());
- reader.forward(1);
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('\u0000', reader.peek());
- assertEquals(Charset.forName("UTF-8"), reader.getEncoding());
- input.close();
- }
-
- public void testUnicodeLeBom() throws IOException {
- File file = new File("src/test/resources/reader/unicode-16le.txt");
- assertTrue("Test file not found: " + file.getAbsolutePath(), file.exists());
- InputStream input = new FileInputStream(file);
- StreamReader reader = new StreamReader(new UnicodeReader(input));
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('e', reader.peek());
- reader.forward(1);
- assertEquals('s', reader.peek());
- reader.forward(1);
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('\u0000', reader.peek());
- assertEquals(Charset.forName("UTF-16LE"), reader.getEncoding());
- input.close();
- }
-
- public void testUnicodeBeBom() throws IOException {
- File file = new File("src/test/resources/reader/unicode-16be.txt");
- assertTrue("Test file not found: " + file.getAbsolutePath(), file.exists());
- InputStream input = new FileInputStream(file);
- StreamReader reader = new StreamReader(new UnicodeReader(input));
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('e', reader.peek());
- reader.forward(1);
- assertEquals('s', reader.peek());
- reader.forward(1);
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('\u0000', reader.peek());
- assertEquals(Charset.forName("UTF-16BE"), reader.getEncoding());
- input.close();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.reader;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.nio.charset.Charset;
+
+import junit.framework.TestCase;
+
+public class ReaderBomTest extends TestCase {
+
+ public void testReader() {
+ Reader input = new StringReader("test");
+ StreamReader reader = new StreamReader(input);
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('e', reader.peek());
+ reader.forward(1);
+ assertEquals('s', reader.peek());
+ reader.forward(1);
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('\u0000', reader.peek());
+ }
+
+ public void testNoBom() throws IOException {
+ byte[] data = "test".getBytes("UTF-8");
+ ByteArrayInputStream input = new ByteArrayInputStream(data);
+ Reader r = new UnicodeReader(input);
+ StreamReader reader = new StreamReader(r);
+ assertEquals('t', reader.peek());
+ assertEquals(Charset.forName("UTF-8"), reader.getEncoding());
+ reader.forward(1);
+ assertEquals('e', reader.peek());
+ reader.forward(1);
+ assertEquals('s', reader.peek());
+ reader.forward(1);
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('\u0000', reader.peek());
+ r.close();
+ }
+
+ public void testUtf8Bom() throws IOException {
+ File file = new File("src/test/resources/reader/utf-8.txt");
+ assertTrue("Test file not found: " + file.getAbsolutePath(), file.exists());
+ InputStream input = new FileInputStream(file);
+ StreamReader reader = new StreamReader(new UnicodeReader(input));
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('e', reader.peek());
+ reader.forward(1);
+ assertEquals('s', reader.peek());
+ reader.forward(1);
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('\u0000', reader.peek());
+ assertEquals(Charset.forName("UTF-8"), reader.getEncoding());
+ input.close();
+ }
+
+ public void testUnicodeLeBom() throws IOException {
+ File file = new File("src/test/resources/reader/unicode-16le.txt");
+ assertTrue("Test file not found: " + file.getAbsolutePath(), file.exists());
+ InputStream input = new FileInputStream(file);
+ StreamReader reader = new StreamReader(new UnicodeReader(input));
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('e', reader.peek());
+ reader.forward(1);
+ assertEquals('s', reader.peek());
+ reader.forward(1);
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('\u0000', reader.peek());
+ assertEquals(Charset.forName("UTF-16LE"), reader.getEncoding());
+ input.close();
+ }
+
+ public void testUnicodeBeBom() throws IOException {
+ File file = new File("src/test/resources/reader/unicode-16be.txt");
+ assertTrue("Test file not found: " + file.getAbsolutePath(), file.exists());
+ InputStream input = new FileInputStream(file);
+ StreamReader reader = new StreamReader(new UnicodeReader(input));
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('e', reader.peek());
+ reader.forward(1);
+ assertEquals('s', reader.peek());
+ reader.forward(1);
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('\u0000', reader.peek());
+ assertEquals(Charset.forName("UTF-16BE"), reader.getEncoding());
+ input.close();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/reader/ReaderStringTest.java b/src/test/java/org/yaml/snakeyaml/reader/ReaderStringTest.java
index 37b1de6..3006c26 100644
--- a/src/test/java/org/yaml/snakeyaml/reader/ReaderStringTest.java
+++ b/src/test/java/org/yaml/snakeyaml/reader/ReaderStringTest.java
@@ -1,108 +1,108 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.reader;
-
-import java.util.regex.Matcher;
-
-import junit.framework.TestCase;
-
-public class ReaderStringTest extends TestCase {
-
- public void testCheckPrintable() {
- StreamReader reader = new StreamReader("test");
- reader.checkPrintable("test");
- Matcher matcher = StreamReader.NON_PRINTABLE.matcher("test");
- assertFalse(matcher.find());
-
- try {
- reader.checkPrintable("test".toCharArray(), 0, 4);
- } catch (ReaderException e) {
- fail();
- }
-
- }
-
- public void testCheckNonPrintable() {
- Matcher matcher = StreamReader.NON_PRINTABLE.matcher("test\u0005 fail");
- assertTrue(matcher.find());
- try {
- new StreamReader("test\u0005 fail");
- fail("Non printable Unicode characters must not be accepted.");
- } catch (ReaderException e) {
- assertEquals(
- "unacceptable character '' (0x5) special characters are not allowed\nin \"<string>\", position 4",
- e.toString());
- }
- }
-
- /**
- * test that regular expression and array check work the same
- */
- public void testCheckAll() {
- StreamReader streamReader = new StreamReader("");
- for (char i = 0; i < 256 * 256 - 1; i++) {
- char[] chars = new char[1];
- chars[0] = i;
- String str = new String(chars);
- Matcher matcher = StreamReader.NON_PRINTABLE.matcher(str);
- boolean regularExpressionResult = !matcher.find();
-
- boolean charsArrayResult = true;
- try {
- streamReader.checkPrintable(chars, 0, 1);
- } catch (Exception e) {
- String error = e.getMessage();
- assertTrue(
- error,
- error.startsWith("unacceptable character")
- || error.equals("special characters are not allowed"));
- charsArrayResult = false;
- }
- assertEquals("Failed for #" + i, regularExpressionResult, charsArrayResult);
- }
- }
-
- public void testForward() {
- StreamReader reader = new StreamReader("test");
- while (reader.peek() != '\u0000') {
- reader.forward(1);
- }
- reader = new StreamReader("test");
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('e', reader.peek());
- reader.forward(1);
- assertEquals('s', reader.peek());
- reader.forward(1);
- assertEquals('t', reader.peek());
- reader.forward(1);
- assertEquals('\u0000', reader.peek());
- }
-
- public void testPeekInt() {
- StreamReader reader = new StreamReader("test");
- assertEquals('t', reader.peek(0));
- assertEquals('e', reader.peek(1));
- assertEquals('s', reader.peek(2));
- assertEquals('t', reader.peek(3));
- reader.forward(1);
- assertEquals('e', reader.peek(0));
- assertEquals('s', reader.peek(1));
- assertEquals('t', reader.peek(2));
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.reader;
+
+import java.util.regex.Matcher;
+
+import junit.framework.TestCase;
+
+public class ReaderStringTest extends TestCase {
+
+ public void testCheckPrintable() {
+ StreamReader reader = new StreamReader("test");
+ reader.checkPrintable("test");
+ Matcher matcher = StreamReader.NON_PRINTABLE.matcher("test");
+ assertFalse(matcher.find());
+
+ try {
+ reader.checkPrintable("test".toCharArray(), 0, 4);
+ } catch (ReaderException e) {
+ fail();
+ }
+
+ }
+
+ public void testCheckNonPrintable() {
+ Matcher matcher = StreamReader.NON_PRINTABLE.matcher("test\u0005 fail");
+ assertTrue(matcher.find());
+ try {
+ new StreamReader("test\u0005 fail");
+ fail("Non printable Unicode characters must not be accepted.");
+ } catch (ReaderException e) {
+ assertEquals(
+ "unacceptable character '' (0x5) special characters are not allowed\nin \"<string>\", position 4",
+ e.toString());
+ }
+ }
+
+ /**
+ * test that regular expression and array check work the same
+ */
+ public void testCheckAll() {
+ StreamReader streamReader = new StreamReader("");
+ for (char i = 0; i < 256 * 256 - 1; i++) {
+ char[] chars = new char[1];
+ chars[0] = i;
+ String str = new String(chars);
+ Matcher matcher = StreamReader.NON_PRINTABLE.matcher(str);
+ boolean regularExpressionResult = !matcher.find();
+
+ boolean charsArrayResult = true;
+ try {
+ streamReader.checkPrintable(chars, 0, 1);
+ } catch (Exception e) {
+ String error = e.getMessage();
+ assertTrue(
+ error,
+ error.startsWith("unacceptable character")
+ || error.equals("special characters are not allowed"));
+ charsArrayResult = false;
+ }
+ assertEquals("Failed for #" + i, regularExpressionResult, charsArrayResult);
+ }
+ }
+
+ public void testForward() {
+ StreamReader reader = new StreamReader("test");
+ while (reader.peek() != '\u0000') {
+ reader.forward(1);
+ }
+ reader = new StreamReader("test");
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('e', reader.peek());
+ reader.forward(1);
+ assertEquals('s', reader.peek());
+ reader.forward(1);
+ assertEquals('t', reader.peek());
+ reader.forward(1);
+ assertEquals('\u0000', reader.peek());
+ }
+
+ public void testPeekInt() {
+ StreamReader reader = new StreamReader("test");
+ assertEquals('t', reader.peek(0));
+ assertEquals('e', reader.peek(1));
+ assertEquals('s', reader.peek(2));
+ assertEquals('t', reader.peek(3));
+ reader.forward(1);
+ assertEquals('e', reader.peek(0));
+ assertEquals('s', reader.peek(1));
+ assertEquals('t', reader.peek(2));
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/AbstractHuman.java b/src/test/java/org/yaml/snakeyaml/recursive/AbstractHuman.java
index 0c40f44..ce24adc 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/AbstractHuman.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/AbstractHuman.java
@@ -1,87 +1,87 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive;
-
-import java.util.Date;
-
-public abstract class AbstractHuman {
- private String name;
- private Date birthday;
- private String birthPlace;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Date getBirthday() {
- return birthday;
- }
-
- public void setBirthday(Date birthday) {
- this.birthday = birthday;
- }
-
- public String getBirthPlace() {
- return birthPlace;
- }
-
- public void setBirthPlace(String birthPlace) {
- this.birthPlace = birthPlace;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((birthPlace == null) ? 0 : birthPlace.hashCode());
- result = prime * result + ((birthday == null) ? 0 : birthday.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- AbstractHuman other = (AbstractHuman) obj;
- if (birthPlace == null) {
- if (other.birthPlace != null)
- return false;
- } else if (!birthPlace.equals(other.birthPlace))
- return false;
- if (birthday == null) {
- if (other.birthday != null)
- return false;
- } else if (!birthday.equals(other.birthday))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive;
+
+import java.util.Date;
+
+public abstract class AbstractHuman {
+ private String name;
+ private Date birthday;
+ private String birthPlace;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Date getBirthday() {
+ return birthday;
+ }
+
+ public void setBirthday(Date birthday) {
+ this.birthday = birthday;
+ }
+
+ public String getBirthPlace() {
+ return birthPlace;
+ }
+
+ public void setBirthPlace(String birthPlace) {
+ this.birthPlace = birthPlace;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((birthPlace == null) ? 0 : birthPlace.hashCode());
+ result = prime * result + ((birthday == null) ? 0 : birthday.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ AbstractHuman other = (AbstractHuman) obj;
+ if (birthPlace == null) {
+ if (other.birthPlace != null)
+ return false;
+ } else if (!birthPlace.equals(other.birthPlace))
+ return false;
+ if (birthday == null) {
+ if (other.birthday != null)
+ return false;
+ } else if (!birthday.equals(other.birthday))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/Human.java b/src/test/java/org/yaml/snakeyaml/recursive/Human.java
index f96d369..b55718a 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/Human.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/Human.java
@@ -1,74 +1,74 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class Human extends AbstractHuman {
-
- private Human father;
- private Human mother;
- private Human partner;
- private Human bankAccountOwner;
- protected Set<Human> children;
-
- public Human() {
- children = new HashSet<Human>();
- }
-
- public Human getFather() {
- return father;
- }
-
- public void setFather(Human father) {
- this.father = father;
- }
-
- public Human getMother() {
- return mother;
- }
-
- public void setMother(Human mother) {
- this.mother = mother;
- }
-
- public Human getPartner() {
- return partner;
- }
-
- public void setPartner(Human partner) {
- this.partner = partner;
- }
-
- public Human getBankAccountOwner() {
- return bankAccountOwner;
- }
-
- public void setBankAccountOwner(Human bankAccountOwner) {
- this.bankAccountOwner = bankAccountOwner;
- }
-
- public Set<Human> getChildren() {
- return children;
- }
-
- public void setChildren(Set<Human> children) {
- this.children = children;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive;
+
+import java.util.HashSet;
+import java.util.Set;
+
+public class Human extends AbstractHuman {
+
+ private Human father;
+ private Human mother;
+ private Human partner;
+ private Human bankAccountOwner;
+ protected Set<Human> children;
+
+ public Human() {
+ children = new HashSet<Human>();
+ }
+
+ public Human getFather() {
+ return father;
+ }
+
+ public void setFather(Human father) {
+ this.father = father;
+ }
+
+ public Human getMother() {
+ return mother;
+ }
+
+ public void setMother(Human mother) {
+ this.mother = mother;
+ }
+
+ public Human getPartner() {
+ return partner;
+ }
+
+ public void setPartner(Human partner) {
+ this.partner = partner;
+ }
+
+ public Human getBankAccountOwner() {
+ return bankAccountOwner;
+ }
+
+ public void setBankAccountOwner(Human bankAccountOwner) {
+ this.bankAccountOwner = bankAccountOwner;
+ }
+
+ public Set<Human> getChildren() {
+ return children;
+ }
+
+ public void setChildren(Set<Human> children) {
+ this.children = children;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/Human2.java b/src/test/java/org/yaml/snakeyaml/recursive/Human2.java
index a4cf28d..67dfdda 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/Human2.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/Human2.java
@@ -1,74 +1,74 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class Human2 extends AbstractHuman {
-
- private Human2 father;
- private Human2 mother;
- private Human2 partner;
- private Human2 bankAccountOwner;
- protected Map<Human2, String> children;
-
- public Human2() {
- children = new HashMap<Human2, String>();
- }
-
- public Human2 getFather() {
- return father;
- }
-
- public void setFather(Human2 father) {
- this.father = father;
- }
-
- public Human2 getMother() {
- return mother;
- }
-
- public void setMother(Human2 mother) {
- this.mother = mother;
- }
-
- public Human2 getPartner() {
- return partner;
- }
-
- public void setPartner(Human2 partner) {
- this.partner = partner;
- }
-
- public Human2 getBankAccountOwner() {
- return bankAccountOwner;
- }
-
- public void setBankAccountOwner(Human2 bankAccountOwner) {
- this.bankAccountOwner = bankAccountOwner;
- }
-
- public Map<Human2, String> getChildren() {
- return children;
- }
-
- public void setChildren(Map<Human2, String> children) {
- this.children = children;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class Human2 extends AbstractHuman {
+
+ private Human2 father;
+ private Human2 mother;
+ private Human2 partner;
+ private Human2 bankAccountOwner;
+ protected Map<Human2, String> children;
+
+ public Human2() {
+ children = new HashMap<Human2, String>();
+ }
+
+ public Human2 getFather() {
+ return father;
+ }
+
+ public void setFather(Human2 father) {
+ this.father = father;
+ }
+
+ public Human2 getMother() {
+ return mother;
+ }
+
+ public void setMother(Human2 mother) {
+ this.mother = mother;
+ }
+
+ public Human2 getPartner() {
+ return partner;
+ }
+
+ public void setPartner(Human2 partner) {
+ this.partner = partner;
+ }
+
+ public Human2 getBankAccountOwner() {
+ return bankAccountOwner;
+ }
+
+ public void setBankAccountOwner(Human2 bankAccountOwner) {
+ this.bankAccountOwner = bankAccountOwner;
+ }
+
+ public Map<Human2, String> getChildren() {
+ return children;
+ }
+
+ public void setChildren(Map<Human2, String> children) {
+ this.children = children;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/Human3.java b/src/test/java/org/yaml/snakeyaml/recursive/Human3.java
index 56f9a86..e9140c8 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/Human3.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/Human3.java
@@ -1,74 +1,74 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class Human3 extends AbstractHuman {
-
- private Human3 father;
- private Human3 mother;
- private Human3 partner;
- private Human3 bankAccountOwner;
- protected List<Human3> children;
-
- public Human3() {
- children = new ArrayList<Human3>();
- }
-
- public Human3 getFather() {
- return father;
- }
-
- public void setFather(Human3 father) {
- this.father = father;
- }
-
- public Human3 getMother() {
- return mother;
- }
-
- public void setMother(Human3 mother) {
- this.mother = mother;
- }
-
- public Human3 getPartner() {
- return partner;
- }
-
- public void setPartner(Human3 partner) {
- this.partner = partner;
- }
-
- public Human3 getBankAccountOwner() {
- return bankAccountOwner;
- }
-
- public void setBankAccountOwner(Human3 bankAccountOwner) {
- this.bankAccountOwner = bankAccountOwner;
- }
-
- public List<Human3> getChildren() {
- return children;
- }
-
- public void setChildren(List<Human3> children) {
- this.children = children;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Human3 extends AbstractHuman {
+
+ private Human3 father;
+ private Human3 mother;
+ private Human3 partner;
+ private Human3 bankAccountOwner;
+ protected List<Human3> children;
+
+ public Human3() {
+ children = new ArrayList<Human3>();
+ }
+
+ public Human3 getFather() {
+ return father;
+ }
+
+ public void setFather(Human3 father) {
+ this.father = father;
+ }
+
+ public Human3 getMother() {
+ return mother;
+ }
+
+ public void setMother(Human3 mother) {
+ this.mother = mother;
+ }
+
+ public Human3 getPartner() {
+ return partner;
+ }
+
+ public void setPartner(Human3 partner) {
+ this.partner = partner;
+ }
+
+ public Human3 getBankAccountOwner() {
+ return bankAccountOwner;
+ }
+
+ public void setBankAccountOwner(Human3 bankAccountOwner) {
+ this.bankAccountOwner = bankAccountOwner;
+ }
+
+ public List<Human3> getChildren() {
+ return children;
+ }
+
+ public void setChildren(List<Human3> children) {
+ this.children = children;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/HumanTest.java b/src/test/java/org/yaml/snakeyaml/recursive/HumanTest.java
index 5576725..228070a 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/HumanTest.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/HumanTest.java
@@ -1,659 +1,659 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class HumanTest extends TestCase {
-
- public void testNoChildren() {
- Human father = new Human();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- Human mother = new Human();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- Yaml yaml = new Yaml();
- String output = yaml.dump(father);
- String etalon = Util.getLocalResource("recursive/no-children-1.yaml");
- assertEquals(etalon, output);
- //
- Human father2 = (Human) yaml.load(output);
- assertNotNull(father2);
- assertEquals("Father", father2.getName());
- assertEquals("Mother", father2.getPartner().getName());
- assertEquals("Father", father2.getBankAccountOwner().getName());
- assertSame(father2, father2.getBankAccountOwner());
- }
-
- public void testNoChildrenPretty() {
- Human father = new Human();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- Human mother = new Human();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- DumperOptions options = new DumperOptions();
- options.setPrettyFlow(true);
- options.setDefaultFlowStyle(FlowStyle.FLOW);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(father);
- String etalon = Util.getLocalResource("recursive/no-children-1-pretty.yaml");
- assertEquals(etalon, output);
- //
- Human father2 = (Human) yaml.load(output);
- assertNotNull(father2);
- assertEquals("Father", father2.getName());
- assertEquals("Mother", father2.getPartner().getName());
- assertEquals("Father", father2.getBankAccountOwner().getName());
- assertSame(father2, father2.getBankAccountOwner());
- }
-
- public void testChildren() {
- Human father = new Human();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- Human mother = new Human();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- Human son = new Human();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- Human daughter = new Human();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- Set<Human> children = new LinkedHashSet<Human>(2);
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
- Yaml beanDumper = new Yaml();
- String output = beanDumper.dumpAsMap(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-children.yaml");
- assertEquals(etalon, output);
- TypeDescription humanDescription = new TypeDescription(Human.class);
- humanDescription.putMapPropertyType("children", Human.class, Object.class);
- Yaml beanLoader = new Yaml(new Constructor(humanDescription));
- //
- Human son2 = beanLoader.loadAs(output, Human.class);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- Human father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- Set<Human> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- // check if type descriptor was correct
- assertSame(Human.class, child.getClass());
- }
-
- // check if hashCode is correct
- validateSet(children2);
- }
-
- public void testChildrenPretty() {
- Human father = new Human();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- Human mother = new Human();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- Human son = new Human();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- Human daughter = new Human();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- Set<Human> children = new LinkedHashSet<Human>(2);
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.FLOW);
- options.setPrettyFlow(true);
- Yaml beanDumper = new Yaml(options);
- String output = beanDumper.dump(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-children-pretty.yaml");
- assertEquals(etalon, output);
- TypeDescription humanDescription = new TypeDescription(Human.class);
- humanDescription.putMapPropertyType("children", Human.class, Object.class);
- Yaml beanLoader = new Yaml(new Constructor(humanDescription));
- //
- Human son2 = beanLoader.loadAs(output, Human.class);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- Human father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- Set<Human> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- // check if type descriptor was correct
- assertSame(Human.class, child.getClass());
- }
-
- // check if hashCode is correct
- validateSet(children2);
- }
-
- public void testChildren2() {
- Human2 father = new Human2();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- Human2 mother = new Human2();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- Human2 son = new Human2();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- Human2 daughter = new Human2();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- HashMap<Human2, String> children = new LinkedHashMap<Human2, String>(2);
- children.put(son, "son");
- children.put(daughter, "daughter");
- father.setChildren(children);
- mother.setChildren(children);
- //
-
- Constructor constructor = new Constructor(Human2.class);
- TypeDescription humanDescription = new TypeDescription(Human2.class);
- humanDescription.putMapPropertyType("children", Human2.class, String.class);
- constructor.addTypeDescription(humanDescription);
-
- Yaml yaml = new Yaml(constructor);
- String output = yaml.dump(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-children-2.yaml");
- assertEquals(etalon, output);
- //
- Human2 son2 = (Human2) yaml.load(output);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- Human2 father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- Map<Human2, String> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- validateMapKeys(children2);
- }
-
- public void testChildren3() {
- Human3 father = new Human3();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- Human3 mother = new Human3();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- Human3 son = new Human3();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- Human3 daughter = new Human3();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- ArrayList<Human3> children = new ArrayList<Human3>();
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
-
- Constructor constructor = new Constructor(Human3.class);
- TypeDescription Human3Description = new TypeDescription(Human3.class);
- Human3Description.putListPropertyType("children", Human3.class);
- constructor.addTypeDescription(Human3Description);
-
- Yaml yaml = new Yaml(constructor);
- String output = yaml.dump(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-children-3.yaml");
- assertEquals(etalon, output);
- //
- Human3 son2 = (Human3) yaml.load(output);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- Human3 father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- List<Human3> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- // check if type descriptor was correct
- assertSame(Human3.class, child.getClass());
- }
- }
-
- /*
- * Loads same structure as created in testChildren. But root object is set
- * of children
- */
- @SuppressWarnings("unchecked")
- public void testChildrenSetAsRoot() {
- String etalon = Util.getLocalResource("recursive/with-children-as-set.yaml");
-
- Constructor constructor = new Constructor();
- TypeDescription humanDescription = new TypeDescription(Human.class);
- humanDescription.putMapPropertyType("children", Human.class, Object.class);
- constructor.addTypeDescription(humanDescription);
-
- Yaml yaml = new Yaml(constructor);
- Set<Human> children2 = (Set<Human>) yaml.load(etalon);
- assertNotNull(children2);
- assertEquals(2, children2.size());
-
- Human firstChild = children2.iterator().next();
-
- Human father2 = firstChild.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", firstChild.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), firstChild.getMother());
- assertSame(father2, firstChild.getMother().getPartner());
-
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- // check if type descriptor was correct
- assertSame(Human.class, child.getClass());
- }
-
- validateSet(children2);
- }
-
- /*
- * Loads same structure as created in testChildren. But root object is map
- * of children
- */
- @SuppressWarnings("unchecked")
- public void testChildrenMapAsRoot() {
- String etalon = Util.getLocalResource("recursive/with-children-as-map.yaml");
-
- Constructor constructor = new Constructor();
- TypeDescription Human2Description = new TypeDescription(Human2.class);
- Human2Description.putMapPropertyType("children", Human2.class, String.class);
- constructor.addTypeDescription(Human2Description);
-
- Yaml yaml = new Yaml(constructor);
- Map<Human2, String> children2 = (Map<Human2, String>) yaml.load(etalon);
- assertNotNull(children2);
- assertEquals(2, children2.size());
-
- Entry<Human2, String> firstEntry = children2.entrySet().iterator().next();
- Human2 firstChild = firstEntry.getKey();
-
- Human2 father2 = firstChild.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", firstChild.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), firstChild.getMother());
- assertSame(father2, firstChild.getMother().getPartner());
-
- assertSame(father2.getPartner().getChildren(), children2);
-
- validateMapKeys(children2);
- }
-
- /*
- * Loads same structure as created in testChildren. But root object is list
- * of children
- */
- @SuppressWarnings("unchecked")
- public void testChildrenListRoot() {
- Human3 father = new Human3();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- Human3 mother = new Human3();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- Human3 son = new Human3();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- Human3 daughter = new Human3();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- ArrayList<Human3> children = new ArrayList<Human3>();
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
-
- Constructor constructor = new Constructor();
- TypeDescription Human3Description = new TypeDescription(Human3.class);
- Human3Description.putListPropertyType("children", Human3.class);
- constructor.addTypeDescription(Human3Description);
-
- Yaml yaml = new Yaml(constructor);
- String output = yaml.dump(father.getChildren());
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-children-as-list.yaml");
- assertEquals(etalon, output);
- //
- List<Human3> children2 = (List<Human3>) yaml.load(output);
- assertNotNull(children2);
- Human3 son2 = children2.iterator().next();
- assertEquals(2, children2.size());
-
- Human3 father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- // check if type descriptor was correct
- assertSame(Human3.class, child.getClass());
- }
- }
-
- public void testBeanRing() {
- Human man1 = new Human();
- man1.setName("Man 1");
- Human man2 = new Human();
- man2.setName("Man 2");
- Human man3 = new Human();
- man3.setName("Man 3");
- man1.setBankAccountOwner(man2);
- man2.setBankAccountOwner(man3);
- man3.setBankAccountOwner(man1);
- //
- Yaml yaml = new Yaml();
- String output = yaml.dump(man1);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/beanring-3.yaml");
- assertEquals(etalon, output);
- //
- Human loadedMan1 = (Human) yaml.load(output);
- assertNotNull(loadedMan1);
- assertEquals("Man 1", loadedMan1.getName());
- Human loadedMan2 = loadedMan1.getBankAccountOwner();
- Human loadedMan3 = loadedMan2.getBankAccountOwner();
- assertSame(loadedMan1, loadedMan3.getBankAccountOwner());
- }
-
- public void qtestCollectionRing() {
- // Set<Object> set = new HashSet<Object>();
- // List<Object> list = new ArrayList<Object>();
- // Map<Object, Object> map = new HashMap<Object, Object>();
- // set.add(list);
- // list.add(map);
- // map.put("1", set);
- // //
- // try {
- // Yaml yaml = new Yaml();
- // String output = yaml.dump(set);
- // // String etalon = Util.getLocalResource("recursive/???.yaml");
- // // assertEquals(etalon, output);
- // //
- // // Set<Object> loadedSet = (Set<Object>) yaml.load(output);
- // } catch (StackOverflowError e) {
- // fail("Cannot dump recursive collections.");
- // }
- }
-
- /**
- * Checks if object was put into the set after full construction. So the
- * hashCode was calculated correctly (if it depends on internal object's
- * state).
- *
- * @param set
- */
- private void validateSet(Set<?> set) {
- for (Object object : set) {
- assertTrue(set.contains(object));
- }
- }
-
- /**
- * Checks if object was put into the map as key after full construction. So
- * the hashCode was calculated correctly (if it depends on internal object's
- * state).
- *
- * @param map
- */
- private void validateMapKeys(Map<?, ?> map) {
- for (Map.Entry<?, ?> entry : map.entrySet()) {
- assertTrue(map.containsKey(entry.getKey()));
- }
- }
-
- public void testChildrenWithoutRootTag() {
- Human father = new Human();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- Human mother = new Human();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- Human son = new Human();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- Human daughter = new Human();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- Set<Human> children = new LinkedHashSet<Human>(2);
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
- Yaml beanDumper = new Yaml();
- String output = beanDumper.dumpAsMap(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-children-no-root-tag.yaml");
- assertEquals(etalon, output);
- TypeDescription humanDescription = new TypeDescription(Human.class);
- humanDescription.putMapPropertyType("children", Human.class, Object.class);
- Yaml beanLoader = new Yaml(new Constructor(humanDescription));
- //
- Human son2 = beanLoader.loadAs(output, Human.class);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- Human father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- Set<Human> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- // check if type descriptor was correct
- assertSame(Human.class, child.getClass());
- }
-
- // check if hashCode is correct
- validateSet(children2);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class HumanTest extends TestCase {
+
+ public void testNoChildren() {
+ Human father = new Human();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ Human mother = new Human();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(father);
+ String etalon = Util.getLocalResource("recursive/no-children-1.yaml");
+ assertEquals(etalon, output);
+ //
+ Human father2 = (Human) yaml.load(output);
+ assertNotNull(father2);
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", father2.getPartner().getName());
+ assertEquals("Father", father2.getBankAccountOwner().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ }
+
+ public void testNoChildrenPretty() {
+ Human father = new Human();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ Human mother = new Human();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ DumperOptions options = new DumperOptions();
+ options.setPrettyFlow(true);
+ options.setDefaultFlowStyle(FlowStyle.FLOW);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(father);
+ String etalon = Util.getLocalResource("recursive/no-children-1-pretty.yaml");
+ assertEquals(etalon, output);
+ //
+ Human father2 = (Human) yaml.load(output);
+ assertNotNull(father2);
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", father2.getPartner().getName());
+ assertEquals("Father", father2.getBankAccountOwner().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ }
+
+ public void testChildren() {
+ Human father = new Human();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ Human mother = new Human();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ Human son = new Human();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ Human daughter = new Human();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ Set<Human> children = new LinkedHashSet<Human>(2);
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+ Yaml beanDumper = new Yaml();
+ String output = beanDumper.dumpAsMap(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-children.yaml");
+ assertEquals(etalon, output);
+ TypeDescription humanDescription = new TypeDescription(Human.class);
+ humanDescription.putMapPropertyType("children", Human.class, Object.class);
+ Yaml beanLoader = new Yaml(new Constructor(humanDescription));
+ //
+ Human son2 = beanLoader.loadAs(output, Human.class);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ Human father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ Set<Human> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ // check if type descriptor was correct
+ assertSame(Human.class, child.getClass());
+ }
+
+ // check if hashCode is correct
+ validateSet(children2);
+ }
+
+ public void testChildrenPretty() {
+ Human father = new Human();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ Human mother = new Human();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ Human son = new Human();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ Human daughter = new Human();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ Set<Human> children = new LinkedHashSet<Human>(2);
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.FLOW);
+ options.setPrettyFlow(true);
+ Yaml beanDumper = new Yaml(options);
+ String output = beanDumper.dump(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-children-pretty.yaml");
+ assertEquals(etalon, output);
+ TypeDescription humanDescription = new TypeDescription(Human.class);
+ humanDescription.putMapPropertyType("children", Human.class, Object.class);
+ Yaml beanLoader = new Yaml(new Constructor(humanDescription));
+ //
+ Human son2 = beanLoader.loadAs(output, Human.class);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ Human father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ Set<Human> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ // check if type descriptor was correct
+ assertSame(Human.class, child.getClass());
+ }
+
+ // check if hashCode is correct
+ validateSet(children2);
+ }
+
+ public void testChildren2() {
+ Human2 father = new Human2();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ Human2 mother = new Human2();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ Human2 son = new Human2();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ Human2 daughter = new Human2();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ HashMap<Human2, String> children = new LinkedHashMap<Human2, String>(2);
+ children.put(son, "son");
+ children.put(daughter, "daughter");
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+
+ Constructor constructor = new Constructor(Human2.class);
+ TypeDescription humanDescription = new TypeDescription(Human2.class);
+ humanDescription.putMapPropertyType("children", Human2.class, String.class);
+ constructor.addTypeDescription(humanDescription);
+
+ Yaml yaml = new Yaml(constructor);
+ String output = yaml.dump(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-children-2.yaml");
+ assertEquals(etalon, output);
+ //
+ Human2 son2 = (Human2) yaml.load(output);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ Human2 father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ Map<Human2, String> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ validateMapKeys(children2);
+ }
+
+ public void testChildren3() {
+ Human3 father = new Human3();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ Human3 mother = new Human3();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ Human3 son = new Human3();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ Human3 daughter = new Human3();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ ArrayList<Human3> children = new ArrayList<Human3>();
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+
+ Constructor constructor = new Constructor(Human3.class);
+ TypeDescription Human3Description = new TypeDescription(Human3.class);
+ Human3Description.putListPropertyType("children", Human3.class);
+ constructor.addTypeDescription(Human3Description);
+
+ Yaml yaml = new Yaml(constructor);
+ String output = yaml.dump(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-children-3.yaml");
+ assertEquals(etalon, output);
+ //
+ Human3 son2 = (Human3) yaml.load(output);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ Human3 father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ List<Human3> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ // check if type descriptor was correct
+ assertSame(Human3.class, child.getClass());
+ }
+ }
+
+ /*
+ * Loads same structure as created in testChildren. But root object is set
+ * of children
+ */
+ @SuppressWarnings("unchecked")
+ public void testChildrenSetAsRoot() {
+ String etalon = Util.getLocalResource("recursive/with-children-as-set.yaml");
+
+ Constructor constructor = new Constructor();
+ TypeDescription humanDescription = new TypeDescription(Human.class);
+ humanDescription.putMapPropertyType("children", Human.class, Object.class);
+ constructor.addTypeDescription(humanDescription);
+
+ Yaml yaml = new Yaml(constructor);
+ Set<Human> children2 = (Set<Human>) yaml.load(etalon);
+ assertNotNull(children2);
+ assertEquals(2, children2.size());
+
+ Human firstChild = children2.iterator().next();
+
+ Human father2 = firstChild.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", firstChild.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), firstChild.getMother());
+ assertSame(father2, firstChild.getMother().getPartner());
+
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ // check if type descriptor was correct
+ assertSame(Human.class, child.getClass());
+ }
+
+ validateSet(children2);
+ }
+
+ /*
+ * Loads same structure as created in testChildren. But root object is map
+ * of children
+ */
+ @SuppressWarnings("unchecked")
+ public void testChildrenMapAsRoot() {
+ String etalon = Util.getLocalResource("recursive/with-children-as-map.yaml");
+
+ Constructor constructor = new Constructor();
+ TypeDescription Human2Description = new TypeDescription(Human2.class);
+ Human2Description.putMapPropertyType("children", Human2.class, String.class);
+ constructor.addTypeDescription(Human2Description);
+
+ Yaml yaml = new Yaml(constructor);
+ Map<Human2, String> children2 = (Map<Human2, String>) yaml.load(etalon);
+ assertNotNull(children2);
+ assertEquals(2, children2.size());
+
+ Entry<Human2, String> firstEntry = children2.entrySet().iterator().next();
+ Human2 firstChild = firstEntry.getKey();
+
+ Human2 father2 = firstChild.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", firstChild.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), firstChild.getMother());
+ assertSame(father2, firstChild.getMother().getPartner());
+
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ validateMapKeys(children2);
+ }
+
+ /*
+ * Loads same structure as created in testChildren. But root object is list
+ * of children
+ */
+ @SuppressWarnings("unchecked")
+ public void testChildrenListRoot() {
+ Human3 father = new Human3();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ Human3 mother = new Human3();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ Human3 son = new Human3();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ Human3 daughter = new Human3();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ ArrayList<Human3> children = new ArrayList<Human3>();
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+
+ Constructor constructor = new Constructor();
+ TypeDescription Human3Description = new TypeDescription(Human3.class);
+ Human3Description.putListPropertyType("children", Human3.class);
+ constructor.addTypeDescription(Human3Description);
+
+ Yaml yaml = new Yaml(constructor);
+ String output = yaml.dump(father.getChildren());
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-children-as-list.yaml");
+ assertEquals(etalon, output);
+ //
+ List<Human3> children2 = (List<Human3>) yaml.load(output);
+ assertNotNull(children2);
+ Human3 son2 = children2.iterator().next();
+ assertEquals(2, children2.size());
+
+ Human3 father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ // check if type descriptor was correct
+ assertSame(Human3.class, child.getClass());
+ }
+ }
+
+ public void testBeanRing() {
+ Human man1 = new Human();
+ man1.setName("Man 1");
+ Human man2 = new Human();
+ man2.setName("Man 2");
+ Human man3 = new Human();
+ man3.setName("Man 3");
+ man1.setBankAccountOwner(man2);
+ man2.setBankAccountOwner(man3);
+ man3.setBankAccountOwner(man1);
+ //
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(man1);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/beanring-3.yaml");
+ assertEquals(etalon, output);
+ //
+ Human loadedMan1 = (Human) yaml.load(output);
+ assertNotNull(loadedMan1);
+ assertEquals("Man 1", loadedMan1.getName());
+ Human loadedMan2 = loadedMan1.getBankAccountOwner();
+ Human loadedMan3 = loadedMan2.getBankAccountOwner();
+ assertSame(loadedMan1, loadedMan3.getBankAccountOwner());
+ }
+
+ public void qtestCollectionRing() {
+ // Set<Object> set = new HashSet<Object>();
+ // List<Object> list = new ArrayList<Object>();
+ // Map<Object, Object> map = new HashMap<Object, Object>();
+ // set.add(list);
+ // list.add(map);
+ // map.put("1", set);
+ // //
+ // try {
+ // Yaml yaml = new Yaml();
+ // String output = yaml.dump(set);
+ // // String etalon = Util.getLocalResource("recursive/???.yaml");
+ // // assertEquals(etalon, output);
+ // //
+ // // Set<Object> loadedSet = (Set<Object>) yaml.load(output);
+ // } catch (StackOverflowError e) {
+ // fail("Cannot dump recursive collections.");
+ // }
+ }
+
+ /**
+ * Checks if object was put into the set after full construction. So the
+ * hashCode was calculated correctly (if it depends on internal object's
+ * state).
+ *
+ * @param set
+ */
+ private void validateSet(Set<?> set) {
+ for (Object object : set) {
+ assertTrue(set.contains(object));
+ }
+ }
+
+ /**
+ * Checks if object was put into the map as key after full construction. So
+ * the hashCode was calculated correctly (if it depends on internal object's
+ * state).
+ *
+ * @param map
+ */
+ private void validateMapKeys(Map<?, ?> map) {
+ for (Map.Entry<?, ?> entry : map.entrySet()) {
+ assertTrue(map.containsKey(entry.getKey()));
+ }
+ }
+
+ public void testChildrenWithoutRootTag() {
+ Human father = new Human();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ Human mother = new Human();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ Human son = new Human();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ Human daughter = new Human();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ Set<Human> children = new LinkedHashSet<Human>(2);
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+ Yaml beanDumper = new Yaml();
+ String output = beanDumper.dumpAsMap(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-children-no-root-tag.yaml");
+ assertEquals(etalon, output);
+ TypeDescription humanDescription = new TypeDescription(Human.class);
+ humanDescription.putMapPropertyType("children", Human.class, Object.class);
+ Yaml beanLoader = new Yaml(new Constructor(humanDescription));
+ //
+ Human son2 = beanLoader.loadAs(output, Human.class);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ Human father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ Set<Human> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ // check if type descriptor was correct
+ assertSame(Human.class, child.getClass());
+ }
+
+ // check if hashCode is correct
+ validateSet(children2);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/Human_WithArrayOfChildrenTest.java b/src/test/java/org/yaml/snakeyaml/recursive/Human_WithArrayOfChildrenTest.java
index 84ef6f5..2012841 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/Human_WithArrayOfChildrenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/Human_WithArrayOfChildrenTest.java
@@ -1,184 +1,184 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive;
-
-import java.util.Date;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class Human_WithArrayOfChildrenTest extends TestCase {
-
- public static class Human_WithArrayOfChildren extends AbstractHuman {
-
- private Human_WithArrayOfChildren father;
- private Human_WithArrayOfChildren mother;
- private Human_WithArrayOfChildren partner;
- private Human_WithArrayOfChildren bankAccountOwner;
- protected Human_WithArrayOfChildren[] children;
-
- public Human_WithArrayOfChildren() {
- children = new Human_WithArrayOfChildren[0];
- }
-
- public Human_WithArrayOfChildren getFather() {
- return father;
- }
-
- public void setFather(Human_WithArrayOfChildren father) {
- this.father = father;
- }
-
- public Human_WithArrayOfChildren getMother() {
- return mother;
- }
-
- public void setMother(Human_WithArrayOfChildren mother) {
- this.mother = mother;
- }
-
- public Human_WithArrayOfChildren getPartner() {
- return partner;
- }
-
- public void setPartner(Human_WithArrayOfChildren partner) {
- this.partner = partner;
- }
-
- public Human_WithArrayOfChildren getBankAccountOwner() {
- return bankAccountOwner;
- }
-
- public void setBankAccountOwner(Human_WithArrayOfChildren bankAccountOwner) {
- this.bankAccountOwner = bankAccountOwner;
- }
-
- public Human_WithArrayOfChildren[] getChildren() {
- return children;
- }
-
- public void setChildren(Human_WithArrayOfChildren[] children) {
- this.children = children;
- }
-
- }
-
- private Human_WithArrayOfChildren createSon() {
- Human_WithArrayOfChildren father = new Human_WithArrayOfChildren();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- Human_WithArrayOfChildren mother = new Human_WithArrayOfChildren();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- Human_WithArrayOfChildren son = new Human_WithArrayOfChildren();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- Human_WithArrayOfChildren daughter = new Human_WithArrayOfChildren();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- Human_WithArrayOfChildren[] children = new Human_WithArrayOfChildren[] { son, daughter };
- father.setChildren(children);
- mother.setChildren(children);
- //
- return son;
- }
-
- private void checkSon(Human_WithArrayOfChildren son) {
- assertNotNull(son);
- assertEquals("Son", son.getName());
-
- Human_WithArrayOfChildren father2 = son.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son.getMother());
- assertSame(father2, son.getMother().getPartner());
-
- Human_WithArrayOfChildren[] fathersChildren = father2.getChildren();
- assertEquals(2, fathersChildren.length);
- Human_WithArrayOfChildren[] mothersChildren = father2.getPartner().getChildren();
- assertEquals(2, mothersChildren.length);
- assertSame(mothersChildren, fathersChildren);
-
- for (Object child : fathersChildren) {
- // check if type descriptor was correct
- assertSame(Human_WithArrayOfChildren.class, child.getClass());
- }
- }
-
- public void testChildrenArray() {
- Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
- TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
- Human_WithArrayOfChildren.class);
- HumanWithChildrenArrayDescription.putListPropertyType("children",
- Human_WithArrayOfChildren.class);
- constructor.addTypeDescription(HumanWithChildrenArrayDescription);
- Human_WithArrayOfChildren son = createSon();
- Yaml yaml = new Yaml(constructor);
- String output = yaml.dump(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-childrenArray.yaml");
- assertEquals(etalon, output);
- //
- Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(output);
- checkSon(son2);
- }
-
- public void testDumpChildrenArrayWithoutRootTag() {
- Yaml yaml = new Yaml();
- Human_WithArrayOfChildren son = createSon();
- String output = yaml.dumpAsMap(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/with-childrenArray-no-root-tag.yaml");
- assertEquals(etalon, output);
- }
-
- public void testParseChildrenArrayWithoutRootTag() {
- Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
- TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
- Human_WithArrayOfChildren.class);
- HumanWithChildrenArrayDescription.putListPropertyType("children",
- Human_WithArrayOfChildren.class);
- constructor.addTypeDescription(HumanWithChildrenArrayDescription);
- Yaml yaml = new Yaml(constructor);
- String doc = Util.getLocalResource("recursive/with-childrenArray-no-root-tag.yaml");
- Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(doc);
- checkSon(son2);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive;
+
+import java.util.Date;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class Human_WithArrayOfChildrenTest extends TestCase {
+
+ public static class Human_WithArrayOfChildren extends AbstractHuman {
+
+ private Human_WithArrayOfChildren father;
+ private Human_WithArrayOfChildren mother;
+ private Human_WithArrayOfChildren partner;
+ private Human_WithArrayOfChildren bankAccountOwner;
+ protected Human_WithArrayOfChildren[] children;
+
+ public Human_WithArrayOfChildren() {
+ children = new Human_WithArrayOfChildren[0];
+ }
+
+ public Human_WithArrayOfChildren getFather() {
+ return father;
+ }
+
+ public void setFather(Human_WithArrayOfChildren father) {
+ this.father = father;
+ }
+
+ public Human_WithArrayOfChildren getMother() {
+ return mother;
+ }
+
+ public void setMother(Human_WithArrayOfChildren mother) {
+ this.mother = mother;
+ }
+
+ public Human_WithArrayOfChildren getPartner() {
+ return partner;
+ }
+
+ public void setPartner(Human_WithArrayOfChildren partner) {
+ this.partner = partner;
+ }
+
+ public Human_WithArrayOfChildren getBankAccountOwner() {
+ return bankAccountOwner;
+ }
+
+ public void setBankAccountOwner(Human_WithArrayOfChildren bankAccountOwner) {
+ this.bankAccountOwner = bankAccountOwner;
+ }
+
+ public Human_WithArrayOfChildren[] getChildren() {
+ return children;
+ }
+
+ public void setChildren(Human_WithArrayOfChildren[] children) {
+ this.children = children;
+ }
+
+ }
+
+ private Human_WithArrayOfChildren createSon() {
+ Human_WithArrayOfChildren father = new Human_WithArrayOfChildren();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ Human_WithArrayOfChildren mother = new Human_WithArrayOfChildren();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ Human_WithArrayOfChildren son = new Human_WithArrayOfChildren();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ Human_WithArrayOfChildren daughter = new Human_WithArrayOfChildren();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ Human_WithArrayOfChildren[] children = new Human_WithArrayOfChildren[] { son, daughter };
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+ return son;
+ }
+
+ private void checkSon(Human_WithArrayOfChildren son) {
+ assertNotNull(son);
+ assertEquals("Son", son.getName());
+
+ Human_WithArrayOfChildren father2 = son.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son.getMother());
+ assertSame(father2, son.getMother().getPartner());
+
+ Human_WithArrayOfChildren[] fathersChildren = father2.getChildren();
+ assertEquals(2, fathersChildren.length);
+ Human_WithArrayOfChildren[] mothersChildren = father2.getPartner().getChildren();
+ assertEquals(2, mothersChildren.length);
+ assertSame(mothersChildren, fathersChildren);
+
+ for (Object child : fathersChildren) {
+ // check if type descriptor was correct
+ assertSame(Human_WithArrayOfChildren.class, child.getClass());
+ }
+ }
+
+ public void testChildrenArray() {
+ Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
+ TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
+ Human_WithArrayOfChildren.class);
+ HumanWithChildrenArrayDescription.putListPropertyType("children",
+ Human_WithArrayOfChildren.class);
+ constructor.addTypeDescription(HumanWithChildrenArrayDescription);
+ Human_WithArrayOfChildren son = createSon();
+ Yaml yaml = new Yaml(constructor);
+ String output = yaml.dump(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-childrenArray.yaml");
+ assertEquals(etalon, output);
+ //
+ Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(output);
+ checkSon(son2);
+ }
+
+ public void testDumpChildrenArrayWithoutRootTag() {
+ Yaml yaml = new Yaml();
+ Human_WithArrayOfChildren son = createSon();
+ String output = yaml.dumpAsMap(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/with-childrenArray-no-root-tag.yaml");
+ assertEquals(etalon, output);
+ }
+
+ public void testParseChildrenArrayWithoutRootTag() {
+ Constructor constructor = new Constructor(Human_WithArrayOfChildren.class);
+ TypeDescription HumanWithChildrenArrayDescription = new TypeDescription(
+ Human_WithArrayOfChildren.class);
+ HumanWithChildrenArrayDescription.putListPropertyType("children",
+ Human_WithArrayOfChildren.class);
+ constructor.addTypeDescription(HumanWithChildrenArrayDescription);
+ Yaml yaml = new Yaml(constructor);
+ String doc = Util.getLocalResource("recursive/with-childrenArray-no-root-tag.yaml");
+ Human_WithArrayOfChildren son2 = (Human_WithArrayOfChildren) yaml.load(doc);
+ checkSon(son2);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/generics/AbstractHumanGen.java b/src/test/java/org/yaml/snakeyaml/recursive/generics/AbstractHumanGen.java
index 3bdba29..7dd24bd 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/generics/AbstractHumanGen.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/generics/AbstractHumanGen.java
@@ -1,95 +1,95 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive.generics;
-
-import java.util.Date;
-
-public abstract class AbstractHumanGen<T, K extends AbstractHumanGen<T, ?>> {
- private String name;
- private Date birthday;
- private String birthPlace;
- private K father;
- private K mother;
- private K partner;
- private K bankAccountOwner;
- protected T children;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Date getBirthday() {
- return birthday;
- }
-
- public void setBirthday(Date birthday) {
- this.birthday = birthday;
- }
-
- public String getBirthPlace() {
- return birthPlace;
- }
-
- public K getFather() {
- return father;
- }
-
- public void setFather(K father) {
- this.father = father;
- }
-
- public K getMother() {
- return mother;
- }
-
- public void setMother(K mother) {
- this.mother = mother;
- }
-
- public void setBirthPlace(String birthPlace) {
- this.birthPlace = birthPlace;
- }
-
- public T getChildren() {
- return children;
- }
-
- public void setChildren(T children) {
- this.children = children;
- }
-
- public K getPartner() {
- return partner;
- }
-
- public void setPartner(K partner) {
- this.partner = partner;
- }
-
- public K getBankAccountOwner() {
- return bankAccountOwner;
- }
-
- public void setBankAccountOwner(K bankAccountOwner) {
- this.bankAccountOwner = bankAccountOwner;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive.generics;
+
+import java.util.Date;
+
+public abstract class AbstractHumanGen<T, K extends AbstractHumanGen<T, ?>> {
+ private String name;
+ private Date birthday;
+ private String birthPlace;
+ private K father;
+ private K mother;
+ private K partner;
+ private K bankAccountOwner;
+ protected T children;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Date getBirthday() {
+ return birthday;
+ }
+
+ public void setBirthday(Date birthday) {
+ this.birthday = birthday;
+ }
+
+ public String getBirthPlace() {
+ return birthPlace;
+ }
+
+ public K getFather() {
+ return father;
+ }
+
+ public void setFather(K father) {
+ this.father = father;
+ }
+
+ public K getMother() {
+ return mother;
+ }
+
+ public void setMother(K mother) {
+ this.mother = mother;
+ }
+
+ public void setBirthPlace(String birthPlace) {
+ this.birthPlace = birthPlace;
+ }
+
+ public T getChildren() {
+ return children;
+ }
+
+ public void setChildren(T children) {
+ this.children = children;
+ }
+
+ public K getPartner() {
+ return partner;
+ }
+
+ public void setPartner(K partner) {
+ this.partner = partner;
+ }
+
+ public K getBankAccountOwner() {
+ return bankAccountOwner;
+ }
+
+ public void setBankAccountOwner(K bankAccountOwner) {
+ this.bankAccountOwner = bankAccountOwner;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen.java b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen.java
index d21fe0d..01b6c6d 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen.java
@@ -1,26 +1,26 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive.generics;
-
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-public class HumanGen extends AbstractHumanGen<Set<HumanGen>, HumanGen> {
- public HumanGen() {
- children = new LinkedHashSet<HumanGen>();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive.generics;
+
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+public class HumanGen extends AbstractHumanGen<Set<HumanGen>, HumanGen> {
+ public HumanGen() {
+ children = new LinkedHashSet<HumanGen>();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen2.java b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen2.java
index 3aa85ce..3e22c3a 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen2.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen2.java
@@ -1,27 +1,27 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive.generics;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class HumanGen2 extends AbstractHumanGen<Map<HumanGen2, String>, HumanGen2> {
-
- public HumanGen2() {
- children = new HashMap<HumanGen2, String>();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive.generics;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class HumanGen2 extends AbstractHumanGen<Map<HumanGen2, String>, HumanGen2> {
+
+ public HumanGen2() {
+ children = new HashMap<HumanGen2, String>();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen3.java b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen3.java
index 97bce03..9f80744 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen3.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGen3.java
@@ -1,27 +1,27 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive.generics;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class HumanGen3 extends AbstractHumanGen<List<HumanGen3>, HumanGen3> {
-
- public HumanGen3() {
- children = new ArrayList<HumanGen3>();
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive.generics;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class HumanGen3 extends AbstractHumanGen<List<HumanGen3>, HumanGen3> {
+
+ public HumanGen3() {
+ children = new ArrayList<HumanGen3>();
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGenericsTest.java b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGenericsTest.java
index eee7910..a999683 100644
--- a/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGenericsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/recursive/generics/HumanGenericsTest.java
@@ -1,500 +1,500 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.recursive.generics;
-
-import java.beans.IntrospectionException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.generics.GenericsBugDetector;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class HumanGenericsTest extends TestCase {
-
- public void testNoChildren() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- HumanGen father = new HumanGen();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- HumanGen mother = new HumanGen();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- Yaml yaml = new Yaml();
- String output = yaml.dump(father);
- String etalon = Util.getLocalResource("recursive/generics/no-children-1.yaml");
- assertEquals(etalon, output);
- //
- HumanGen father2 = (HumanGen) yaml.load(output);
- assertNotNull(father2);
- assertEquals("Father", father2.getName());
- assertEquals("Mother", father2.getPartner().getName());
- assertEquals("Father", father2.getBankAccountOwner().getName());
- assertSame(father2, father2.getBankAccountOwner());
- }
-
- /**
- * the YAML document should contain no global tags
- *
- * @throws IntrospectionException
- */
- public void testNoChildren2() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- HumanGen father = new HumanGen();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- HumanGen mother = new HumanGen();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- Yaml yaml = new Yaml();
- String output = yaml.dumpAsMap(father);
- String etalon = Util.getLocalResource("recursive/generics/no-children-2.yaml");
- assertEquals(etalon, output);
- //
- Yaml loader = new Yaml();
- HumanGen father2 = (HumanGen) loader.loadAs(etalon, HumanGen.class);
- assertNotNull(father2);
- assertEquals("Father", father2.getName());
- assertEquals("Mother", father2.getPartner().getName());
- assertEquals("Father", father2.getBankAccountOwner().getName());
- assertSame(father2, father2.getBankAccountOwner());
- }
-
- public void testChildren() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- HumanGen father = new HumanGen();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- HumanGen mother = new HumanGen();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- HumanGen son = new HumanGen();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- HumanGen daughter = new HumanGen();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- Set<HumanGen> children = new LinkedHashSet<HumanGen>(2);
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
-
- Constructor constructor = new Constructor();
- TypeDescription humanDescription = new TypeDescription(HumanGen.class);
- humanDescription.putMapPropertyType("children", HumanGen.class, Object.class);
- constructor.addTypeDescription(humanDescription);
-
- Yaml yaml = new Yaml(constructor);
- String output = yaml.dump(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/generics/with-children.yaml");
- assertEquals(etalon, output);
- //
- HumanGen son2 = (HumanGen) yaml.load(output);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- HumanGen father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- Set<HumanGen> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- assertSame(HumanGen.class, child.getClass()); // check if type
- // descriptor was correct
- }
- }
-
- public void testChildren2() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- HumanGen2 father = new HumanGen2();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- HumanGen2 mother = new HumanGen2();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- HumanGen2 son = new HumanGen2();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- HumanGen2 daughter = new HumanGen2();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- HashMap<HumanGen2, String> children = new LinkedHashMap<HumanGen2, String>(2);
- children.put(son, "son");
- children.put(daughter, "daughter");
- father.setChildren(children);
- mother.setChildren(children);
- //
- Representer representer = new Representer();
- representer.addClassTag(HumanGen2.class, Tag.MAP);
- Yaml yaml = new Yaml(representer);
- String output = yaml.dump(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/generics/with-children-2.yaml");
- assertEquals(etalon, output);
- // load
- TypeDescription humanDescription = new TypeDescription(HumanGen2.class);
- humanDescription.putMapPropertyType("children", HumanGen2.class, String.class);
- Yaml beanLoader = new Yaml(new Constructor(humanDescription));
- //
- HumanGen2 son2 = beanLoader.loadAs(output, HumanGen2.class);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- HumanGen2 father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- Map<HumanGen2, String> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- }
-
- public void testChildren3() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- HumanGen3 father = new HumanGen3();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- HumanGen3 mother = new HumanGen3();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- HumanGen3 son = new HumanGen3();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- HumanGen3 daughter = new HumanGen3();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- ArrayList<HumanGen3> children = new ArrayList<HumanGen3>();
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
-
- Constructor constructor = new Constructor();
- TypeDescription Human3Description = new TypeDescription(HumanGen3.class);
- Human3Description.putListPropertyType("children", HumanGen3.class);
- constructor.addTypeDescription(Human3Description);
-
- Yaml yaml = new Yaml(constructor);
- String output = yaml.dump(son);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/generics/with-children-3.yaml");
- assertEquals(etalon, output);
- //
- HumanGen3 son2 = (HumanGen3) yaml.load(output);
- assertNotNull(son2);
- assertEquals("Son", son.getName());
-
- HumanGen3 father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- List<HumanGen3> children2 = father2.getChildren();
- assertEquals(2, children2.size());
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- assertSame(HumanGen3.class, child.getClass()); // check if type
- // descriptor was
- // correct
- }
- }
-
- /*
- * Loads same structure as created in testChildren. But root object is set
- * of children
- */
- @SuppressWarnings("unchecked")
- public void testChildrenSetAsRoot() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- String etalon = Util.getLocalResource("recursive/generics/with-children-as-set.yaml");
-
- Constructor constructor = new Constructor();
- TypeDescription humanDescription = new TypeDescription(HumanGen.class);
- humanDescription.putMapPropertyType("children", HumanGen.class, Object.class);
- constructor.addTypeDescription(humanDescription);
-
- Yaml yaml = new Yaml(constructor);
- Set<HumanGen> children2 = (Set<HumanGen>) yaml.load(etalon);
- assertNotNull(children2);
- assertEquals(2, children2.size());
-
- HumanGen firstChild = children2.iterator().next();
-
- HumanGen father2 = firstChild.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", firstChild.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), firstChild.getMother());
- assertSame(father2, firstChild.getMother().getPartner());
-
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- assertSame(HumanGen.class, child.getClass()); // check if type
- // descriptor was correct
- }
- }
-
- /*
- * Loads same structure as created in testChildren. But root object is map
- * of children
- */
- @SuppressWarnings("unchecked")
- public void testChildrenMapAsRoot() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- String etalon = Util.getLocalResource("recursive/generics/with-children-as-map.yaml");
-
- Constructor constructor = new Constructor();
- TypeDescription Human2Description = new TypeDescription(HumanGen2.class);
- Human2Description.putMapPropertyType("children", HumanGen2.class, String.class);
- constructor.addTypeDescription(Human2Description);
-
- Yaml yaml = new Yaml(constructor);
- Map<HumanGen2, String> children2 = (Map<HumanGen2, String>) yaml.load(etalon);
- assertNotNull(children2);
- assertEquals(2, children2.size());
-
- Entry<HumanGen2, String> firstEntry = children2.entrySet().iterator().next();
- HumanGen2 firstChild = firstEntry.getKey();
-
- HumanGen2 father2 = firstChild.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", firstChild.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), firstChild.getMother());
- assertSame(father2, firstChild.getMother().getPartner());
-
- assertSame(father2.getPartner().getChildren(), children2);
- }
-
- /*
- * Loads same structure as created in testChildren. But root object is list
- * of children
- */
- @SuppressWarnings("unchecked")
- public void testChildrenListRoot() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- HumanGen3 father = new HumanGen3();
- father.setName("Father");
- father.setBirthday(new Date(1000000000));
- father.setBirthPlace("Leningrad");
- father.setBankAccountOwner(father);
- //
- HumanGen3 mother = new HumanGen3();
- mother.setName("Mother");
- mother.setBirthday(new Date(100000000000L));
- mother.setBirthPlace("Saint-Petersburg");
- father.setPartner(mother);
- mother.setPartner(father);
- mother.setBankAccountOwner(father);
- //
- HumanGen3 son = new HumanGen3();
- son.setName("Son");
- son.setBirthday(new Date(310000000000L));
- son.setBirthPlace("Munich");
- son.setBankAccountOwner(father);
- son.setFather(father);
- son.setMother(mother);
- //
- HumanGen3 daughter = new HumanGen3();
- daughter.setName("Daughter");
- daughter.setBirthday(new Date(420000000000L));
- daughter.setBirthPlace("New York");
- daughter.setBankAccountOwner(father);
- daughter.setFather(father);
- daughter.setMother(mother);
- //
- ArrayList<HumanGen3> children = new ArrayList<HumanGen3>();
- children.add(son);
- children.add(daughter);
- father.setChildren(children);
- mother.setChildren(children);
- //
-
- Constructor constructor = new Constructor();
- TypeDescription Human3Description = new TypeDescription(HumanGen3.class);
- Human3Description.putListPropertyType("children", HumanGen3.class);
- constructor.addTypeDescription(Human3Description);
-
- Yaml yaml = new Yaml(constructor);
- String output = yaml.dump(father.getChildren());
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/generics/with-children-as-list.yaml");
- assertEquals(etalon, output);
- //
- List<HumanGen3> children2 = (List<HumanGen3>) yaml.load(output);
- assertNotNull(children2);
- HumanGen3 son2 = children2.iterator().next();
- assertEquals(2, children2.size());
-
- HumanGen3 father2 = son2.getFather();
- assertEquals("Father", father2.getName());
- assertEquals("Mother", son2.getMother().getName());
- assertSame(father2, father2.getBankAccountOwner());
- assertSame(father2.getPartner(), son2.getMother());
- assertSame(father2, son2.getMother().getPartner());
-
- assertSame(father2.getPartner().getChildren(), children2);
-
- for (Object child : children2) {
- assertSame(HumanGen3.class, child.getClass()); // check if type
- // descriptor was
- // correct
- }
- }
-
- public void testBeanRing() throws IOException, IntrospectionException {
- if (!GenericsBugDetector.isProperIntrospection()) {
- return;
- }
- HumanGen man1 = new HumanGen();
- man1.setName("Man 1");
- HumanGen man2 = new HumanGen();
- man2.setName("Man 2");
- HumanGen man3 = new HumanGen();
- man3.setName("Man 3");
- man1.setBankAccountOwner(man2);
- man2.setBankAccountOwner(man3);
- man3.setBankAccountOwner(man1);
- //
- Yaml yaml = new Yaml();
- String output = yaml.dump(man1);
- // System.out.println(output);
- String etalon = Util.getLocalResource("recursive/generics/beanring-3.yaml");
- assertEquals(etalon, output);
- //
- HumanGen loadedMan1 = (HumanGen) yaml.load(output);
- assertNotNull(loadedMan1);
- assertEquals("Man 1", loadedMan1.getName());
- HumanGen loadedMan2 = loadedMan1.getBankAccountOwner();
- HumanGen loadedMan3 = loadedMan2.getBankAccountOwner();
- assertSame(loadedMan1, loadedMan3.getBankAccountOwner());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.recursive.generics;
+
+import java.beans.IntrospectionException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.generics.GenericsBugDetector;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class HumanGenericsTest extends TestCase {
+
+ public void testNoChildren() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ HumanGen father = new HumanGen();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ HumanGen mother = new HumanGen();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(father);
+ String etalon = Util.getLocalResource("recursive/generics/no-children-1.yaml");
+ assertEquals(etalon, output);
+ //
+ HumanGen father2 = (HumanGen) yaml.load(output);
+ assertNotNull(father2);
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", father2.getPartner().getName());
+ assertEquals("Father", father2.getBankAccountOwner().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ }
+
+ /**
+ * the YAML document should contain no global tags
+ *
+ * @throws IntrospectionException
+ */
+ public void testNoChildren2() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ HumanGen father = new HumanGen();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ HumanGen mother = new HumanGen();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ Yaml yaml = new Yaml();
+ String output = yaml.dumpAsMap(father);
+ String etalon = Util.getLocalResource("recursive/generics/no-children-2.yaml");
+ assertEquals(etalon, output);
+ //
+ Yaml loader = new Yaml();
+ HumanGen father2 = (HumanGen) loader.loadAs(etalon, HumanGen.class);
+ assertNotNull(father2);
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", father2.getPartner().getName());
+ assertEquals("Father", father2.getBankAccountOwner().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ }
+
+ public void testChildren() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ HumanGen father = new HumanGen();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ HumanGen mother = new HumanGen();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ HumanGen son = new HumanGen();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ HumanGen daughter = new HumanGen();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ Set<HumanGen> children = new LinkedHashSet<HumanGen>(2);
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+
+ Constructor constructor = new Constructor();
+ TypeDescription humanDescription = new TypeDescription(HumanGen.class);
+ humanDescription.putMapPropertyType("children", HumanGen.class, Object.class);
+ constructor.addTypeDescription(humanDescription);
+
+ Yaml yaml = new Yaml(constructor);
+ String output = yaml.dump(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/generics/with-children.yaml");
+ assertEquals(etalon, output);
+ //
+ HumanGen son2 = (HumanGen) yaml.load(output);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ HumanGen father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ Set<HumanGen> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ assertSame(HumanGen.class, child.getClass()); // check if type
+ // descriptor was correct
+ }
+ }
+
+ public void testChildren2() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ HumanGen2 father = new HumanGen2();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ HumanGen2 mother = new HumanGen2();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ HumanGen2 son = new HumanGen2();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ HumanGen2 daughter = new HumanGen2();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ HashMap<HumanGen2, String> children = new LinkedHashMap<HumanGen2, String>(2);
+ children.put(son, "son");
+ children.put(daughter, "daughter");
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+ Representer representer = new Representer();
+ representer.addClassTag(HumanGen2.class, Tag.MAP);
+ Yaml yaml = new Yaml(representer);
+ String output = yaml.dump(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/generics/with-children-2.yaml");
+ assertEquals(etalon, output);
+ // load
+ TypeDescription humanDescription = new TypeDescription(HumanGen2.class);
+ humanDescription.putMapPropertyType("children", HumanGen2.class, String.class);
+ Yaml beanLoader = new Yaml(new Constructor(humanDescription));
+ //
+ HumanGen2 son2 = beanLoader.loadAs(output, HumanGen2.class);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ HumanGen2 father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ Map<HumanGen2, String> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ }
+
+ public void testChildren3() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ HumanGen3 father = new HumanGen3();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ HumanGen3 mother = new HumanGen3();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ HumanGen3 son = new HumanGen3();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ HumanGen3 daughter = new HumanGen3();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ ArrayList<HumanGen3> children = new ArrayList<HumanGen3>();
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+
+ Constructor constructor = new Constructor();
+ TypeDescription Human3Description = new TypeDescription(HumanGen3.class);
+ Human3Description.putListPropertyType("children", HumanGen3.class);
+ constructor.addTypeDescription(Human3Description);
+
+ Yaml yaml = new Yaml(constructor);
+ String output = yaml.dump(son);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/generics/with-children-3.yaml");
+ assertEquals(etalon, output);
+ //
+ HumanGen3 son2 = (HumanGen3) yaml.load(output);
+ assertNotNull(son2);
+ assertEquals("Son", son.getName());
+
+ HumanGen3 father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ List<HumanGen3> children2 = father2.getChildren();
+ assertEquals(2, children2.size());
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ assertSame(HumanGen3.class, child.getClass()); // check if type
+ // descriptor was
+ // correct
+ }
+ }
+
+ /*
+ * Loads same structure as created in testChildren. But root object is set
+ * of children
+ */
+ @SuppressWarnings("unchecked")
+ public void testChildrenSetAsRoot() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ String etalon = Util.getLocalResource("recursive/generics/with-children-as-set.yaml");
+
+ Constructor constructor = new Constructor();
+ TypeDescription humanDescription = new TypeDescription(HumanGen.class);
+ humanDescription.putMapPropertyType("children", HumanGen.class, Object.class);
+ constructor.addTypeDescription(humanDescription);
+
+ Yaml yaml = new Yaml(constructor);
+ Set<HumanGen> children2 = (Set<HumanGen>) yaml.load(etalon);
+ assertNotNull(children2);
+ assertEquals(2, children2.size());
+
+ HumanGen firstChild = children2.iterator().next();
+
+ HumanGen father2 = firstChild.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", firstChild.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), firstChild.getMother());
+ assertSame(father2, firstChild.getMother().getPartner());
+
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ assertSame(HumanGen.class, child.getClass()); // check if type
+ // descriptor was correct
+ }
+ }
+
+ /*
+ * Loads same structure as created in testChildren. But root object is map
+ * of children
+ */
+ @SuppressWarnings("unchecked")
+ public void testChildrenMapAsRoot() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ String etalon = Util.getLocalResource("recursive/generics/with-children-as-map.yaml");
+
+ Constructor constructor = new Constructor();
+ TypeDescription Human2Description = new TypeDescription(HumanGen2.class);
+ Human2Description.putMapPropertyType("children", HumanGen2.class, String.class);
+ constructor.addTypeDescription(Human2Description);
+
+ Yaml yaml = new Yaml(constructor);
+ Map<HumanGen2, String> children2 = (Map<HumanGen2, String>) yaml.load(etalon);
+ assertNotNull(children2);
+ assertEquals(2, children2.size());
+
+ Entry<HumanGen2, String> firstEntry = children2.entrySet().iterator().next();
+ HumanGen2 firstChild = firstEntry.getKey();
+
+ HumanGen2 father2 = firstChild.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", firstChild.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), firstChild.getMother());
+ assertSame(father2, firstChild.getMother().getPartner());
+
+ assertSame(father2.getPartner().getChildren(), children2);
+ }
+
+ /*
+ * Loads same structure as created in testChildren. But root object is list
+ * of children
+ */
+ @SuppressWarnings("unchecked")
+ public void testChildrenListRoot() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ HumanGen3 father = new HumanGen3();
+ father.setName("Father");
+ father.setBirthday(new Date(1000000000));
+ father.setBirthPlace("Leningrad");
+ father.setBankAccountOwner(father);
+ //
+ HumanGen3 mother = new HumanGen3();
+ mother.setName("Mother");
+ mother.setBirthday(new Date(100000000000L));
+ mother.setBirthPlace("Saint-Petersburg");
+ father.setPartner(mother);
+ mother.setPartner(father);
+ mother.setBankAccountOwner(father);
+ //
+ HumanGen3 son = new HumanGen3();
+ son.setName("Son");
+ son.setBirthday(new Date(310000000000L));
+ son.setBirthPlace("Munich");
+ son.setBankAccountOwner(father);
+ son.setFather(father);
+ son.setMother(mother);
+ //
+ HumanGen3 daughter = new HumanGen3();
+ daughter.setName("Daughter");
+ daughter.setBirthday(new Date(420000000000L));
+ daughter.setBirthPlace("New York");
+ daughter.setBankAccountOwner(father);
+ daughter.setFather(father);
+ daughter.setMother(mother);
+ //
+ ArrayList<HumanGen3> children = new ArrayList<HumanGen3>();
+ children.add(son);
+ children.add(daughter);
+ father.setChildren(children);
+ mother.setChildren(children);
+ //
+
+ Constructor constructor = new Constructor();
+ TypeDescription Human3Description = new TypeDescription(HumanGen3.class);
+ Human3Description.putListPropertyType("children", HumanGen3.class);
+ constructor.addTypeDescription(Human3Description);
+
+ Yaml yaml = new Yaml(constructor);
+ String output = yaml.dump(father.getChildren());
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/generics/with-children-as-list.yaml");
+ assertEquals(etalon, output);
+ //
+ List<HumanGen3> children2 = (List<HumanGen3>) yaml.load(output);
+ assertNotNull(children2);
+ HumanGen3 son2 = children2.iterator().next();
+ assertEquals(2, children2.size());
+
+ HumanGen3 father2 = son2.getFather();
+ assertEquals("Father", father2.getName());
+ assertEquals("Mother", son2.getMother().getName());
+ assertSame(father2, father2.getBankAccountOwner());
+ assertSame(father2.getPartner(), son2.getMother());
+ assertSame(father2, son2.getMother().getPartner());
+
+ assertSame(father2.getPartner().getChildren(), children2);
+
+ for (Object child : children2) {
+ assertSame(HumanGen3.class, child.getClass()); // check if type
+ // descriptor was
+ // correct
+ }
+ }
+
+ public void testBeanRing() throws IOException, IntrospectionException {
+ if (!GenericsBugDetector.isProperIntrospection()) {
+ return;
+ }
+ HumanGen man1 = new HumanGen();
+ man1.setName("Man 1");
+ HumanGen man2 = new HumanGen();
+ man2.setName("Man 2");
+ HumanGen man3 = new HumanGen();
+ man3.setName("Man 3");
+ man1.setBankAccountOwner(man2);
+ man2.setBankAccountOwner(man3);
+ man3.setBankAccountOwner(man1);
+ //
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(man1);
+ // System.out.println(output);
+ String etalon = Util.getLocalResource("recursive/generics/beanring-3.yaml");
+ assertEquals(etalon, output);
+ //
+ HumanGen loadedMan1 = (HumanGen) yaml.load(output);
+ assertNotNull(loadedMan1);
+ assertEquals("Man 1", loadedMan1.getName());
+ HumanGen loadedMan2 = loadedMan1.getBankAccountOwner();
+ HumanGen loadedMan3 = loadedMan2.getBankAccountOwner();
+ assertSame(loadedMan1, loadedMan3.getBankAccountOwner());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/representer/DumpStackTraceTest.java b/src/test/java/org/yaml/snakeyaml/representer/DumpStackTraceTest.java
index d730e12..ef8ba2a 100644
--- a/src/test/java/org/yaml/snakeyaml/representer/DumpStackTraceTest.java
+++ b/src/test/java/org/yaml/snakeyaml/representer/DumpStackTraceTest.java
@@ -1,66 +1,66 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-public class DumpStackTraceTest extends TestCase {
-
- public void testJavaStackTrace() {
- Yaml yaml = new Yaml();
- String input = Util.getLocalResource("representer/stacktrace1.txt");
- String result = yaml.dump(input);
- // System.out.println(result);
- assertEquals(result, yaml.dump(yaml.load(result)));
- }
-
- public void testJavaStackTraceWithNoSpecialCharacters() {
- DumperOptions options = new DumperOptions();
- options.setWidth(50);
- Yaml yaml = new Yaml(options);
- String input = Util.getLocalResource("representer/stacktrace2.txt");
- assertEquals(-1, input.indexOf(':'));
- assertEquals(-1, input.indexOf('\t'));
- String result = yaml.dump(input);
- // System.out.println(result);
- assertEquals(result, yaml.dump(yaml.load(result)));
- }
-
- public void testJavaStackTraceWithTabs() {
- Yaml yaml = new Yaml();
- String input = Util.getLocalResource("representer/stacktrace3.txt");
- assertEquals(-1, input.indexOf(':'));
- assertTrue("Tabs must be used.", input.indexOf('\t') > 0);
- String result = yaml.dump(input);
- // System.out.println(result);
- assertEquals(result, yaml.dump(yaml.load(result)));
- }
-
- public void testJavaStackTraceWithoutTabs() {
- Yaml yaml = new Yaml();
- String input = Util.getLocalResource("representer/stacktrace1.txt");
- String result = (String) yaml.dump(input);
- // System.out.println(result);
- String etalon = Util.getLocalResource("representer/stacktrace1.yaml");
- // http://code.google.com/p/snakeyaml/issues/detail?id=66
- assertEquals(etalon, result);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+public class DumpStackTraceTest extends TestCase {
+
+ public void testJavaStackTrace() {
+ Yaml yaml = new Yaml();
+ String input = Util.getLocalResource("representer/stacktrace1.txt");
+ String result = yaml.dump(input);
+ // System.out.println(result);
+ assertEquals(result, yaml.dump(yaml.load(result)));
+ }
+
+ public void testJavaStackTraceWithNoSpecialCharacters() {
+ DumperOptions options = new DumperOptions();
+ options.setWidth(50);
+ Yaml yaml = new Yaml(options);
+ String input = Util.getLocalResource("representer/stacktrace2.txt");
+ assertEquals(-1, input.indexOf(':'));
+ assertEquals(-1, input.indexOf('\t'));
+ String result = yaml.dump(input);
+ // System.out.println(result);
+ assertEquals(result, yaml.dump(yaml.load(result)));
+ }
+
+ public void testJavaStackTraceWithTabs() {
+ Yaml yaml = new Yaml();
+ String input = Util.getLocalResource("representer/stacktrace3.txt");
+ assertEquals(-1, input.indexOf(':'));
+ assertTrue("Tabs must be used.", input.indexOf('\t') > 0);
+ String result = yaml.dump(input);
+ // System.out.println(result);
+ assertEquals(result, yaml.dump(yaml.load(result)));
+ }
+
+ public void testJavaStackTraceWithoutTabs() {
+ Yaml yaml = new Yaml();
+ String input = Util.getLocalResource("representer/stacktrace1.txt");
+ String result = (String) yaml.dump(input);
+ // System.out.println(result);
+ String etalon = Util.getLocalResource("representer/stacktrace1.yaml");
+ // http://code.google.com/p/snakeyaml/issues/detail?id=66
+ assertEquals(etalon, result);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/representer/FilterPropertyToDumpTest.java b/src/test/java/org/yaml/snakeyaml/representer/FilterPropertyToDumpTest.java
index f898143..e2f2736 100644
--- a/src/test/java/org/yaml/snakeyaml/representer/FilterPropertyToDumpTest.java
+++ b/src/test/java/org/yaml/snakeyaml/representer/FilterPropertyToDumpTest.java
@@ -1,108 +1,108 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import java.beans.IntrospectionException;
-import java.util.Set;
-import java.util.TreeSet;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.introspector.Property;
-
-public class FilterPropertyToDumpTest extends TestCase {
-
- public void testFilterPropertyInJavaBeanDumper() {
- BeanToRemoveProperty bean = new BeanToRemoveProperty();
- bean.setNumber(24);
- bean.setId("ID124");
- Yaml d = new Yaml();
- String dump = d.dumpAsMap(bean);
- // System.out.println(dump);
- assertEquals("id: ID124\nnumber: 24\n", dump);
- }
-
- public void testFilterPropertyInYaml() {
- BeanToRemoveProperty bean = new BeanToRemoveProperty();
- bean.setNumber(25);
- bean.setId("ID125");
- Yaml yaml = new Yaml(new MyRepresenter());
- String dump = yaml.dumpAsMap(bean);
- // System.out.println(dump);
- assertEquals("number: 25\n", dump);
- }
-
- public void testDoNotFilterPropertyIncludeReadOnly() {
- BeanToRemoveProperty bean = new BeanToRemoveProperty();
- bean.setNumber(26);
- bean.setId("ID126");
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- String dump = yaml.dump(bean);
- // System.out.println(dump);
- assertEquals(
- "!!org.yaml.snakeyaml.representer.FilterPropertyToDumpTest$BeanToRemoveProperty {id: ID126,\n number: 26, something: true}\n",
- dump);
- }
-
- public class BeanToRemoveProperty {
- private int number;
- private String id;
-
- public boolean isSomething() {
- return true;
- }
-
- public int getNumber() {
- return number;
- }
-
- public void setNumber(int number) {
- this.number = number;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
- }
-
- private class MyRepresenter extends Representer {
- @Override
- protected Set<Property> getProperties(Class<? extends Object> type)
- throws IntrospectionException {
- Set<Property> set = super.getProperties(type);
- Set<Property> filtered = new TreeSet<Property>();
- if (type.equals(BeanToRemoveProperty.class)) {
- // filter properties
- for (Property prop : set) {
- String name = prop.getName();
- if (!name.equals("id")) {
- filtered.add(prop);
- }
- }
- }
- return filtered;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import java.beans.IntrospectionException;
+import java.util.Set;
+import java.util.TreeSet;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.introspector.Property;
+
+public class FilterPropertyToDumpTest extends TestCase {
+
+ public void testFilterPropertyInJavaBeanDumper() {
+ BeanToRemoveProperty bean = new BeanToRemoveProperty();
+ bean.setNumber(24);
+ bean.setId("ID124");
+ Yaml d = new Yaml();
+ String dump = d.dumpAsMap(bean);
+ // System.out.println(dump);
+ assertEquals("id: ID124\nnumber: 24\n", dump);
+ }
+
+ public void testFilterPropertyInYaml() {
+ BeanToRemoveProperty bean = new BeanToRemoveProperty();
+ bean.setNumber(25);
+ bean.setId("ID125");
+ Yaml yaml = new Yaml(new MyRepresenter());
+ String dump = yaml.dumpAsMap(bean);
+ // System.out.println(dump);
+ assertEquals("number: 25\n", dump);
+ }
+
+ public void testDoNotFilterPropertyIncludeReadOnly() {
+ BeanToRemoveProperty bean = new BeanToRemoveProperty();
+ bean.setNumber(26);
+ bean.setId("ID126");
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ String dump = yaml.dump(bean);
+ // System.out.println(dump);
+ assertEquals(
+ "!!org.yaml.snakeyaml.representer.FilterPropertyToDumpTest$BeanToRemoveProperty {id: ID126,\n number: 26, something: true}\n",
+ dump);
+ }
+
+ public class BeanToRemoveProperty {
+ private int number;
+ private String id;
+
+ public boolean isSomething() {
+ return true;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public void setNumber(int number) {
+ this.number = number;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
+ }
+
+ private class MyRepresenter extends Representer {
+ @Override
+ protected Set<Property> getProperties(Class<? extends Object> type)
+ throws IntrospectionException {
+ Set<Property> set = super.getProperties(type);
+ Set<Property> filtered = new TreeSet<Property>();
+ if (type.equals(BeanToRemoveProperty.class)) {
+ // filter properties
+ for (Property prop : set) {
+ String name = prop.getName();
+ if (!name.equals("id")) {
+ filtered.add(prop);
+ }
+ }
+ }
+ return filtered;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/representer/RepresentFieldTest.java b/src/test/java/org/yaml/snakeyaml/representer/RepresentFieldTest.java
index 84437f2..0ad25f0 100644
--- a/src/test/java/org/yaml/snakeyaml/representer/RepresentFieldTest.java
+++ b/src/test/java/org/yaml/snakeyaml/representer/RepresentFieldTest.java
@@ -1,69 +1,69 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public class RepresentFieldTest extends TestCase {
-
- public void testRepresent1() {
- Yaml yaml = new Yaml();
- WrongJavaBean bean = new WrongJavaBean();
- bean.packageField = "Value";// the field is present
- bean.publicField = "Michael Jackson";
- WrongJavaBean.staticField = "Another value";
- String output = yaml.dump(bean);
- assertEquals(
- "!!org.yaml.snakeyaml.representer.WrongJavaBean {publicField: Michael Jackson}\n",
- output);
- }
-
- public void testWrongNotPublicField() {
- Yaml yaml = new Yaml();
- WrongJavaBean bean = new WrongJavaBean();
- bean.packageField = "Value";// the field is present
- try {
- yaml.load("!!org.yaml.snakeyaml.representer.WrongJavaBean {packageField: Gnome}\n");
- fail("Only public fields can be used.");
- } catch (Exception e) {
- assertEquals(
- "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.representer.WrongJavaBean; exception=Cannot create property=packageField for JavaBean=WrongJavaBean; Unable to find property 'packageField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
- e.getMessage());
- assertEquals(
- "Cannot create property=packageField for JavaBean=WrongJavaBean; Unable to find property 'packageField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
- e.getCause().getMessage());
- }
- }
-
- public void testStaticField() {
- Yaml yaml = new Yaml();
- WrongJavaBean.staticField = "Value";// the field is present
- try {
- yaml.load("!!org.yaml.snakeyaml.representer.WrongJavaBean {staticField: Gnome}\n");
- fail("Static fields cannot be used.");
- } catch (Exception e) {
- assertEquals(
- "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.representer.WrongJavaBean; exception=Cannot create property=staticField for JavaBean=WrongJavaBean; Unable to find property 'staticField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
- e.getMessage());
- assertEquals(
- "Cannot create property=staticField for JavaBean=WrongJavaBean; Unable to find property 'staticField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
- e.getCause().getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public class RepresentFieldTest extends TestCase {
+
+ public void testRepresent1() {
+ Yaml yaml = new Yaml();
+ WrongJavaBean bean = new WrongJavaBean();
+ bean.packageField = "Value";// the field is present
+ bean.publicField = "Michael Jackson";
+ WrongJavaBean.staticField = "Another value";
+ String output = yaml.dump(bean);
+ assertEquals(
+ "!!org.yaml.snakeyaml.representer.WrongJavaBean {publicField: Michael Jackson}\n",
+ output);
+ }
+
+ public void testWrongNotPublicField() {
+ Yaml yaml = new Yaml();
+ WrongJavaBean bean = new WrongJavaBean();
+ bean.packageField = "Value";// the field is present
+ try {
+ yaml.load("!!org.yaml.snakeyaml.representer.WrongJavaBean {packageField: Gnome}\n");
+ fail("Only public fields can be used.");
+ } catch (Exception e) {
+ assertEquals(
+ "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.representer.WrongJavaBean; exception=Cannot create property=packageField for JavaBean=WrongJavaBean; Unable to find property 'packageField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
+ e.getMessage());
+ assertEquals(
+ "Cannot create property=packageField for JavaBean=WrongJavaBean; Unable to find property 'packageField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
+ e.getCause().getMessage());
+ }
+ }
+
+ public void testStaticField() {
+ Yaml yaml = new Yaml();
+ WrongJavaBean.staticField = "Value";// the field is present
+ try {
+ yaml.load("!!org.yaml.snakeyaml.representer.WrongJavaBean {staticField: Gnome}\n");
+ fail("Static fields cannot be used.");
+ } catch (Exception e) {
+ assertEquals(
+ "null; Can't construct a java object for tag:yaml.org,2002:org.yaml.snakeyaml.representer.WrongJavaBean; exception=Cannot create property=staticField for JavaBean=WrongJavaBean; Unable to find property 'staticField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
+ e.getMessage());
+ assertEquals(
+ "Cannot create property=staticField for JavaBean=WrongJavaBean; Unable to find property 'staticField' on class: org.yaml.snakeyaml.representer.WrongJavaBean",
+ e.getCause().getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/representer/RepresentIterableTest.java b/src/test/java/org/yaml/snakeyaml/representer/RepresentIterableTest.java
index 1463474..2e8769a 100644
--- a/src/test/java/org/yaml/snakeyaml/representer/RepresentIterableTest.java
+++ b/src/test/java/org/yaml/snakeyaml/representer/RepresentIterableTest.java
@@ -1,74 +1,74 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import java.util.Iterator;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test {@link issue69 http://code.google.com/p/snakeyaml/issues/detail?id=69}
- */
-public class RepresentIterableTest extends TestCase {
-
- public void testIterable() {
- Yaml yaml = new Yaml();
- try {
- yaml.dump(new CounterFactory());
- fail("Iterable should not be treated as sequence by default.");
- } catch (Exception e) {
- assertEquals(
- "No JavaBean properties found in org.yaml.snakeyaml.representer.RepresentIterableTest$CounterFactory",
- e.getMessage());
- }
- }
-
- public void testIterator() {
- Yaml yaml = new Yaml();
- String output = yaml.dump(new Counter(7));
- assertEquals("[0, 1, 2, 3, 4, 5, 6]\n", output);
- }
-
- private class CounterFactory implements Iterable<Integer> {
- public Iterator<Integer> iterator() {
- return new Counter(10);
- }
- }
-
- private class Counter implements Iterator<Integer> {
- private int max = 0;
- private int counter = 0;
-
- public Counter(int max) {
- this.max = max;
- }
-
- public boolean hasNext() {
- return counter < max;
- }
-
- public Integer next() {
- return counter++;
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test {@link issue69 http://code.google.com/p/snakeyaml/issues/detail?id=69}
+ */
+public class RepresentIterableTest extends TestCase {
+
+ public void testIterable() {
+ Yaml yaml = new Yaml();
+ try {
+ yaml.dump(new CounterFactory());
+ fail("Iterable should not be treated as sequence by default.");
+ } catch (Exception e) {
+ assertEquals(
+ "No JavaBean properties found in org.yaml.snakeyaml.representer.RepresentIterableTest$CounterFactory",
+ e.getMessage());
+ }
+ }
+
+ public void testIterator() {
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(new Counter(7));
+ assertEquals("[0, 1, 2, 3, 4, 5, 6]\n", output);
+ }
+
+ private class CounterFactory implements Iterable<Integer> {
+ public Iterator<Integer> iterator() {
+ return new Counter(10);
+ }
+ }
+
+ private class Counter implements Iterator<Integer> {
+ private int max = 0;
+ private int counter = 0;
+
+ public Counter(int max) {
+ this.max = max;
+ }
+
+ public boolean hasNext() {
+ return counter < max;
+ }
+
+ public Integer next() {
+ return counter++;
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/representer/RepresentTest.java b/src/test/java/org/yaml/snakeyaml/representer/RepresentTest.java
index c5f7116..83a2148 100644
--- a/src/test/java/org/yaml/snakeyaml/representer/RepresentTest.java
+++ b/src/test/java/org/yaml/snakeyaml/representer/RepresentTest.java
@@ -1,91 +1,91 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class RepresentTest extends TestCase {
-
- public void testCustomRepresenter() {
- Yaml yaml = new Yaml(new MyConstructor(), new MyRepresenter());
- CustomBean etalon = new CustomBean("A", 1);
- String output = yaml.dump(etalon);
- assertEquals("!!Dice 'Ad1'\n", output);
- CustomBean bean = (CustomBean) yaml.load(output);
- assertEquals("A", bean.getPrefix());
- assertEquals(1, bean.getSuffix());
- assertEquals(etalon, bean);
- }
-
- class CustomBean {
- private String prefix;
- private int suffix;
-
- public CustomBean(String prefix, int suffix) {
- this.prefix = prefix;
- this.suffix = suffix;
- }
-
- public String getPrefix() {
- return prefix;
- }
-
- public int getSuffix() {
- return suffix;
- }
-
- @Override
- public boolean equals(Object obj) {
- CustomBean bean = (CustomBean) obj;
- return prefix.equals(bean.getPrefix()) && suffix == bean.getSuffix();
- }
- }
-
- class MyRepresenter extends Representer {
- public MyRepresenter() {
- this.representers.put(CustomBean.class, new RepresentDice());
- }
-
- private class RepresentDice implements Represent {
- public Node representData(Object data) {
- CustomBean coin = (CustomBean) data;
- String value = coin.getPrefix() + "d" + coin.getSuffix();
- return representScalar(new Tag("!!Dice"), value);
- }
- }
- }
-
- class MyConstructor extends Constructor {
- public MyConstructor() {
- this.yamlConstructors.put(new Tag(Tag.PREFIX + "Dice"), new ConstructDice());
- }
-
- private class ConstructDice extends AbstractConstruct {
- public Object construct(Node node) {
- String val = (String) constructScalar((ScalarNode) node);
- return new CustomBean(val.substring(0, 1), new Integer(val.substring(2)));
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class RepresentTest extends TestCase {
+
+ public void testCustomRepresenter() {
+ Yaml yaml = new Yaml(new MyConstructor(), new MyRepresenter());
+ CustomBean etalon = new CustomBean("A", 1);
+ String output = yaml.dump(etalon);
+ assertEquals("!!Dice 'Ad1'\n", output);
+ CustomBean bean = (CustomBean) yaml.load(output);
+ assertEquals("A", bean.getPrefix());
+ assertEquals(1, bean.getSuffix());
+ assertEquals(etalon, bean);
+ }
+
+ class CustomBean {
+ private String prefix;
+ private int suffix;
+
+ public CustomBean(String prefix, int suffix) {
+ this.prefix = prefix;
+ this.suffix = suffix;
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public int getSuffix() {
+ return suffix;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ CustomBean bean = (CustomBean) obj;
+ return prefix.equals(bean.getPrefix()) && suffix == bean.getSuffix();
+ }
+ }
+
+ class MyRepresenter extends Representer {
+ public MyRepresenter() {
+ this.representers.put(CustomBean.class, new RepresentDice());
+ }
+
+ private class RepresentDice implements Represent {
+ public Node representData(Object data) {
+ CustomBean coin = (CustomBean) data;
+ String value = coin.getPrefix() + "d" + coin.getSuffix();
+ return representScalar(new Tag("!!Dice"), value);
+ }
+ }
+ }
+
+ class MyConstructor extends Constructor {
+ public MyConstructor() {
+ this.yamlConstructors.put(new Tag(Tag.PREFIX + "Dice"), new ConstructDice());
+ }
+
+ private class ConstructDice extends AbstractConstruct {
+ public Object construct(Node node) {
+ String val = (String) constructScalar((ScalarNode) node);
+ return new CustomBean(val.substring(0, 1), new Integer(val.substring(2)));
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/representer/RepresenterTest.java b/src/test/java/org/yaml/snakeyaml/representer/RepresenterTest.java
index a691837..531d17a 100644
--- a/src/test/java/org/yaml/snakeyaml/representer/RepresenterTest.java
+++ b/src/test/java/org/yaml/snakeyaml/representer/RepresenterTest.java
@@ -1,193 +1,193 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class RepresenterTest extends TestCase {
-
- public void testRepresenter() {
- MyBean bean = new MyBean();
- bean.setName("Gnome");
- bean.setValid(true);
- bean.setPrimitive(true);
- Yaml yaml = new Yaml();
- assertEquals(
- "!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean {name: Gnome, primitive: true}\n",
- yaml.dump(bean));
- }
-
- public static class MyBean {
- private String name;
- private Boolean valid;
- private boolean primitive;
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Boolean isValid() {
- return valid;
- }
-
- public void setValid(Boolean valid) {
- this.valid = valid;
- }
-
- public boolean isPrimitive() {
- return primitive;
- }
-
- public void setPrimitive(boolean primitive) {
- this.primitive = primitive;
- }
- }
-
- public void testRepresenterNoConstructorAvailable() {
- MyBean2 bean = new MyBean2("Gnome", true);
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- assertEquals("!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean2 {valid: true}\n",
- yaml.dump(bean));
- }
-
- public static class MyBean2 {
- private String name;
- private Boolean valid;
-
- public MyBean2(String name, Boolean valid) {
- this();
- this.name = name;
- this.valid = valid;
- }
-
- private MyBean2() {
- super();
- }
-
- private String getName() {
- return name;
- }
-
- public Boolean getValid() {
- return valid;
- }
-
- @Override
- public String toString() {
- return getName() + " " + getValid();
- }
- }
-
- public void testRepresenterGetterWithException() {
- MyBean3 bean = new MyBean3("Gnome", false);
- DumperOptions options = new DumperOptions();
- options.setAllowReadOnlyProperties(true);
- Yaml yaml = new Yaml(options);
- try {
- String str = yaml.dump(bean);
- fail("Exception must be reported: " + str);
- } catch (Exception e) {
- assertTrue(true);
- }
- // no exception
- MyBean3 bean2 = new MyBean3("Gnome", true);
- String str = yaml.dump(bean2);
- // isValid is no JavaBean property (it must be a primitive then)
- assertEquals(
- "isValid property must not be dumped.",
- "!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean3 {boolProperty: true, name: Gnome}\n",
- str);
- }
-
- public static class MyBean3 {
- private String name;
- private Boolean valid;
- private boolean boolProperty;
-
- public MyBean3(String name, Boolean valid) {
- this.name = name;
- this.valid = valid;
- boolProperty = true;
- }
-
- public String getName() {
- if (valid) {
- return name;
- } else {
- throw new UnsupportedOperationException("Test.");
- }
- }
-
- public Boolean isValid() {
- return valid;
- }
-
- public boolean isBoolProperty() {
- return boolProperty;
- }
-
- @Override
- public String toString() {
- return "MyBean3<" + name + ", " + isValid() + ">";
- }
- }
-
- public void testRepresenterAddNull() {
- Representer representer = new Representer();
- try {
- representer.addClassTag(EmptyBean.class, (Tag) null);
- fail("Tag must be provided.");
- } catch (Exception e) {
- assertEquals("Tag must be provided.", e.getMessage());
- }
- }
-
- public void testRepresenterEmptyBean() {
- EmptyBean bean = new EmptyBean();
- Yaml yaml = new Yaml();
- try {
- yaml.dump(bean);
- fail("EmptyBean has empty representation.");
- } catch (Exception e) {
- assertEquals(
- "No JavaBean properties found in org.yaml.snakeyaml.representer.RepresenterTest$EmptyBean",
- e.getMessage());
- }
- }
-
- public static class EmptyBean {
- private int number;
-
- public void process() {
- number += 1;
- }
-
- public int obtain() {
- return number;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class RepresenterTest extends TestCase {
+
+ public void testRepresenter() {
+ MyBean bean = new MyBean();
+ bean.setName("Gnome");
+ bean.setValid(true);
+ bean.setPrimitive(true);
+ Yaml yaml = new Yaml();
+ assertEquals(
+ "!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean {name: Gnome, primitive: true}\n",
+ yaml.dump(bean));
+ }
+
+ public static class MyBean {
+ private String name;
+ private Boolean valid;
+ private boolean primitive;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Boolean isValid() {
+ return valid;
+ }
+
+ public void setValid(Boolean valid) {
+ this.valid = valid;
+ }
+
+ public boolean isPrimitive() {
+ return primitive;
+ }
+
+ public void setPrimitive(boolean primitive) {
+ this.primitive = primitive;
+ }
+ }
+
+ public void testRepresenterNoConstructorAvailable() {
+ MyBean2 bean = new MyBean2("Gnome", true);
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ assertEquals("!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean2 {valid: true}\n",
+ yaml.dump(bean));
+ }
+
+ public static class MyBean2 {
+ private String name;
+ private Boolean valid;
+
+ public MyBean2(String name, Boolean valid) {
+ this();
+ this.name = name;
+ this.valid = valid;
+ }
+
+ private MyBean2() {
+ super();
+ }
+
+ private String getName() {
+ return name;
+ }
+
+ public Boolean getValid() {
+ return valid;
+ }
+
+ @Override
+ public String toString() {
+ return getName() + " " + getValid();
+ }
+ }
+
+ public void testRepresenterGetterWithException() {
+ MyBean3 bean = new MyBean3("Gnome", false);
+ DumperOptions options = new DumperOptions();
+ options.setAllowReadOnlyProperties(true);
+ Yaml yaml = new Yaml(options);
+ try {
+ String str = yaml.dump(bean);
+ fail("Exception must be reported: " + str);
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+ // no exception
+ MyBean3 bean2 = new MyBean3("Gnome", true);
+ String str = yaml.dump(bean2);
+ // isValid is no JavaBean property (it must be a primitive then)
+ assertEquals(
+ "isValid property must not be dumped.",
+ "!!org.yaml.snakeyaml.representer.RepresenterTest$MyBean3 {boolProperty: true, name: Gnome}\n",
+ str);
+ }
+
+ public static class MyBean3 {
+ private String name;
+ private Boolean valid;
+ private boolean boolProperty;
+
+ public MyBean3(String name, Boolean valid) {
+ this.name = name;
+ this.valid = valid;
+ boolProperty = true;
+ }
+
+ public String getName() {
+ if (valid) {
+ return name;
+ } else {
+ throw new UnsupportedOperationException("Test.");
+ }
+ }
+
+ public Boolean isValid() {
+ return valid;
+ }
+
+ public boolean isBoolProperty() {
+ return boolProperty;
+ }
+
+ @Override
+ public String toString() {
+ return "MyBean3<" + name + ", " + isValid() + ">";
+ }
+ }
+
+ public void testRepresenterAddNull() {
+ Representer representer = new Representer();
+ try {
+ representer.addClassTag(EmptyBean.class, (Tag) null);
+ fail("Tag must be provided.");
+ } catch (Exception e) {
+ assertEquals("Tag must be provided.", e.getMessage());
+ }
+ }
+
+ public void testRepresenterEmptyBean() {
+ EmptyBean bean = new EmptyBean();
+ Yaml yaml = new Yaml();
+ try {
+ yaml.dump(bean);
+ fail("EmptyBean has empty representation.");
+ } catch (Exception e) {
+ assertEquals(
+ "No JavaBean properties found in org.yaml.snakeyaml.representer.RepresenterTest$EmptyBean",
+ e.getMessage());
+ }
+ }
+
+ public static class EmptyBean {
+ private int number;
+
+ public void process() {
+ number += 1;
+ }
+
+ public int obtain() {
+ return number;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/representer/SafeRepresenterTest.java b/src/test/java/org/yaml/snakeyaml/representer/SafeRepresenterTest.java
index 61fcc86..5232598 100644
--- a/src/test/java/org/yaml/snakeyaml/representer/SafeRepresenterTest.java
+++ b/src/test/java/org/yaml/snakeyaml/representer/SafeRepresenterTest.java
@@ -1,137 +1,137 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.representer;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-
-public class SafeRepresenterTest extends TestCase {
-
- public void testBinaryPattern() {
- Pattern pattern = SafeRepresenter.BINARY_PATTERN;
- assertFalse(pattern.matcher("\tAndrey\r\n").find());
- assertTrue(pattern.matcher("\u0005Andrey").find());
- }
-
- public void testFloat() {
- assertEquals("1.0E12", String.valueOf(new Double("1e12")));
- }
-
- public void testNumber() {
- List<Number> list = new ArrayList<Number>();
- list.add(new Byte((byte) 3));
- list.add(new Short((short) 4));
- list.add(new Integer(5));
- list.add(new BigInteger("6"));
- list.add(new Long(7L));
- list.add(Double.POSITIVE_INFINITY);
- list.add(Double.NEGATIVE_INFINITY);
- list.add(Double.NaN);
- Yaml yaml = new Yaml();
- String output = yaml.dump(list);
- assertEquals("[3, 4, 5, 6, 7, .inf, -.inf, .NaN]\n", output);
- }
-
- public void testDate() {
- List<Date> list = new ArrayList<Date>();
- list.add(new Date(1229684761159L));
- list.add(new Date(1229684761059L));
- list.add(new Date(1229684761009L));
- list.add(new Date(1229684761150L));
- list.add(new Date(1229684761100L));
- list.add(new Date(1229684761000L));
- list.add(new Date(1229684760000L));
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(list);
- assertEquals(
- "- 2008-12-19T11:06:01.159Z\n- 2008-12-19T11:06:01.059Z\n- 2008-12-19T11:06:01.009Z\n- 2008-12-19T11:06:01.150Z\n- 2008-12-19T11:06:01.100Z\n- 2008-12-19T11:06:01Z\n- 2008-12-19T11:06:00Z\n",
- output);
- }
-
- public void testEmptyArray() {
- Yaml yaml = new Yaml();
- String output = yaml.dump(new String[0]);
- assertEquals("[]\n", output);
- }
-
- public void testStyle() {
- List<Integer> list = new ArrayList<Integer>();
- list.add(new Integer(1));
- list.add(new Integer(1));
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("list", list);
- map.put("name", "Ubuntu");
- map.put("age", 5);
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- assertTrue(output.contains("\"age\": !!int \"5\""));
- assertTrue(output.contains("\"name\": \"Ubuntu\""));
- assertTrue(output.contains("- !!int \"1\""));
- }
-
- public void testStyle2() {
- List<Integer> list = new ArrayList<Integer>();
- list.add(new Integer(1));
- list.add(new Integer(1));
- Map<String, Object> map = new LinkedHashMap<String, Object>();
- map.put("age", 5);
- map.put("name", "Ubuntu");
- map.put("list", list);
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- assertEquals("{'age': !!int '5', 'name': 'Ubuntu', 'list': [!!int '1', !!int '1']}\n",
- output);
- }
-
- public void testStyle2Pretty() {
- List<Integer> list = new ArrayList<Integer>();
- list.add(new Integer(1));
- list.add(new Integer(1));
- Map<String, Object> map = new LinkedHashMap<String, Object>();
- map.put("age", 5);
- map.put("name", "Ubuntu");
- map.put("list", list);
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
- options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
- options.setPrettyFlow(true);
- Yaml yaml = new Yaml(options);
- String output = yaml.dump(map);
- assertEquals(
- "{\n 'age': !!int '5',\n 'name': 'Ubuntu',\n 'list': [\n !!int '1',\n !!int '1']\n \n}\n",
- output);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.representer;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+
+public class SafeRepresenterTest extends TestCase {
+
+ public void testBinaryPattern() {
+ Pattern pattern = SafeRepresenter.BINARY_PATTERN;
+ assertFalse(pattern.matcher("\tAndrey\r\n").find());
+ assertTrue(pattern.matcher("\u0005Andrey").find());
+ }
+
+ public void testFloat() {
+ assertEquals("1.0E12", String.valueOf(new Double("1e12")));
+ }
+
+ public void testNumber() {
+ List<Number> list = new ArrayList<Number>();
+ list.add(new Byte((byte) 3));
+ list.add(new Short((short) 4));
+ list.add(new Integer(5));
+ list.add(new BigInteger("6"));
+ list.add(new Long(7L));
+ list.add(Double.POSITIVE_INFINITY);
+ list.add(Double.NEGATIVE_INFINITY);
+ list.add(Double.NaN);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(list);
+ assertEquals("[3, 4, 5, 6, 7, .inf, -.inf, .NaN]\n", output);
+ }
+
+ public void testDate() {
+ List<Date> list = new ArrayList<Date>();
+ list.add(new Date(1229684761159L));
+ list.add(new Date(1229684761059L));
+ list.add(new Date(1229684761009L));
+ list.add(new Date(1229684761150L));
+ list.add(new Date(1229684761100L));
+ list.add(new Date(1229684761000L));
+ list.add(new Date(1229684760000L));
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(list);
+ assertEquals(
+ "- 2008-12-19T11:06:01.159Z\n- 2008-12-19T11:06:01.059Z\n- 2008-12-19T11:06:01.009Z\n- 2008-12-19T11:06:01.150Z\n- 2008-12-19T11:06:01.100Z\n- 2008-12-19T11:06:01Z\n- 2008-12-19T11:06:00Z\n",
+ output);
+ }
+
+ public void testEmptyArray() {
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(new String[0]);
+ assertEquals("[]\n", output);
+ }
+
+ public void testStyle() {
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(new Integer(1));
+ list.add(new Integer(1));
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("list", list);
+ map.put("name", "Ubuntu");
+ map.put("age", 5);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ assertTrue(output.contains("\"age\": !!int \"5\""));
+ assertTrue(output.contains("\"name\": \"Ubuntu\""));
+ assertTrue(output.contains("- !!int \"1\""));
+ }
+
+ public void testStyle2() {
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(new Integer(1));
+ list.add(new Integer(1));
+ Map<String, Object> map = new LinkedHashMap<String, Object>();
+ map.put("age", 5);
+ map.put("name", "Ubuntu");
+ map.put("list", list);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ assertEquals("{'age': !!int '5', 'name': 'Ubuntu', 'list': [!!int '1', !!int '1']}\n",
+ output);
+ }
+
+ public void testStyle2Pretty() {
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(new Integer(1));
+ list.add(new Integer(1));
+ Map<String, Object> map = new LinkedHashMap<String, Object>();
+ map.put("age", 5);
+ map.put("name", "Ubuntu");
+ map.put("list", list);
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(DumperOptions.ScalarStyle.SINGLE_QUOTED);
+ options.setDefaultFlowStyle(DumperOptions.FlowStyle.FLOW);
+ options.setPrettyFlow(true);
+ Yaml yaml = new Yaml(options);
+ String output = yaml.dump(map);
+ assertEquals(
+ "{\n 'age': !!int '5',\n 'name': 'Ubuntu',\n 'list': [\n !!int '1',\n !!int '1']\n \n}\n",
+ output);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/resolver/ImplicitResolverTest.java b/src/test/java/org/yaml/snakeyaml/resolver/ImplicitResolverTest.java
index 5058a92..1ed8daa 100644
--- a/src/test/java/org/yaml/snakeyaml/resolver/ImplicitResolverTest.java
+++ b/src/test/java/org/yaml/snakeyaml/resolver/ImplicitResolverTest.java
@@ -1,96 +1,96 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.resolver;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Construct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-
-/**
- * Custom implicit resolver does not apply inside JavaBean declaration <a href=
- * "http://groups.google.com/group/snakeyaml-core/browse_frm/thread/c75c35a3d9cfcaba"
- * >mailing list</a> for more information
- */
-public class ImplicitResolverTest extends TestCase {
- private static final Tag CFG = new Tag("!cfg");
-
- public static class ConfigurationConstructor extends Constructor {
- protected Map<String, String> config = null;
-
- public ConfigurationConstructor(Map<String, String> config) {
- this.config = config;
- this.yamlConstructors.put(CFG, new ConfigObjectConstruct());
- }
-
- private class ConfigObjectConstruct extends AbstractConstruct {
- public Object construct(Node node) {
- String val = (String) constructScalar((ScalarNode) node);
- val = val.substring(2, val.length() - 1);
- return config.get(val);
- }
- }
-
- protected Construct getConstructor(Node node) {
- if (CFG.equals(node.getTag())) {
- node.setUseClassConstructor(false);
- }
- return super.getConstructor(node);
- }
- }
-
- public static class TestBean {
- String myval;
-
- public String getMyval() {
- return myval;
- }
-
- public void setMyval(String myval) {
- this.myval = myval;
- }
-
- public String toString() {
- return "MyVal: " + myval;
- }
- }
-
- public void testMain() {
- Map<String, String> config = new HashMap<String, String>();
- config.put("user.home", "HOME");
- Constructor constructor = new ConfigurationConstructor(config);
- constructor.addTypeDescription(new TypeDescription(TestBean.class, "!testbean"));
- Yaml yaml = new Yaml(constructor);
- yaml.addImplicitResolver(CFG, Pattern.compile("\\$\\([a-zA-Z\\d\\u002E\\u005F]+\\)"), "$");
- TestBean bean = (TestBean) yaml.load("!testbean {myval: !cfg $(user.home)}");
- // System.out.println(bean.toString());
- assertEquals("Explicit tag must be respected", "HOME", bean.getMyval());
- bean = (TestBean) yaml.load("!testbean {myval: $(user.home)}");
- // System.out.println(bean.toString());
- assertEquals("Implicit tag must be respected", "HOME", bean.getMyval());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.resolver;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Construct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+
+/**
+ * Custom implicit resolver does not apply inside JavaBean declaration <a href=
+ * "http://groups.google.com/group/snakeyaml-core/browse_frm/thread/c75c35a3d9cfcaba"
+ * >mailing list</a> for more information
+ */
+public class ImplicitResolverTest extends TestCase {
+ private static final Tag CFG = new Tag("!cfg");
+
+ public static class ConfigurationConstructor extends Constructor {
+ protected Map<String, String> config = null;
+
+ public ConfigurationConstructor(Map<String, String> config) {
+ this.config = config;
+ this.yamlConstructors.put(CFG, new ConfigObjectConstruct());
+ }
+
+ private class ConfigObjectConstruct extends AbstractConstruct {
+ public Object construct(Node node) {
+ String val = (String) constructScalar((ScalarNode) node);
+ val = val.substring(2, val.length() - 1);
+ return config.get(val);
+ }
+ }
+
+ protected Construct getConstructor(Node node) {
+ if (CFG.equals(node.getTag())) {
+ node.setUseClassConstructor(false);
+ }
+ return super.getConstructor(node);
+ }
+ }
+
+ public static class TestBean {
+ String myval;
+
+ public String getMyval() {
+ return myval;
+ }
+
+ public void setMyval(String myval) {
+ this.myval = myval;
+ }
+
+ public String toString() {
+ return "MyVal: " + myval;
+ }
+ }
+
+ public void testMain() {
+ Map<String, String> config = new HashMap<String, String>();
+ config.put("user.home", "HOME");
+ Constructor constructor = new ConfigurationConstructor(config);
+ constructor.addTypeDescription(new TypeDescription(TestBean.class, "!testbean"));
+ Yaml yaml = new Yaml(constructor);
+ yaml.addImplicitResolver(CFG, Pattern.compile("\\$\\([a-zA-Z\\d\\u002E\\u005F]+\\)"), "$");
+ TestBean bean = (TestBean) yaml.load("!testbean {myval: !cfg $(user.home)}");
+ // System.out.println(bean.toString());
+ assertEquals("Explicit tag must be respected", "HOME", bean.getMyval());
+ bean = (TestBean) yaml.load("!testbean {myval: $(user.home)}");
+ // System.out.println(bean.toString());
+ assertEquals("Implicit tag must be respected", "HOME", bean.getMyval());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/resolver/RagelMachine.java b/src/test/java/org/yaml/snakeyaml/resolver/RagelMachine.java
index d115134..5accc80 100644
--- a/src/test/java/org/yaml/snakeyaml/resolver/RagelMachine.java
+++ b/src/test/java/org/yaml/snakeyaml/resolver/RagelMachine.java
@@ -1,330 +1,330 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.
- */
-
-// line 1 "RagelMachine.rl"
-package org.yaml.snakeyaml.resolver;
-
-//Source for Ragel 6.3
-
-/**
- * Generated by Ragel 6.3 (http://www.complang.org/ragel/)
- *
- * @see http://www.complang.org/ragel/
- */
-public class RagelMachine {
-
- // line 15 "RagelMachine.java"
- private static byte[] init__snakeyaml_actions_0() {
- return new byte[] { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6 };
- }
-
- private static final byte _snakeyaml_actions[] = init__snakeyaml_actions_0();
-
- private static short[] init__snakeyaml_key_offsets_0() {
- return new short[] { 0, 0, 20, 24, 28, 30, 32, 34, 35, 36, 37, 42, 46, 50, 52, 56, 59, 66,
- 70, 74, 80, 82, 83, 84, 85, 87, 90, 92, 98, 102, 105, 106, 108, 110, 111, 113, 115,
- 120, 122, 124, 126, 130, 132, 133, 135, 141, 147, 152, 157, 158, 160, 161, 162,
- 163, 164, 165, 166, 170, 171, 172, 173, 174, 178, 179, 180, 182, 183, 184, 186,
- 187, 188, 189, 191, 193, 194, 195, 195, 200, 202, 202, 211, 218, 224, 227, 234,
- 239, 243, 245, 250, 253, 254, 263, 270, 277, 285, 291, 294, 295, 295, 302, 306,
- 311, 316, 321, 327, 327, 327 };
- }
-
- private static final short _snakeyaml_key_offsets[] = init__snakeyaml_key_offsets_0();
-
- private static char[] init__snakeyaml_trans_keys_0() {
- return new char[] { 32, 43, 45, 46, 48, 60, 61, 70, 78, 79, 84, 89, 102, 110, 111, 116,
- 121, 126, 49, 57, 46, 48, 49, 57, 73, 105, 48, 57, 43, 45, 48, 57, 78, 110, 70,
- 102, 110, 46, 58, 95, 48, 57, 48, 53, 54, 57, 46, 58, 48, 57, 46, 58, 46, 95, 48,
- 57, 95, 48, 49, 95, 48, 57, 65, 70, 97, 102, 48, 53, 54, 57, 48, 53, 54, 57, 73,
- 78, 105, 110, 48, 57, 65, 97, 78, 97, 110, 48, 57, 45, 48, 57, 48, 57, 9, 32, 84,
- 116, 48, 57, 9, 32, 48, 57, 58, 48, 57, 58, 48, 57, 48, 57, 58, 48, 57, 48, 57, 9,
- 32, 43, 45, 90, 48, 57, 48, 57, 48, 57, 9, 32, 84, 116, 48, 57, 45, 48, 57, 9, 32,
- 84, 116, 48, 57, 45, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57,
- 60, 65, 97, 76, 83, 69, 108, 115, 101, 79, 85, 111, 117, 76, 76, 108, 108, 70, 78,
- 102, 110, 70, 102, 82, 114, 85, 117, 69, 101, 83, 115, 97, 111, 117, 102, 110, 114,
- 101, 69, 95, 101, 48, 57, 48, 57, 46, 58, 95, 98, 120, 48, 55, 56, 57, 46, 58, 95,
- 48, 55, 56, 57, 46, 95, 48, 55, 56, 57, 95, 48, 49, 95, 48, 57, 65, 70, 97, 102,
- 46, 58, 95, 48, 57, 46, 58, 48, 57, 46, 58, 46, 58, 95, 48, 57, 58, 48, 57, 58, 46,
- 58, 95, 98, 120, 48, 55, 56, 57, 46, 58, 95, 48, 55, 56, 57, 46, 58, 95, 48, 55,
- 56, 57, 45, 46, 58, 95, 48, 55, 56, 57, 9, 32, 43, 45, 46, 90, 58, 48, 57, 58, 9,
- 32, 43, 45, 90, 48, 57, 9, 32, 84, 116, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57, 46,
- 58, 95, 48, 57, 45, 46, 58, 95, 48, 57, 0 };
- }
-
- private static final char _snakeyaml_trans_keys[] = init__snakeyaml_trans_keys_0();
-
- private static byte[] init__snakeyaml_single_lengths_0() {
- return new byte[] { 0, 18, 2, 2, 2, 0, 2, 1, 1, 1, 3, 0, 2, 2, 2, 1, 1, 0, 0, 4, 2, 1, 1,
- 1, 0, 1, 0, 4, 2, 1, 1, 0, 0, 1, 0, 0, 5, 0, 0, 0, 4, 0, 1, 0, 4, 4, 3, 3, 1, 2, 1,
- 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 4, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 0, 3, 0, 0,
- 5, 3, 2, 1, 1, 3, 2, 2, 3, 1, 1, 5, 3, 3, 4, 6, 1, 1, 0, 5, 4, 3, 3, 3, 4, 0, 0, 0 };
- }
-
- private static final byte _snakeyaml_single_lengths[] = init__snakeyaml_single_lengths_0();
-
- private static byte[] init__snakeyaml_range_lengths_0() {
- return new byte[] { 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 1, 3, 2, 2, 1, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 2,
- 2, 2, 1, 3, 1, 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0 };
- }
-
- private static final byte _snakeyaml_range_lengths[] = init__snakeyaml_range_lengths_0();
-
- private static short[] init__snakeyaml_index_offsets_0() {
- return new short[] { 0, 0, 20, 24, 28, 31, 33, 36, 38, 40, 42, 47, 50, 54, 57, 61, 64, 69,
- 72, 75, 81, 84, 86, 88, 90, 92, 95, 97, 103, 107, 110, 112, 114, 116, 118, 120,
- 122, 128, 130, 132, 134, 139, 141, 143, 145, 151, 157, 162, 167, 169, 172, 174,
- 176, 178, 180, 182, 184, 189, 191, 193, 195, 197, 202, 204, 206, 209, 211, 213,
- 216, 218, 220, 222, 225, 228, 230, 232, 233, 238, 240, 241, 249, 255, 260, 263,
- 268, 273, 277, 280, 285, 288, 290, 298, 304, 310, 317, 324, 327, 329, 330, 337,
- 342, 347, 352, 357, 363, 364, 365 };
- }
-
- private static final short _snakeyaml_index_offsets[] = init__snakeyaml_index_offsets_0();
-
- private static byte[] init__snakeyaml_indicies_0() {
- return new byte[] { 0, 2, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 5, 1, 18,
- 19, 20, 1, 22, 23, 21, 1, 24, 24, 1, 25, 1, 26, 27, 1, 28, 1, 28, 1, 27, 1, 21, 30,
- 31, 29, 1, 32, 33, 1, 25, 30, 33, 1, 25, 30, 1, 21, 31, 31, 1, 34, 34, 1, 35, 35,
- 35, 35, 1, 36, 37, 1, 38, 39, 1, 22, 40, 23, 41, 21, 1, 42, 42, 1, 28, 1, 43, 1,
- 28, 1, 44, 1, 45, 46, 1, 47, 1, 48, 48, 50, 50, 49, 1, 48, 48, 51, 1, 53, 52, 1,
- 53, 1, 54, 1, 55, 1, 56, 1, 57, 1, 58, 1, 59, 59, 60, 60, 61, 1, 62, 1, 63, 1, 61,
- 1, 48, 48, 50, 50, 1, 51, 1, 64, 1, 65, 1, 48, 48, 50, 50, 66, 1, 67, 21, 30, 31,
- 29, 1, 21, 30, 31, 68, 1, 21, 30, 31, 69, 1, 70, 1, 71, 72, 1, 73, 1, 74, 1, 75, 1,
- 76, 1, 77, 1, 75, 1, 75, 78, 75, 79, 1, 80, 1, 0, 1, 81, 1, 0, 1, 82, 75, 83, 75,
- 1, 75, 1, 75, 1, 84, 85, 1, 74, 1, 77, 1, 86, 87, 1, 75, 1, 75, 1, 72, 1, 75, 79,
- 1, 83, 75, 1, 85, 1, 87, 1, 1, 88, 21, 88, 21, 1, 25, 1, 1, 21, 30, 90, 91, 92, 89,
- 29, 1, 21, 30, 90, 89, 29, 1, 21, 90, 90, 31, 1, 34, 34, 1, 35, 35, 35, 35, 1, 21,
- 93, 94, 20, 1, 25, 93, 37, 1, 25, 93, 1, 21, 95, 94, 94, 1, 95, 39, 1, 95, 1, 21,
- 30, 90, 91, 92, 96, 97, 1, 21, 30, 90, 98, 69, 1, 21, 30, 90, 99, 68, 1, 67, 21,
- 30, 90, 89, 29, 1, 59, 59, 60, 60, 100, 61, 1, 102, 101, 1, 102, 1, 1, 59, 59, 60,
- 60, 61, 100, 1, 48, 48, 50, 50, 1, 21, 93, 94, 103, 1, 21, 93, 94, 104, 1, 21, 93,
- 94, 105, 1, 67, 21, 93, 94, 20, 1, 1, 1, 1, 0 };
- }
-
- private static final byte _snakeyaml_indicies[] = init__snakeyaml_indicies_0();
-
- private static byte[] init__snakeyaml_trans_targs_0() {
- return new byte[] { 75, 0, 2, 19, 90, 100, 48, 105, 49, 56, 61, 64, 67, 70, 71, 72, 73, 74,
- 3, 79, 84, 76, 6, 9, 5, 77, 7, 8, 78, 10, 11, 14, 12, 13, 82, 83, 85, 86, 88, 89,
- 20, 22, 21, 23, 25, 26, 42, 27, 28, 40, 41, 29, 30, 31, 32, 33, 34, 35, 94, 36, 37,
- 97, 95, 39, 43, 44, 99, 24, 45, 46, 104, 50, 53, 51, 52, 106, 54, 55, 57, 59, 58,
- 60, 62, 63, 65, 66, 68, 69, 4, 80, 81, 15, 16, 17, 87, 18, 91, 47, 92, 93, 98, 96,
- 38, 101, 102, 103 };
- }
-
- private static final byte _snakeyaml_trans_targs[] = init__snakeyaml_trans_targs_0();
-
- // private static byte[] init__snakeyaml_trans_actions_0() {
- // return new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- // 0, 0, 0, 0, 0, 0,
- // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- // 0, 0, 0, 0,
- // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- // 0, 0, 0, 0,
- // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- // 0, 0 };
- // }
-
- // private static final byte _snakeyaml_trans_actions[] =
- // init__snakeyaml_trans_actions_0();
-
- private static byte[] init__snakeyaml_eof_actions_0() {
- return new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 11, 11, 11,
- 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 3,
- 7, 1 };
- }
-
- private static final byte _snakeyaml_eof_actions[] = init__snakeyaml_eof_actions_0();
-
- static final int snakeyaml_start = 1;
- static final int snakeyaml_error = 0;
-
- static final int snakeyaml_en_main = 1;
-
- // line 53 "RagelMachine.rl"
-
- public String scan(String scalar) {
- if (scalar == null) {
- throw new NullPointerException("Scalar must be provided.");
- }
- String tag = null;
- int cs = 0;
- int p = 0;
- int pe = scalar.length();
- int eof = pe;
- char[] data;
- if (pe == 0) {
- // NULL value
- data = new char[] { '~' };
- pe = 1;
- eof = 1;
- } else {
- data = scalar.toCharArray();
- }
-
- // line 257 "RagelMachine.java"
- {
- cs = snakeyaml_start;
- }
-
- // line 262 "RagelMachine.java"
- {
- int _klen;
- int _trans = 0;
- int _keys;
- int _goto_targ = 0;
-
- _goto: while (true) {
- switch (_goto_targ) {
- case 0:
- if (p == pe) {
- _goto_targ = 4;
- continue _goto;
- }
- if (cs == 0) {
- _goto_targ = 5;
- continue _goto;
- }
- case 1:
- _match: do {
- _keys = _snakeyaml_key_offsets[cs];
- _trans = _snakeyaml_index_offsets[cs];
- _klen = _snakeyaml_single_lengths[cs];
- if (_klen > 0) {
- int _lower = _keys;
- int _mid;
- int _upper = _keys + _klen - 1;
- while (true) {
- if (_upper < _lower)
- break;
-
- _mid = _lower + ((_upper - _lower) >> 1);
- if (data[p] < _snakeyaml_trans_keys[_mid])
- _upper = _mid - 1;
- else if (data[p] > _snakeyaml_trans_keys[_mid])
- _lower = _mid + 1;
- else {
- _trans += (_mid - _keys);
- break _match;
- }
- }
- _keys += _klen;
- _trans += _klen;
- }
-
- _klen = _snakeyaml_range_lengths[cs];
- if (_klen > 0) {
- int _lower = _keys;
- int _mid;
- int _upper = _keys + (_klen << 1) - 2;
- while (true) {
- if (_upper < _lower)
- break;
-
- _mid = _lower + (((_upper - _lower) >> 1) & ~1);
- if (data[p] < _snakeyaml_trans_keys[_mid])
- _upper = _mid - 2;
- else if (data[p] > _snakeyaml_trans_keys[_mid + 1])
- _lower = _mid + 2;
- else {
- _trans += ((_mid - _keys) >> 1);
- break _match;
- }
- }
- _trans += _klen;
- }
- } while (false);
-
- _trans = _snakeyaml_indicies[_trans];
- cs = _snakeyaml_trans_targs[_trans];
-
- case 2:
- if (cs == 0) {
- _goto_targ = 5;
- continue _goto;
- }
- if (++p != pe) {
- _goto_targ = 1;
- continue _goto;
- }
- case 4:
- if (p == eof) {
- int __acts = _snakeyaml_eof_actions[cs];
- int __nacts = (int) _snakeyaml_actions[__acts++];
- while (__nacts-- > 0) {
- switch (_snakeyaml_actions[__acts++]) {
- case 0:
- // line 14 "RagelMachine.rl"
- {
- tag = "tag:yaml.org,2002:bool";
- }
- break;
- case 1:
- // line 15 "RagelMachine.rl"
- {
- tag = "tag:yaml.org,2002:merge";
- }
- break;
- case 2:
- // line 16 "RagelMachine.rl"
- {
- tag = "tag:yaml.org,2002:null";
- }
- break;
- case 3:
- // line 17 "RagelMachine.rl"
- {
- tag = "tag:yaml.org,2002:value";
- }
- break;
- case 4:
- // line 18 "RagelMachine.rl"
- {
- tag = "tag:yaml.org,2002:int";
- }
- break;
- case 5:
- // line 19 "RagelMachine.rl"
- {
- tag = "tag:yaml.org,2002:float";
- }
- break;
- case 6:
- // line 20 "RagelMachine.rl"
- {
- tag = "tag:yaml.org,2002:timestamp";
- }
- break;
- // line 377 "RagelMachine.java"
- }
- }
- }
-
- case 5:
- }
- break;
- }
- }
- // line 77 "RagelMachine.rl"
-
- return tag;
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.
+ */
+
+// line 1 "RagelMachine.rl"
+package org.yaml.snakeyaml.resolver;
+
+//Source for Ragel 6.3
+
+/**
+ * Generated by Ragel 6.3 (http://www.complang.org/ragel/)
+ *
+ * @see http://www.complang.org/ragel/
+ */
+public class RagelMachine {
+
+ // line 15 "RagelMachine.java"
+ private static byte[] init__snakeyaml_actions_0() {
+ return new byte[] { 0, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6 };
+ }
+
+ private static final byte _snakeyaml_actions[] = init__snakeyaml_actions_0();
+
+ private static short[] init__snakeyaml_key_offsets_0() {
+ return new short[] { 0, 0, 20, 24, 28, 30, 32, 34, 35, 36, 37, 42, 46, 50, 52, 56, 59, 66,
+ 70, 74, 80, 82, 83, 84, 85, 87, 90, 92, 98, 102, 105, 106, 108, 110, 111, 113, 115,
+ 120, 122, 124, 126, 130, 132, 133, 135, 141, 147, 152, 157, 158, 160, 161, 162,
+ 163, 164, 165, 166, 170, 171, 172, 173, 174, 178, 179, 180, 182, 183, 184, 186,
+ 187, 188, 189, 191, 193, 194, 195, 195, 200, 202, 202, 211, 218, 224, 227, 234,
+ 239, 243, 245, 250, 253, 254, 263, 270, 277, 285, 291, 294, 295, 295, 302, 306,
+ 311, 316, 321, 327, 327, 327 };
+ }
+
+ private static final short _snakeyaml_key_offsets[] = init__snakeyaml_key_offsets_0();
+
+ private static char[] init__snakeyaml_trans_keys_0() {
+ return new char[] { 32, 43, 45, 46, 48, 60, 61, 70, 78, 79, 84, 89, 102, 110, 111, 116,
+ 121, 126, 49, 57, 46, 48, 49, 57, 73, 105, 48, 57, 43, 45, 48, 57, 78, 110, 70,
+ 102, 110, 46, 58, 95, 48, 57, 48, 53, 54, 57, 46, 58, 48, 57, 46, 58, 46, 95, 48,
+ 57, 95, 48, 49, 95, 48, 57, 65, 70, 97, 102, 48, 53, 54, 57, 48, 53, 54, 57, 73,
+ 78, 105, 110, 48, 57, 65, 97, 78, 97, 110, 48, 57, 45, 48, 57, 48, 57, 9, 32, 84,
+ 116, 48, 57, 9, 32, 48, 57, 58, 48, 57, 58, 48, 57, 48, 57, 58, 48, 57, 48, 57, 9,
+ 32, 43, 45, 90, 48, 57, 48, 57, 48, 57, 9, 32, 84, 116, 48, 57, 45, 48, 57, 9, 32,
+ 84, 116, 48, 57, 45, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57,
+ 60, 65, 97, 76, 83, 69, 108, 115, 101, 79, 85, 111, 117, 76, 76, 108, 108, 70, 78,
+ 102, 110, 70, 102, 82, 114, 85, 117, 69, 101, 83, 115, 97, 111, 117, 102, 110, 114,
+ 101, 69, 95, 101, 48, 57, 48, 57, 46, 58, 95, 98, 120, 48, 55, 56, 57, 46, 58, 95,
+ 48, 55, 56, 57, 46, 95, 48, 55, 56, 57, 95, 48, 49, 95, 48, 57, 65, 70, 97, 102,
+ 46, 58, 95, 48, 57, 46, 58, 48, 57, 46, 58, 46, 58, 95, 48, 57, 58, 48, 57, 58, 46,
+ 58, 95, 98, 120, 48, 55, 56, 57, 46, 58, 95, 48, 55, 56, 57, 46, 58, 95, 48, 55,
+ 56, 57, 45, 46, 58, 95, 48, 55, 56, 57, 9, 32, 43, 45, 46, 90, 58, 48, 57, 58, 9,
+ 32, 43, 45, 90, 48, 57, 9, 32, 84, 116, 46, 58, 95, 48, 57, 46, 58, 95, 48, 57, 46,
+ 58, 95, 48, 57, 45, 46, 58, 95, 48, 57, 0 };
+ }
+
+ private static final char _snakeyaml_trans_keys[] = init__snakeyaml_trans_keys_0();
+
+ private static byte[] init__snakeyaml_single_lengths_0() {
+ return new byte[] { 0, 18, 2, 2, 2, 0, 2, 1, 1, 1, 3, 0, 2, 2, 2, 1, 1, 0, 0, 4, 2, 1, 1,
+ 1, 0, 1, 0, 4, 2, 1, 1, 0, 0, 1, 0, 0, 5, 0, 0, 0, 4, 0, 1, 0, 4, 4, 3, 3, 1, 2, 1,
+ 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 4, 1, 1, 2, 1, 1, 2, 1, 1, 1, 2, 2, 1, 1, 0, 3, 0, 0,
+ 5, 3, 2, 1, 1, 3, 2, 2, 3, 1, 1, 5, 3, 3, 4, 6, 1, 1, 0, 5, 4, 3, 3, 3, 4, 0, 0, 0 };
+ }
+
+ private static final byte _snakeyaml_single_lengths[] = init__snakeyaml_single_lengths_0();
+
+ private static byte[] init__snakeyaml_range_lengths_0() {
+ return new byte[] { 0, 1, 1, 1, 0, 1, 0, 0, 0, 0, 1, 2, 1, 0, 1, 1, 3, 2, 2, 1, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 2,
+ 2, 2, 1, 3, 1, 1, 0, 1, 1, 0, 2, 2, 2, 2, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 0, 0 };
+ }
+
+ private static final byte _snakeyaml_range_lengths[] = init__snakeyaml_range_lengths_0();
+
+ private static short[] init__snakeyaml_index_offsets_0() {
+ return new short[] { 0, 0, 20, 24, 28, 31, 33, 36, 38, 40, 42, 47, 50, 54, 57, 61, 64, 69,
+ 72, 75, 81, 84, 86, 88, 90, 92, 95, 97, 103, 107, 110, 112, 114, 116, 118, 120,
+ 122, 128, 130, 132, 134, 139, 141, 143, 145, 151, 157, 162, 167, 169, 172, 174,
+ 176, 178, 180, 182, 184, 189, 191, 193, 195, 197, 202, 204, 206, 209, 211, 213,
+ 216, 218, 220, 222, 225, 228, 230, 232, 233, 238, 240, 241, 249, 255, 260, 263,
+ 268, 273, 277, 280, 285, 288, 290, 298, 304, 310, 317, 324, 327, 329, 330, 337,
+ 342, 347, 352, 357, 363, 364, 365 };
+ }
+
+ private static final short _snakeyaml_index_offsets[] = init__snakeyaml_index_offsets_0();
+
+ private static byte[] init__snakeyaml_indicies_0() {
+ return new byte[] { 0, 2, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 5, 1, 18,
+ 19, 20, 1, 22, 23, 21, 1, 24, 24, 1, 25, 1, 26, 27, 1, 28, 1, 28, 1, 27, 1, 21, 30,
+ 31, 29, 1, 32, 33, 1, 25, 30, 33, 1, 25, 30, 1, 21, 31, 31, 1, 34, 34, 1, 35, 35,
+ 35, 35, 1, 36, 37, 1, 38, 39, 1, 22, 40, 23, 41, 21, 1, 42, 42, 1, 28, 1, 43, 1,
+ 28, 1, 44, 1, 45, 46, 1, 47, 1, 48, 48, 50, 50, 49, 1, 48, 48, 51, 1, 53, 52, 1,
+ 53, 1, 54, 1, 55, 1, 56, 1, 57, 1, 58, 1, 59, 59, 60, 60, 61, 1, 62, 1, 63, 1, 61,
+ 1, 48, 48, 50, 50, 1, 51, 1, 64, 1, 65, 1, 48, 48, 50, 50, 66, 1, 67, 21, 30, 31,
+ 29, 1, 21, 30, 31, 68, 1, 21, 30, 31, 69, 1, 70, 1, 71, 72, 1, 73, 1, 74, 1, 75, 1,
+ 76, 1, 77, 1, 75, 1, 75, 78, 75, 79, 1, 80, 1, 0, 1, 81, 1, 0, 1, 82, 75, 83, 75,
+ 1, 75, 1, 75, 1, 84, 85, 1, 74, 1, 77, 1, 86, 87, 1, 75, 1, 75, 1, 72, 1, 75, 79,
+ 1, 83, 75, 1, 85, 1, 87, 1, 1, 88, 21, 88, 21, 1, 25, 1, 1, 21, 30, 90, 91, 92, 89,
+ 29, 1, 21, 30, 90, 89, 29, 1, 21, 90, 90, 31, 1, 34, 34, 1, 35, 35, 35, 35, 1, 21,
+ 93, 94, 20, 1, 25, 93, 37, 1, 25, 93, 1, 21, 95, 94, 94, 1, 95, 39, 1, 95, 1, 21,
+ 30, 90, 91, 92, 96, 97, 1, 21, 30, 90, 98, 69, 1, 21, 30, 90, 99, 68, 1, 67, 21,
+ 30, 90, 89, 29, 1, 59, 59, 60, 60, 100, 61, 1, 102, 101, 1, 102, 1, 1, 59, 59, 60,
+ 60, 61, 100, 1, 48, 48, 50, 50, 1, 21, 93, 94, 103, 1, 21, 93, 94, 104, 1, 21, 93,
+ 94, 105, 1, 67, 21, 93, 94, 20, 1, 1, 1, 1, 0 };
+ }
+
+ private static final byte _snakeyaml_indicies[] = init__snakeyaml_indicies_0();
+
+ private static byte[] init__snakeyaml_trans_targs_0() {
+ return new byte[] { 75, 0, 2, 19, 90, 100, 48, 105, 49, 56, 61, 64, 67, 70, 71, 72, 73, 74,
+ 3, 79, 84, 76, 6, 9, 5, 77, 7, 8, 78, 10, 11, 14, 12, 13, 82, 83, 85, 86, 88, 89,
+ 20, 22, 21, 23, 25, 26, 42, 27, 28, 40, 41, 29, 30, 31, 32, 33, 34, 35, 94, 36, 37,
+ 97, 95, 39, 43, 44, 99, 24, 45, 46, 104, 50, 53, 51, 52, 106, 54, 55, 57, 59, 58,
+ 60, 62, 63, 65, 66, 68, 69, 4, 80, 81, 15, 16, 17, 87, 18, 91, 47, 92, 93, 98, 96,
+ 38, 101, 102, 103 };
+ }
+
+ private static final byte _snakeyaml_trans_targs[] = init__snakeyaml_trans_targs_0();
+
+ // private static byte[] init__snakeyaml_trans_actions_0() {
+ // return new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ // 0, 0, 0, 0, 0, 0,
+ // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ // 0, 0, 0, 0,
+ // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ // 0, 0, 0, 0,
+ // 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ // 0, 0 };
+ // }
+
+ // private static final byte _snakeyaml_trans_actions[] =
+ // init__snakeyaml_trans_actions_0();
+
+ private static byte[] init__snakeyaml_eof_actions_0() {
+ return new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 11, 11, 11,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 13, 13, 13, 13, 13, 13, 9, 9, 9, 9, 3,
+ 7, 1 };
+ }
+
+ private static final byte _snakeyaml_eof_actions[] = init__snakeyaml_eof_actions_0();
+
+ static final int snakeyaml_start = 1;
+ static final int snakeyaml_error = 0;
+
+ static final int snakeyaml_en_main = 1;
+
+ // line 53 "RagelMachine.rl"
+
+ public String scan(String scalar) {
+ if (scalar == null) {
+ throw new NullPointerException("Scalar must be provided.");
+ }
+ String tag = null;
+ int cs = 0;
+ int p = 0;
+ int pe = scalar.length();
+ int eof = pe;
+ char[] data;
+ if (pe == 0) {
+ // NULL value
+ data = new char[] { '~' };
+ pe = 1;
+ eof = 1;
+ } else {
+ data = scalar.toCharArray();
+ }
+
+ // line 257 "RagelMachine.java"
+ {
+ cs = snakeyaml_start;
+ }
+
+ // line 262 "RagelMachine.java"
+ {
+ int _klen;
+ int _trans = 0;
+ int _keys;
+ int _goto_targ = 0;
+
+ _goto: while (true) {
+ switch (_goto_targ) {
+ case 0:
+ if (p == pe) {
+ _goto_targ = 4;
+ continue _goto;
+ }
+ if (cs == 0) {
+ _goto_targ = 5;
+ continue _goto;
+ }
+ case 1:
+ _match: do {
+ _keys = _snakeyaml_key_offsets[cs];
+ _trans = _snakeyaml_index_offsets[cs];
+ _klen = _snakeyaml_single_lengths[cs];
+ if (_klen > 0) {
+ int _lower = _keys;
+ int _mid;
+ int _upper = _keys + _klen - 1;
+ while (true) {
+ if (_upper < _lower)
+ break;
+
+ _mid = _lower + ((_upper - _lower) >> 1);
+ if (data[p] < _snakeyaml_trans_keys[_mid])
+ _upper = _mid - 1;
+ else if (data[p] > _snakeyaml_trans_keys[_mid])
+ _lower = _mid + 1;
+ else {
+ _trans += (_mid - _keys);
+ break _match;
+ }
+ }
+ _keys += _klen;
+ _trans += _klen;
+ }
+
+ _klen = _snakeyaml_range_lengths[cs];
+ if (_klen > 0) {
+ int _lower = _keys;
+ int _mid;
+ int _upper = _keys + (_klen << 1) - 2;
+ while (true) {
+ if (_upper < _lower)
+ break;
+
+ _mid = _lower + (((_upper - _lower) >> 1) & ~1);
+ if (data[p] < _snakeyaml_trans_keys[_mid])
+ _upper = _mid - 2;
+ else if (data[p] > _snakeyaml_trans_keys[_mid + 1])
+ _lower = _mid + 2;
+ else {
+ _trans += ((_mid - _keys) >> 1);
+ break _match;
+ }
+ }
+ _trans += _klen;
+ }
+ } while (false);
+
+ _trans = _snakeyaml_indicies[_trans];
+ cs = _snakeyaml_trans_targs[_trans];
+
+ case 2:
+ if (cs == 0) {
+ _goto_targ = 5;
+ continue _goto;
+ }
+ if (++p != pe) {
+ _goto_targ = 1;
+ continue _goto;
+ }
+ case 4:
+ if (p == eof) {
+ int __acts = _snakeyaml_eof_actions[cs];
+ int __nacts = (int) _snakeyaml_actions[__acts++];
+ while (__nacts-- > 0) {
+ switch (_snakeyaml_actions[__acts++]) {
+ case 0:
+ // line 14 "RagelMachine.rl"
+ {
+ tag = "tag:yaml.org,2002:bool";
+ }
+ break;
+ case 1:
+ // line 15 "RagelMachine.rl"
+ {
+ tag = "tag:yaml.org,2002:merge";
+ }
+ break;
+ case 2:
+ // line 16 "RagelMachine.rl"
+ {
+ tag = "tag:yaml.org,2002:null";
+ }
+ break;
+ case 3:
+ // line 17 "RagelMachine.rl"
+ {
+ tag = "tag:yaml.org,2002:value";
+ }
+ break;
+ case 4:
+ // line 18 "RagelMachine.rl"
+ {
+ tag = "tag:yaml.org,2002:int";
+ }
+ break;
+ case 5:
+ // line 19 "RagelMachine.rl"
+ {
+ tag = "tag:yaml.org,2002:float";
+ }
+ break;
+ case 6:
+ // line 20 "RagelMachine.rl"
+ {
+ tag = "tag:yaml.org,2002:timestamp";
+ }
+ break;
+ // line 377 "RagelMachine.java"
+ }
+ }
+ }
+
+ case 5:
+ }
+ break;
+ }
+ }
+ // line 77 "RagelMachine.rl"
+
+ return tag;
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/resolver/RagelMachineTest.java b/src/test/java/org/yaml/snakeyaml/resolver/RagelMachineTest.java
index 267c9a1..3c2d85f 100644
--- a/src/test/java/org/yaml/snakeyaml/resolver/RagelMachineTest.java
+++ b/src/test/java/org/yaml/snakeyaml/resolver/RagelMachineTest.java
@@ -1,120 +1,120 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.resolver;
-
-import junit.framework.TestCase;
-
-public class RagelMachineTest extends TestCase {
- private RagelMachine machine = new RagelMachine();
-
- public void testScan() {
- assertNull(machine.scan("abc"));
- }
-
- public void testNullPointerException() {
- try {
- machine.scan(null);
- fail("null must not be accepted.");
- } catch (NullPointerException e) {
- assertEquals("Scalar must be provided.", e.getMessage());
- }
- }
-
- public void testScanBoolean() {
- assertEquals("tag:yaml.org,2002:bool", machine.scan("true"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("True"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("TRUE"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("false"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("False"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("FALSE"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("on"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("ON"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("On"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("off"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("Off"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("OFF"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("on"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("ON"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("On"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("off"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("Off"));
- assertEquals("tag:yaml.org,2002:bool", machine.scan("OFF"));
- }
-
- public void testScanNull() {
- assertEquals("tag:yaml.org,2002:null", machine.scan("null"));
- assertEquals("tag:yaml.org,2002:null", machine.scan("Null"));
- assertEquals("tag:yaml.org,2002:null", machine.scan("NULL"));
- assertEquals("tag:yaml.org,2002:null", machine.scan("~"));
- assertEquals("tag:yaml.org,2002:null", machine.scan(" "));
- assertEquals("tag:yaml.org,2002:null", machine.scan(""));
- }
-
- public void testScanMerge() {
- assertEquals("tag:yaml.org,2002:merge", machine.scan("<<"));
- }
-
- public void testScanValue() {
- assertEquals("tag:yaml.org,2002:value", machine.scan("="));
- }
-
- public void testScanInt() {
- assertEquals("tag:yaml.org,2002:int", machine.scan("0"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("1"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("-0"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("-9"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("0b0011"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("0x12ef"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("0123"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("1_000"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("1_000_000"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("+0"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("+10"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("1__000"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("24:12:34"));
- assertEquals("tag:yaml.org,2002:int", machine.scan("240:12:34"));
- }
-
- public void testScanFloat() {
- assertEquals("tag:yaml.org,2002:float", machine.scan("1.0"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("-0.0"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("+2.2310"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("1.0e+12"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("1.345e-3"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("190:20:30.15"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("-.inf"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("+.INF"));
- assertEquals("tag:yaml.org,2002:float", machine.scan(".Inf"));
- assertEquals("tag:yaml.org,2002:float", machine.scan(".nan"));
- assertEquals("tag:yaml.org,2002:float", machine.scan(".NaN"));
- assertEquals("tag:yaml.org,2002:float", machine.scan(".NAN"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("1_000.5"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("1.023_456"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("-1_123.45"));
- assertEquals("tag:yaml.org,2002:float", machine.scan(".5"));
- assertEquals("tag:yaml.org,2002:float", machine.scan("1.E+1"));
- assertNull(machine.scan("0x1,1"), machine.scan("0x1,1"));
- }
-
- public void testScanTimestamp() {
- assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2009-02-28"));
- assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-15T02:59:43.1Z"));
- assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-14t21:59:43.10-05:00"));
- assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-14 21:59:43.10 -5"));
- assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-15 2:59:43.10"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.resolver;
+
+import junit.framework.TestCase;
+
+public class RagelMachineTest extends TestCase {
+ private RagelMachine machine = new RagelMachine();
+
+ public void testScan() {
+ assertNull(machine.scan("abc"));
+ }
+
+ public void testNullPointerException() {
+ try {
+ machine.scan(null);
+ fail("null must not be accepted.");
+ } catch (NullPointerException e) {
+ assertEquals("Scalar must be provided.", e.getMessage());
+ }
+ }
+
+ public void testScanBoolean() {
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("true"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("True"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("TRUE"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("false"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("False"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("FALSE"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("on"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("ON"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("On"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("off"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("Off"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("OFF"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("on"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("ON"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("On"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("off"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("Off"));
+ assertEquals("tag:yaml.org,2002:bool", machine.scan("OFF"));
+ }
+
+ public void testScanNull() {
+ assertEquals("tag:yaml.org,2002:null", machine.scan("null"));
+ assertEquals("tag:yaml.org,2002:null", machine.scan("Null"));
+ assertEquals("tag:yaml.org,2002:null", machine.scan("NULL"));
+ assertEquals("tag:yaml.org,2002:null", machine.scan("~"));
+ assertEquals("tag:yaml.org,2002:null", machine.scan(" "));
+ assertEquals("tag:yaml.org,2002:null", machine.scan(""));
+ }
+
+ public void testScanMerge() {
+ assertEquals("tag:yaml.org,2002:merge", machine.scan("<<"));
+ }
+
+ public void testScanValue() {
+ assertEquals("tag:yaml.org,2002:value", machine.scan("="));
+ }
+
+ public void testScanInt() {
+ assertEquals("tag:yaml.org,2002:int", machine.scan("0"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("1"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("-0"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("-9"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("0b0011"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("0x12ef"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("0123"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("1_000"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("1_000_000"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("+0"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("+10"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("1__000"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("24:12:34"));
+ assertEquals("tag:yaml.org,2002:int", machine.scan("240:12:34"));
+ }
+
+ public void testScanFloat() {
+ assertEquals("tag:yaml.org,2002:float", machine.scan("1.0"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("-0.0"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("+2.2310"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("1.0e+12"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("1.345e-3"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("190:20:30.15"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("-.inf"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("+.INF"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan(".Inf"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan(".nan"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan(".NaN"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan(".NAN"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("1_000.5"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("1.023_456"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("-1_123.45"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan(".5"));
+ assertEquals("tag:yaml.org,2002:float", machine.scan("1.E+1"));
+ assertNull(machine.scan("0x1,1"), machine.scan("0x1,1"));
+ }
+
+ public void testScanTimestamp() {
+ assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2009-02-28"));
+ assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-15T02:59:43.1Z"));
+ assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-14t21:59:43.10-05:00"));
+ assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-14 21:59:43.10 -5"));
+ assertEquals("tag:yaml.org,2002:timestamp", machine.scan("2001-12-15 2:59:43.10"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java b/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java
index 490cd8c..c73b919 100644
--- a/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java
+++ b/src/test/java/org/yaml/snakeyaml/resolver/ResolverTest.java
@@ -1,163 +1,163 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.resolver;
-
-import java.awt.Point;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.AbstractConstruct;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Represent;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class ResolverTest extends TestCase {
-
- @SuppressWarnings("unchecked")
- public void testAddImplicitResolver() {
- Yaml yaml = new Yaml(new MyConstructor(), new MyRepresenter());
- Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
- yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "0123456789");
- Phone phone1 = new Phone("12-34-567");
- Phone phone2 = new Phone("11-22-333");
- Phone phone3 = new Phone("44-55-777");
- List<Phone> etalonList = new ArrayList<Phone>();
- etalonList.add(phone1);
- etalonList.add(phone2);
- etalonList.add(phone3);
- String output = yaml.dump(etalonList);
- assertEquals("[12-34-567, 11-22-333, 44-55-777]\n", output);
- List<Phone> parsedList = (List<Phone>) yaml.load(output);
- assertEquals(3, parsedList.size());
- assertEquals(phone1, parsedList.get(0));
- assertEquals(phone2, parsedList.get(1));
- assertEquals(phone3, parsedList.get(2));
- assertEquals(etalonList, parsedList);
- }
-
- public void testAddImplicitResolver2() {
- Yaml yaml = new Yaml(new PointRepresenter());
- Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
- yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "\0");
- Pattern regexp2 = Pattern.compile("x\\d_y\\d");
- // try any scalar, and not only those which start with 'x'
- yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Point"), regexp2, null);
- Map<String, Object> map = new LinkedHashMap<String, Object>();
- map.put("a", new Phone("12-34-567"));
- map.put("b", new Point(1, 5));
- String output = yaml.dump(map);
- assertEquals("{a: 12-34-567, b: x1_y5}\n", output);
- }
-
- class Phone {
- private String number;
-
- public Phone(String n) {
- this.number = n;
- }
-
- public String getNumber() {
- return number;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof Phone)) {
- return false;
- }
- return toString().equals(obj.toString());
- }
-
- @Override
- public String toString() {
- return "Phone: " + number;
- }
- }
-
- class MyRepresenter extends Representer {
- public MyRepresenter() {
- this.representers.put(Phone.class, new RepresentPhone());
- }
-
- private class RepresentPhone implements Represent {
- public Node representData(Object data) {
- Phone phone = (Phone) data;
- String value = phone.getNumber();
- return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
- }
- }
- }
-
- class MyConstructor extends Constructor {
- public MyConstructor() {
- this.yamlConstructors.put(new Tag(Tag.PREFIX + "Phone"), new ConstructPhone());
- }
-
- private class ConstructPhone extends AbstractConstruct {
- public Object construct(Node node) {
- String val = (String) constructScalar((ScalarNode) node);
- return new Phone(val);
- }
- }
- }
-
- class PointRepresenter extends Representer {
- public PointRepresenter() {
- this.representers.put(Point.class, new RepresentPoint());
- this.representers.put(Phone.class, new RepresentPhone());
- }
-
- private class RepresentPoint implements Represent {
- public Node representData(Object data) {
- Point phone = (Point) data;
- String value = "x" + (int) phone.getX() + "_y" + (int) phone.getY();
- return representScalar(new Tag(Tag.PREFIX + "Point"), value);
- }
- }
-
- private class RepresentPhone implements Represent {
- public Node representData(Object data) {
- Phone phone = (Phone) data;
- String value = phone.getNumber();
- return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
- }
- }
- }
-
- /**
- * Parse scalars as Strings
- */
- @SuppressWarnings({ "unchecked", "deprecation" })
- public void testStringResolver() {
- Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(),
- new Resolver(false));
- List<Object> output = (List<Object>) yaml.load("[ '1.00', 1.00, !!float '1.00' ]");
- assertEquals("1.00", output.get(0));
- assertEquals("1.00", output.get(1));
- assertEquals(1.0, output.get(2));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.resolver;
+
+import java.awt.Point;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.AbstractConstruct;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Represent;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class ResolverTest extends TestCase {
+
+ @SuppressWarnings("unchecked")
+ public void testAddImplicitResolver() {
+ Yaml yaml = new Yaml(new MyConstructor(), new MyRepresenter());
+ Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
+ yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "0123456789");
+ Phone phone1 = new Phone("12-34-567");
+ Phone phone2 = new Phone("11-22-333");
+ Phone phone3 = new Phone("44-55-777");
+ List<Phone> etalonList = new ArrayList<Phone>();
+ etalonList.add(phone1);
+ etalonList.add(phone2);
+ etalonList.add(phone3);
+ String output = yaml.dump(etalonList);
+ assertEquals("[12-34-567, 11-22-333, 44-55-777]\n", output);
+ List<Phone> parsedList = (List<Phone>) yaml.load(output);
+ assertEquals(3, parsedList.size());
+ assertEquals(phone1, parsedList.get(0));
+ assertEquals(phone2, parsedList.get(1));
+ assertEquals(phone3, parsedList.get(2));
+ assertEquals(etalonList, parsedList);
+ }
+
+ public void testAddImplicitResolver2() {
+ Yaml yaml = new Yaml(new PointRepresenter());
+ Pattern regexp = Pattern.compile("\\d\\d-\\d\\d-\\d\\d\\d");
+ yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Phone"), regexp, "\0");
+ Pattern regexp2 = Pattern.compile("x\\d_y\\d");
+ // try any scalar, and not only those which start with 'x'
+ yaml.addImplicitResolver(new Tag(Tag.PREFIX + "Point"), regexp2, null);
+ Map<String, Object> map = new LinkedHashMap<String, Object>();
+ map.put("a", new Phone("12-34-567"));
+ map.put("b", new Point(1, 5));
+ String output = yaml.dump(map);
+ assertEquals("{a: 12-34-567, b: x1_y5}\n", output);
+ }
+
+ class Phone {
+ private String number;
+
+ public Phone(String n) {
+ this.number = n;
+ }
+
+ public String getNumber() {
+ return number;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof Phone)) {
+ return false;
+ }
+ return toString().equals(obj.toString());
+ }
+
+ @Override
+ public String toString() {
+ return "Phone: " + number;
+ }
+ }
+
+ class MyRepresenter extends Representer {
+ public MyRepresenter() {
+ this.representers.put(Phone.class, new RepresentPhone());
+ }
+
+ private class RepresentPhone implements Represent {
+ public Node representData(Object data) {
+ Phone phone = (Phone) data;
+ String value = phone.getNumber();
+ return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
+ }
+ }
+ }
+
+ class MyConstructor extends Constructor {
+ public MyConstructor() {
+ this.yamlConstructors.put(new Tag(Tag.PREFIX + "Phone"), new ConstructPhone());
+ }
+
+ private class ConstructPhone extends AbstractConstruct {
+ public Object construct(Node node) {
+ String val = (String) constructScalar((ScalarNode) node);
+ return new Phone(val);
+ }
+ }
+ }
+
+ class PointRepresenter extends Representer {
+ public PointRepresenter() {
+ this.representers.put(Point.class, new RepresentPoint());
+ this.representers.put(Phone.class, new RepresentPhone());
+ }
+
+ private class RepresentPoint implements Represent {
+ public Node representData(Object data) {
+ Point phone = (Point) data;
+ String value = "x" + (int) phone.getX() + "_y" + (int) phone.getY();
+ return representScalar(new Tag(Tag.PREFIX + "Point"), value);
+ }
+ }
+
+ private class RepresentPhone implements Represent {
+ public Node representData(Object data) {
+ Phone phone = (Phone) data;
+ String value = phone.getNumber();
+ return representScalar(new Tag(Tag.PREFIX + "Phone"), value);
+ }
+ }
+ }
+
+ /**
+ * Parse scalars as Strings
+ */
+ @SuppressWarnings({ "unchecked", "deprecation" })
+ public void testStringResolver() {
+ Yaml yaml = new Yaml(new Constructor(), new Representer(), new DumperOptions(),
+ new Resolver(false));
+ List<Object> output = (List<Object>) yaml.load("[ '1.00', 1.00, !!float '1.00' ]");
+ assertEquals("1.00", output.get(0));
+ assertEquals("1.00", output.get(1));
+ assertEquals(1.0, output.get(2));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/resolver/ResolverTupleTest.java b/src/test/java/org/yaml/snakeyaml/resolver/ResolverTupleTest.java
index 2185a8b..89ec04e 100644
--- a/src/test/java/org/yaml/snakeyaml/resolver/ResolverTupleTest.java
+++ b/src/test/java/org/yaml/snakeyaml/resolver/ResolverTupleTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.resolver;
-
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.nodes.Tag;
-
-public class ResolverTupleTest extends TestCase {
-
- public void testToString() {
- ResolverTuple tuple = new ResolverTuple(new Tag("dice"), Pattern.compile("\\d+"));
- assertEquals("Tuple tag=dice regexp=\\d+", tuple.toString());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.resolver;
+
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class ResolverTupleTest extends TestCase {
+
+ public void testToString() {
+ ResolverTuple tuple = new ResolverTuple(new Tag("dice"), Pattern.compile("\\d+"));
+ assertEquals("Tuple tag=dice regexp=\\d+", tuple.toString());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java b/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java
index 4f19a80..11fb26f 100644
--- a/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java
+++ b/src/test/java/org/yaml/snakeyaml/ruby/RubyTest.java
@@ -1,114 +1,114 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.ruby;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.TypeDescription;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Representer;
-
-public class RubyTest extends TestCase {
-
- public void testParse() {
- TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
- assertNotNull(result);
- assertEquals(0, result.getSub1().getAtt2());
- assertEquals("MyString", result.getSub2().getAtt1());
- assertEquals(1, result.getSub2().getAtt2().size());
- assertEquals(12345, result.getSub2().getAtt3());
- }
-
- public void testEmitNoTags() {
- TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
- DumperOptions options = new DumperOptions();
- options.setExplicitStart(true);
- Yaml yaml2 = new Yaml(options);
- String output = yaml2.dumpAsMap(result);
- assertFalse("No tags expected.", output.contains("Sub1"));
- // System.out.println(output);
- // parse back. Without tags it shall still work
- Yaml beanLoader = new Yaml();
- TestObject result2 = beanLoader.loadAs(output, TestObject.class);
- assertEquals(0, result2.getSub1().getAtt2());
- assertEquals("MyString", result2.getSub2().getAtt1());
- assertEquals(1, result2.getSub2().getAtt2().size());
- assertEquals(12345, result2.getSub2().getAtt3());
- }
-
- public void testEmitWithTags() {
- TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
- DumperOptions options = new DumperOptions();
- options.setExplicitStart(true);
- Representer repr = new Representer();
- repr.addClassTag(TestObject.class, new Tag("!ruby/object:Test::Module::Object"));
- repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
- repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
- Yaml yaml2 = new Yaml(repr, options);
- String output = yaml2.dump(result);
- // System.out.println(output);
- assertTrue("Tags must be present.",
- output.startsWith("--- !ruby/object:Test::Module::Object"));
- assertTrue("Tags must be present: " + output,
- output.contains("!ruby/object:Test::Module::Sub1"));
- assertTrue("Tags must be present.", output.contains("!ruby/object:Test::Module::Sub2"));
- // parse back.
- TestObject result2 = parseObject(output);
- assertEquals(0, result2.getSub1().getAtt2());
- assertEquals("MyString", result2.getSub2().getAtt1());
- assertEquals(1, result2.getSub2().getAtt2().size());
- assertEquals(12345, result2.getSub2().getAtt3());
- }
-
- public void testEmitWithTags2WithoutTagForParentJavabean() {
- TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
- DumperOptions options = new DumperOptions();
- options.setExplicitStart(true);
- Representer repr = new Representer();
- repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
- repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
- Yaml yaml2 = new Yaml(repr, options);
- String output = yaml2.dump(result);
- // System.out.println(output);
- assertTrue("Tags must be present.",
- output.startsWith("--- !!org.yaml.snakeyaml.ruby.TestObject"));
- assertTrue("Tags must be present: " + output,
- output.contains("!ruby/object:Test::Module::Sub1"));
- assertTrue("Tags must be present.", output.contains("!ruby/object:Test::Module::Sub2"));
- // parse back.
- TestObject result2 = parseObject(output);
- assertEquals(0, result2.getSub1().getAtt2());
- assertEquals("MyString", result2.getSub2().getAtt1());
- assertEquals(1, result2.getSub2().getAtt2().size());
- assertEquals(12345, result2.getSub2().getAtt3());
- }
-
- private TestObject parseObject(String input) {
- Constructor con = new Constructor(TestObject.class);
- con.addTypeDescription(new TypeDescription(TestObject.class,
- "!ruby/object:Test::Module::Object"));
- con.addTypeDescription(new TypeDescription(Sub1.class, "!ruby/object:Test::Module::Sub1"));
- con.addTypeDescription(new TypeDescription(Sub2.class, "!ruby/object:Test::Module::Sub2"));
-
- Yaml yaml = new Yaml(con);
- return (TestObject) yaml.load(input);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.ruby;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Representer;
+
+public class RubyTest extends TestCase {
+
+ public void testParse() {
+ TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
+ assertNotNull(result);
+ assertEquals(0, result.getSub1().getAtt2());
+ assertEquals("MyString", result.getSub2().getAtt1());
+ assertEquals(1, result.getSub2().getAtt2().size());
+ assertEquals(12345, result.getSub2().getAtt3());
+ }
+
+ public void testEmitNoTags() {
+ TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
+ DumperOptions options = new DumperOptions();
+ options.setExplicitStart(true);
+ Yaml yaml2 = new Yaml(options);
+ String output = yaml2.dumpAsMap(result);
+ assertFalse("No tags expected.", output.contains("Sub1"));
+ // System.out.println(output);
+ // parse back. Without tags it shall still work
+ Yaml beanLoader = new Yaml();
+ TestObject result2 = beanLoader.loadAs(output, TestObject.class);
+ assertEquals(0, result2.getSub1().getAtt2());
+ assertEquals("MyString", result2.getSub2().getAtt1());
+ assertEquals(1, result2.getSub2().getAtt2().size());
+ assertEquals(12345, result2.getSub2().getAtt3());
+ }
+
+ public void testEmitWithTags() {
+ TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
+ DumperOptions options = new DumperOptions();
+ options.setExplicitStart(true);
+ Representer repr = new Representer();
+ repr.addClassTag(TestObject.class, new Tag("!ruby/object:Test::Module::Object"));
+ repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
+ repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
+ Yaml yaml2 = new Yaml(repr, options);
+ String output = yaml2.dump(result);
+ // System.out.println(output);
+ assertTrue("Tags must be present.",
+ output.startsWith("--- !ruby/object:Test::Module::Object"));
+ assertTrue("Tags must be present: " + output,
+ output.contains("!ruby/object:Test::Module::Sub1"));
+ assertTrue("Tags must be present.", output.contains("!ruby/object:Test::Module::Sub2"));
+ // parse back.
+ TestObject result2 = parseObject(output);
+ assertEquals(0, result2.getSub1().getAtt2());
+ assertEquals("MyString", result2.getSub2().getAtt1());
+ assertEquals(1, result2.getSub2().getAtt2().size());
+ assertEquals(12345, result2.getSub2().getAtt3());
+ }
+
+ public void testEmitWithTags2WithoutTagForParentJavabean() {
+ TestObject result = parseObject(Util.getLocalResource("ruby/ruby1.yaml"));
+ DumperOptions options = new DumperOptions();
+ options.setExplicitStart(true);
+ Representer repr = new Representer();
+ repr.addClassTag(Sub1.class, new Tag("!ruby/object:Test::Module::Sub1"));
+ repr.addClassTag(Sub2.class, new Tag("!ruby/object:Test::Module::Sub2"));
+ Yaml yaml2 = new Yaml(repr, options);
+ String output = yaml2.dump(result);
+ // System.out.println(output);
+ assertTrue("Tags must be present.",
+ output.startsWith("--- !!org.yaml.snakeyaml.ruby.TestObject"));
+ assertTrue("Tags must be present: " + output,
+ output.contains("!ruby/object:Test::Module::Sub1"));
+ assertTrue("Tags must be present.", output.contains("!ruby/object:Test::Module::Sub2"));
+ // parse back.
+ TestObject result2 = parseObject(output);
+ assertEquals(0, result2.getSub1().getAtt2());
+ assertEquals("MyString", result2.getSub2().getAtt1());
+ assertEquals(1, result2.getSub2().getAtt2().size());
+ assertEquals(12345, result2.getSub2().getAtt3());
+ }
+
+ private TestObject parseObject(String input) {
+ Constructor con = new Constructor(TestObject.class);
+ con.addTypeDescription(new TypeDescription(TestObject.class,
+ "!ruby/object:Test::Module::Object"));
+ con.addTypeDescription(new TypeDescription(Sub1.class, "!ruby/object:Test::Module::Sub1"));
+ con.addTypeDescription(new TypeDescription(Sub2.class, "!ruby/object:Test::Module::Sub2"));
+
+ Yaml yaml = new Yaml(con);
+ return (TestObject) yaml.load(input);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/ruby/Sub1.java b/src/test/java/org/yaml/snakeyaml/ruby/Sub1.java
index 25eed82..6be8f62 100644
--- a/src/test/java/org/yaml/snakeyaml/ruby/Sub1.java
+++ b/src/test/java/org/yaml/snakeyaml/ruby/Sub1.java
@@ -1,49 +1,49 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.ruby;
-
-import java.util.List;
-
-public class Sub1 {
- private List<Integer> att1;
- private int att2;
- private List<Integer> att3;
-
- public List<Integer> getAtt1() {
- return att1;
- }
-
- public void setAtt1(List<Integer> att1) {
- this.att1 = att1;
- }
-
- public int getAtt2() {
- return att2;
- }
-
- public void setAtt2(int att2) {
- this.att2 = att2;
- }
-
- public List<Integer> getAtt3() {
- return att3;
- }
-
- public void setAtt3(List<Integer> att3) {
- this.att3 = att3;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.ruby;
+
+import java.util.List;
+
+public class Sub1 {
+ private List<Integer> att1;
+ private int att2;
+ private List<Integer> att3;
+
+ public List<Integer> getAtt1() {
+ return att1;
+ }
+
+ public void setAtt1(List<Integer> att1) {
+ this.att1 = att1;
+ }
+
+ public int getAtt2() {
+ return att2;
+ }
+
+ public void setAtt2(int att2) {
+ this.att2 = att2;
+ }
+
+ public List<Integer> getAtt3() {
+ return att3;
+ }
+
+ public void setAtt3(List<Integer> att3) {
+ this.att3 = att3;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/ruby/Sub2.java b/src/test/java/org/yaml/snakeyaml/ruby/Sub2.java
index e8427b5..121ceb2 100644
--- a/src/test/java/org/yaml/snakeyaml/ruby/Sub2.java
+++ b/src/test/java/org/yaml/snakeyaml/ruby/Sub2.java
@@ -1,50 +1,50 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.ruby;
-
-import java.util.List;
-
-public class Sub2 {
- private String att1;
- private List<String> att2;
- private int att3;
-
- public String getAtt1() {
- return att1;
- }
-
- public void setAtt1(String att1) {
- this.att1 = att1;
- }
-
- public List<String> getAtt2() {
- return att2;
- }
-
- public void setAtt2(List<String> att2) {
- this.att2 = att2;
- }
-
- public int getAtt3() {
- return att3;
- }
-
- public void setAtt3(int att3) {
- this.att3 = att3;
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.ruby;
+
+import java.util.List;
+
+public class Sub2 {
+ private String att1;
+ private List<String> att2;
+ private int att3;
+
+ public String getAtt1() {
+ return att1;
+ }
+
+ public void setAtt1(String att1) {
+ this.att1 = att1;
+ }
+
+ public List<String> getAtt2() {
+ return att2;
+ }
+
+ public void setAtt2(List<String> att2) {
+ this.att2 = att2;
+ }
+
+ public int getAtt3() {
+ return att3;
+ }
+
+ public void setAtt3(int att3) {
+ this.att3 = att3;
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/ruby/TestObject.java b/src/test/java/org/yaml/snakeyaml/ruby/TestObject.java
index 438c691..c402eaa 100644
--- a/src/test/java/org/yaml/snakeyaml/ruby/TestObject.java
+++ b/src/test/java/org/yaml/snakeyaml/ruby/TestObject.java
@@ -1,38 +1,38 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.ruby;
-
-public class TestObject {
- private Sub1 sub1;
- private Sub2 sub2;
-
- public Sub1 getSub1() {
- return sub1;
- }
-
- public void setSub1(Sub1 sub1) {
- this.sub1 = sub1;
- }
-
- public Sub2 getSub2() {
- return sub2;
- }
-
- public void setSub2(Sub2 sub2) {
- this.sub2 = sub2;
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.ruby;
+
+public class TestObject {
+ private Sub1 sub1;
+ private Sub2 sub2;
+
+ public Sub1 getSub1() {
+ return sub1;
+ }
+
+ public void setSub1(Sub1 sub1) {
+ this.sub1 = sub1;
+ }
+
+ public Sub2 getSub2() {
+ return sub2;
+ }
+
+ public void setSub2(Sub2 sub2) {
+ this.sub2 = sub2;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/scanner/ConstantTest.java b/src/test/java/org/yaml/snakeyaml/scanner/ConstantTest.java
index 6005bb8..f428578 100644
--- a/src/test/java/org/yaml/snakeyaml/scanner/ConstantTest.java
+++ b/src/test/java/org/yaml/snakeyaml/scanner/ConstantTest.java
@@ -1,37 +1,37 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.scanner;
-
-import junit.framework.TestCase;
-
-public class ConstantTest extends TestCase {
-
- public void testHasChar() {
- assertTrue(Constant.LINEBR.has('\n'));
- assertTrue(Constant.LINEBR.has('\u0085'));
- assertFalse(Constant.LINEBR.has(' '));
- }
-
- public void testHasStringChar() {
- assertTrue(Constant.LINEBR.has(' ', " "));
- }
-
- public void testHas0() {
- assertTrue(Constant.LINEBR.has((char) 0, "\0"));
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.scanner;
+
+import junit.framework.TestCase;
+
+public class ConstantTest extends TestCase {
+
+ public void testHasChar() {
+ assertTrue(Constant.LINEBR.has('\n'));
+ assertTrue(Constant.LINEBR.has('\u0085'));
+ assertFalse(Constant.LINEBR.has(' '));
+ }
+
+ public void testHasStringChar() {
+ assertTrue(Constant.LINEBR.has(' ', " "));
+ }
+
+ public void testHas0() {
+ assertTrue(Constant.LINEBR.has((char) 0, "\0"));
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/scanner/ScannerImplTest.java b/src/test/java/org/yaml/snakeyaml/scanner/ScannerImplTest.java
index aabf991..5fa0aaf 100644
--- a/src/test/java/org/yaml/snakeyaml/scanner/ScannerImplTest.java
+++ b/src/test/java/org/yaml/snakeyaml/scanner/ScannerImplTest.java
@@ -1,69 +1,69 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.scanner;
-
-import java.util.LinkedList;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.reader.StreamReader;
-import org.yaml.snakeyaml.tokens.BlockEndToken;
-import org.yaml.snakeyaml.tokens.BlockMappingStartToken;
-import org.yaml.snakeyaml.tokens.KeyToken;
-import org.yaml.snakeyaml.tokens.ScalarToken;
-import org.yaml.snakeyaml.tokens.StreamEndToken;
-import org.yaml.snakeyaml.tokens.StreamStartToken;
-import org.yaml.snakeyaml.tokens.Token;
-import org.yaml.snakeyaml.tokens.ValueToken;
-
-public class ScannerImplTest extends TestCase {
-
- public void testGetToken() {
- String data = "string: abcd";
- StreamReader reader = new StreamReader(data);
- Scanner scanner = new ScannerImpl(reader);
- Mark dummy = new Mark("dummy", 0, 0, 0, "", 0);
- LinkedList<Token> etalonTokens = new LinkedList<Token>();
- etalonTokens.add(new StreamStartToken(dummy, dummy));
- etalonTokens.add(new BlockMappingStartToken(dummy, dummy));
- etalonTokens.add(new KeyToken(dummy, dummy));
- etalonTokens.add(new ScalarToken("string", true, dummy, dummy, (char) 0));
- etalonTokens.add(new ValueToken(dummy, dummy));
- etalonTokens.add(new ScalarToken("abcd", true, dummy, dummy, (char) 0));
- etalonTokens.add(new BlockEndToken(dummy, dummy));
- etalonTokens.add(new StreamEndToken(dummy, dummy));
- while (!etalonTokens.isEmpty() && scanner.checkToken(etalonTokens.get(0).getTokenId())) {
- assertEquals(etalonTokens.removeFirst(), scanner.getToken());
- }
- assertFalse("Must contain no more tokens: " + scanner.getToken(),
- scanner.checkToken(new Token.ID[0]));
- }
-
- public void testWrongTab() {
- Yaml yaml = new Yaml();
- try {
- yaml.load("\t data: 1");
- fail("TAB cannot start a token.");
- } catch (Exception e) {
- assertEquals(
- "while scanning for the next token; found character \t'\\t' that cannot start any token",
- e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.scanner;
+
+import java.util.LinkedList;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.reader.StreamReader;
+import org.yaml.snakeyaml.tokens.BlockEndToken;
+import org.yaml.snakeyaml.tokens.BlockMappingStartToken;
+import org.yaml.snakeyaml.tokens.KeyToken;
+import org.yaml.snakeyaml.tokens.ScalarToken;
+import org.yaml.snakeyaml.tokens.StreamEndToken;
+import org.yaml.snakeyaml.tokens.StreamStartToken;
+import org.yaml.snakeyaml.tokens.Token;
+import org.yaml.snakeyaml.tokens.ValueToken;
+
+public class ScannerImplTest extends TestCase {
+
+ public void testGetToken() {
+ String data = "string: abcd";
+ StreamReader reader = new StreamReader(data);
+ Scanner scanner = new ScannerImpl(reader);
+ Mark dummy = new Mark("dummy", 0, 0, 0, "", 0);
+ LinkedList<Token> etalonTokens = new LinkedList<Token>();
+ etalonTokens.add(new StreamStartToken(dummy, dummy));
+ etalonTokens.add(new BlockMappingStartToken(dummy, dummy));
+ etalonTokens.add(new KeyToken(dummy, dummy));
+ etalonTokens.add(new ScalarToken("string", true, dummy, dummy, (char) 0));
+ etalonTokens.add(new ValueToken(dummy, dummy));
+ etalonTokens.add(new ScalarToken("abcd", true, dummy, dummy, (char) 0));
+ etalonTokens.add(new BlockEndToken(dummy, dummy));
+ etalonTokens.add(new StreamEndToken(dummy, dummy));
+ while (!etalonTokens.isEmpty() && scanner.checkToken(etalonTokens.get(0).getTokenId())) {
+ assertEquals(etalonTokens.removeFirst(), scanner.getToken());
+ }
+ assertFalse("Must contain no more tokens: " + scanner.getToken(),
+ scanner.checkToken(new Token.ID[0]));
+ }
+
+ public void testWrongTab() {
+ Yaml yaml = new Yaml();
+ try {
+ yaml.load("\t data: 1");
+ fail("TAB cannot start a token.");
+ } catch (Exception e) {
+ assertEquals(
+ "while scanning for the next token; found character \t'\\t' that cannot start any token",
+ e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/scanner/SimpleKeyTest.java b/src/test/java/org/yaml/snakeyaml/scanner/SimpleKeyTest.java
index 0da2990..7464312 100644
--- a/src/test/java/org/yaml/snakeyaml/scanner/SimpleKeyTest.java
+++ b/src/test/java/org/yaml/snakeyaml/scanner/SimpleKeyTest.java
@@ -1,27 +1,27 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.scanner;
-
-import junit.framework.TestCase;
-
-public class SimpleKeyTest extends TestCase {
-
- public void testToString() {
- SimpleKey key = new SimpleKey(1, false, 5, 3, 2, null);
- assertTrue(key.toString().contains("SimpleKey"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.scanner;
+
+import junit.framework.TestCase;
+
+public class SimpleKeyTest extends TestCase {
+
+ public void testToString() {
+ SimpleKey key = new SimpleKey(1, false, 5, 3, 2, null);
+ assertTrue(key.toString().contains("SimpleKey"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/serializer/SerializerTest.java b/src/test/java/org/yaml/snakeyaml/serializer/SerializerTest.java
index f136dca..4d467ea 100644
--- a/src/test/java/org/yaml/snakeyaml/serializer/SerializerTest.java
+++ b/src/test/java/org/yaml/snakeyaml/serializer/SerializerTest.java
@@ -1,103 +1,103 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.serializer;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.text.NumberFormat;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.emitter.Emitter;
-import org.yaml.snakeyaml.nodes.ScalarNode;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.resolver.Resolver;
-
-public class SerializerTest extends TestCase {
- private Serializer serializer;
-
- @Override
- protected void setUp() {
- DumperOptions config = new DumperOptions();
- StringWriter writer = new StringWriter();
- serializer = new Serializer(new Emitter(writer, config), new Resolver(), config, null);
- }
-
- public void testSerializerIsAlreadyOpened() throws IOException {
- serializer.open();
- try {
- serializer.open();
- fail();
- } catch (RuntimeException e) {
- assertEquals("serializer is already opened", e.getMessage());
- }
- }
-
- public void testSerializerIsClosed1() throws IOException {
- serializer.open();
- serializer.close();
- try {
- serializer.open();
- fail();
- } catch (RuntimeException e) {
- assertEquals("serializer is closed", e.getMessage());
- }
- }
-
- public void testSerializerIsClosed2() throws IOException {
- serializer.open();
- serializer.close();
- try {
- serializer.serialize(new ScalarNode(new Tag("!foo"), "bar", null, null, (char) 0));
- fail();
- } catch (RuntimeException e) {
- assertEquals("serializer is closed", e.getMessage());
- }
- }
-
- public void testSerializerIsClosed3() throws IOException {
- serializer.open();
- serializer.close();
- serializer.close();// no problem to close twice
- }
-
- public void testSerializerIsNotOpened1() throws IOException {
- try {
- serializer.close();
- fail();
- } catch (RuntimeException e) {
- assertEquals("serializer is not opened", e.getMessage());
- }
- }
-
- public void testSerializerIsNotOpened2() throws IOException {
- try {
- serializer.serialize(new ScalarNode(new Tag("!foo"), "bar", null, null, (char) 0));
- fail();
- } catch (RuntimeException e) {
- assertEquals("serializer is not opened", e.getMessage());
- }
- }
-
- public void testGenerateAnchor() {
- NumberFormat format = NumberFormat.getNumberInstance();
- format.setMinimumIntegerDigits(3);
- String anchor = format.format(3L);
- assertEquals("003", anchor);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.serializer;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.text.NumberFormat;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.emitter.Emitter;
+import org.yaml.snakeyaml.nodes.ScalarNode;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.resolver.Resolver;
+
+public class SerializerTest extends TestCase {
+ private Serializer serializer;
+
+ @Override
+ protected void setUp() {
+ DumperOptions config = new DumperOptions();
+ StringWriter writer = new StringWriter();
+ serializer = new Serializer(new Emitter(writer, config), new Resolver(), config, null);
+ }
+
+ public void testSerializerIsAlreadyOpened() throws IOException {
+ serializer.open();
+ try {
+ serializer.open();
+ fail();
+ } catch (RuntimeException e) {
+ assertEquals("serializer is already opened", e.getMessage());
+ }
+ }
+
+ public void testSerializerIsClosed1() throws IOException {
+ serializer.open();
+ serializer.close();
+ try {
+ serializer.open();
+ fail();
+ } catch (RuntimeException e) {
+ assertEquals("serializer is closed", e.getMessage());
+ }
+ }
+
+ public void testSerializerIsClosed2() throws IOException {
+ serializer.open();
+ serializer.close();
+ try {
+ serializer.serialize(new ScalarNode(new Tag("!foo"), "bar", null, null, (char) 0));
+ fail();
+ } catch (RuntimeException e) {
+ assertEquals("serializer is closed", e.getMessage());
+ }
+ }
+
+ public void testSerializerIsClosed3() throws IOException {
+ serializer.open();
+ serializer.close();
+ serializer.close();// no problem to close twice
+ }
+
+ public void testSerializerIsNotOpened1() throws IOException {
+ try {
+ serializer.close();
+ fail();
+ } catch (RuntimeException e) {
+ assertEquals("serializer is not opened", e.getMessage());
+ }
+ }
+
+ public void testSerializerIsNotOpened2() throws IOException {
+ try {
+ serializer.serialize(new ScalarNode(new Tag("!foo"), "bar", null, null, (char) 0));
+ fail();
+ } catch (RuntimeException e) {
+ assertEquals("serializer is not opened", e.getMessage());
+ }
+ }
+
+ public void testGenerateAnchor() {
+ NumberFormat format = NumberFormat.getNumberInstance();
+ format.setMinimumIntegerDigits(3);
+ String anchor = format.format(3L);
+ assertEquals("003", anchor);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/stress/ParallelTest.java b/src/test/java/org/yaml/snakeyaml/stress/ParallelTest.java
index 359fdb7..e7531c8 100644
--- a/src/test/java/org/yaml/snakeyaml/stress/ParallelTest.java
+++ b/src/test/java/org/yaml/snakeyaml/stress/ParallelTest.java
@@ -1,72 +1,72 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.stress;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Invoice;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * Test that Yaml instances are independent and can be used in multiple threads.
- */
-public class ParallelTest extends TestCase {
- private int progress = 0;
- private int MAX = 5;
-
- public void testPerfomance() {
- String doc = Util.getLocalResource("specification/example2_27.yaml");
- for (int i = 0; i < MAX; i++) {
- Worker worker = new Worker(i, doc);
- Thread thread = new Thread(worker);
- thread.start();
- }
- while (progress < MAX - 1) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- fail(e.getMessage());
- }
- }
- }
-
- private class Worker implements Runnable {
- private int id;
- private String doc;
-
- public Worker(int id, String doc) {
- this.id = id;
- this.doc = doc;
- }
-
- public void run() {
- System.out.println("Started: " + id);
- Yaml loader = new Yaml();
- long time1 = System.nanoTime();
- int cycles = 200;
- for (int i = 0; i < cycles; i++) {
- Invoice invoice = loader.loadAs(doc, Invoice.class);
- assertNotNull(invoice);
- }
- long time2 = System.nanoTime();
- float duration = ((time2 - time1) / 1000000) / (float) cycles;
- System.out.println("Duration of " + id + " was " + duration + " ms/load.");
- progress++;
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.stress;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Invoice;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * Test that Yaml instances are independent and can be used in multiple threads.
+ */
+public class ParallelTest extends TestCase {
+ private int progress = 0;
+ private int MAX = 5;
+
+ public void testPerfomance() {
+ String doc = Util.getLocalResource("specification/example2_27.yaml");
+ for (int i = 0; i < MAX; i++) {
+ Worker worker = new Worker(i, doc);
+ Thread thread = new Thread(worker);
+ thread.start();
+ }
+ while (progress < MAX - 1) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ fail(e.getMessage());
+ }
+ }
+ }
+
+ private class Worker implements Runnable {
+ private int id;
+ private String doc;
+
+ public Worker(int id, String doc) {
+ this.id = id;
+ this.doc = doc;
+ }
+
+ public void run() {
+ System.out.println("Started: " + id);
+ Yaml loader = new Yaml();
+ long time1 = System.nanoTime();
+ int cycles = 200;
+ for (int i = 0; i < cycles; i++) {
+ Invoice invoice = loader.loadAs(doc, Invoice.class);
+ assertNotNull(invoice);
+ }
+ long time2 = System.nanoTime();
+ float duration = ((time2 - time1) / 1000000) / (float) cycles;
+ System.out.println("Duration of " + id + " was " + duration + " ms/load.");
+ progress++;
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/stress/StressEmitterTest.java b/src/test/java/org/yaml/snakeyaml/stress/StressEmitterTest.java
index 243710a..6e1a20f 100644
--- a/src/test/java/org/yaml/snakeyaml/stress/StressEmitterTest.java
+++ b/src/test/java/org/yaml/snakeyaml/stress/StressEmitterTest.java
@@ -1,81 +1,81 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.stress;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.yaml.snakeyaml.Invoice;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-
-public class StressEmitterTest extends TestCase {
-
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new TestSuite(StressEmitterTest.class);
- }
-
- public void testPerformance() {
- Yaml loader = new Yaml();
- Invoice invoice = loader.loadAs(Util.getLocalResource("specification/example2_27.yaml"),
- Invoice.class);
- Yaml dumper = new Yaml();
- long time1 = System.nanoTime();
- dumper.dumpAsMap(invoice);
- long time2 = System.nanoTime();
- float duration = (time2 - time1) / 1000000;
- System.out.println("\nSingle dump was " + duration + " ms.");
-
- int[] range = new int[] { 1000, 2000 /* , 8000 */};
- System.out.println("\nOne instance.");
- for (int number : range) {
- time1 = System.nanoTime();
- for (int i = 0; i < number; i++) {
- dumper.dump(invoice);
- }
- time2 = System.nanoTime();
- duration = ((time2 - time1) / 1000000) / (float) number;
- System.out.println("Duration for r=" + number + " was " + duration + " ms/dump.");
- // cobertura may make it very slow
- if (duration > 3) {
- System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
- }
- }
-
- System.out.println("\nMany instances.");
- for (int number : range) {
- time1 = System.nanoTime();
- for (int i = 0; i < number; i++) {
- dumper = new Yaml();
- dumper.dumpAsMap(invoice);
- }
- time2 = System.nanoTime();
- duration = ((time2 - time1) / 1000000) / (float) number;
- System.out.println("Duration for r=" + number + " was " + duration + " ms/dump.");
- // cobertura may make it very slow
- if (duration > 3) {
- System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
- }
- // assertTrue("duration=" + duration, duration < 3);
- }
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.stress;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.yaml.snakeyaml.Invoice;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+
+public class StressEmitterTest extends TestCase {
+
+ public static void main(String args[]) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite() {
+ return new TestSuite(StressEmitterTest.class);
+ }
+
+ public void testPerformance() {
+ Yaml loader = new Yaml();
+ Invoice invoice = loader.loadAs(Util.getLocalResource("specification/example2_27.yaml"),
+ Invoice.class);
+ Yaml dumper = new Yaml();
+ long time1 = System.nanoTime();
+ dumper.dumpAsMap(invoice);
+ long time2 = System.nanoTime();
+ float duration = (time2 - time1) / 1000000;
+ System.out.println("\nSingle dump was " + duration + " ms.");
+
+ int[] range = new int[] { 1000, 2000 /* , 8000 */};
+ System.out.println("\nOne instance.");
+ for (int number : range) {
+ time1 = System.nanoTime();
+ for (int i = 0; i < number; i++) {
+ dumper.dump(invoice);
+ }
+ time2 = System.nanoTime();
+ duration = ((time2 - time1) / 1000000) / (float) number;
+ System.out.println("Duration for r=" + number + " was " + duration + " ms/dump.");
+ // cobertura may make it very slow
+ if (duration > 3) {
+ System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
+ }
+ }
+
+ System.out.println("\nMany instances.");
+ for (int number : range) {
+ time1 = System.nanoTime();
+ for (int i = 0; i < number; i++) {
+ dumper = new Yaml();
+ dumper.dumpAsMap(invoice);
+ }
+ time2 = System.nanoTime();
+ duration = ((time2 - time1) / 1000000) / (float) number;
+ System.out.println("Duration for r=" + number + " was " + duration + " ms/dump.");
+ // cobertura may make it very slow
+ if (duration > 3) {
+ System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
+ }
+ // assertTrue("duration=" + duration, duration < 3);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/stress/StressTest.java b/src/test/java/org/yaml/snakeyaml/stress/StressTest.java
index c7edfa3..218729a 100644
--- a/src/test/java/org/yaml/snakeyaml/stress/StressTest.java
+++ b/src/test/java/org/yaml/snakeyaml/stress/StressTest.java
@@ -1,92 +1,92 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.stress;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.yaml.snakeyaml.Invoice;
-import org.yaml.snakeyaml.Util;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.Constructor;
-
-public class StressTest extends TestCase {
- String doc;
-
- public static void main(String args[]) {
- junit.textui.TestRunner.run(suite());
- }
-
- public static Test suite() {
- return new TestSuite(StressTest.class);
- }
-
- public void setUp() {
- doc = Util.getLocalResource("specification/example2_27.yaml");
- }
-
- public void testPerformance() {
- long time1 = System.nanoTime();
- new Yaml(new Constructor(Invoice.class));
- long time2 = System.nanoTime();
- float duration = (time2 - time1) / 1000000;
- System.out.println("Init was " + duration + " ms.");
-
- Yaml loader = new Yaml();
- time1 = System.nanoTime();
- loader.loadAs(doc, Invoice.class);
- time2 = System.nanoTime();
- duration = (time2 - time1) / 1000000;
- System.out.println("\nSingle load was " + duration + " ms.");
-
- loader = new Yaml();
- int[] range = new int[] { 1000, 2000 /* , 4000, 8000 */};
- System.out.println("\nOne instance.");
- for (int number : range) {
- time1 = System.nanoTime();
- for (int i = 0; i < number; i++) {
- loader.loadAs(doc, Invoice.class);
- }
- time2 = System.nanoTime();
- duration = ((time2 - time1) / 1000000) / (float) number;
- System.out.println("Duration for r=" + number + " was " + duration + " ms/load.");
- // cobertura may make it very slow
- if (duration > 3) {
- System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
- }
- // assertTrue("duration=" + duration, duration < 3);
- }
-
- System.out.println("\nMany instances.");
- for (int number : range) {
- time1 = System.nanoTime();
- for (int i = 0; i < number; i++) {
- loader = new Yaml();
- loader.loadAs(doc, Invoice.class);
- }
- time2 = System.nanoTime();
- duration = ((time2 - time1) / 1000000) / (float) number;
- System.out.println("Duration for r=" + number + " was " + duration + " ms/load.");
- // cobertura may make it very slow
- if (duration > 3) {
- System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
- }
- // assertTrue("duration=" + duration, duration < 3);
- }
- }
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.stress;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.yaml.snakeyaml.Invoice;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+
+public class StressTest extends TestCase {
+ String doc;
+
+ public static void main(String args[]) {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static Test suite() {
+ return new TestSuite(StressTest.class);
+ }
+
+ public void setUp() {
+ doc = Util.getLocalResource("specification/example2_27.yaml");
+ }
+
+ public void testPerformance() {
+ long time1 = System.nanoTime();
+ new Yaml(new Constructor(Invoice.class));
+ long time2 = System.nanoTime();
+ float duration = (time2 - time1) / 1000000;
+ System.out.println("Init was " + duration + " ms.");
+
+ Yaml loader = new Yaml();
+ time1 = System.nanoTime();
+ loader.loadAs(doc, Invoice.class);
+ time2 = System.nanoTime();
+ duration = (time2 - time1) / 1000000;
+ System.out.println("\nSingle load was " + duration + " ms.");
+
+ loader = new Yaml();
+ int[] range = new int[] { 1000, 2000 /* , 4000, 8000 */};
+ System.out.println("\nOne instance.");
+ for (int number : range) {
+ time1 = System.nanoTime();
+ for (int i = 0; i < number; i++) {
+ loader.loadAs(doc, Invoice.class);
+ }
+ time2 = System.nanoTime();
+ duration = ((time2 - time1) / 1000000) / (float) number;
+ System.out.println("Duration for r=" + number + " was " + duration + " ms/load.");
+ // cobertura may make it very slow
+ if (duration > 3) {
+ System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
+ }
+ // assertTrue("duration=" + duration, duration < 3);
+ }
+
+ System.out.println("\nMany instances.");
+ for (int number : range) {
+ time1 = System.nanoTime();
+ for (int i = 0; i < number; i++) {
+ loader = new Yaml();
+ loader.loadAs(doc, Invoice.class);
+ }
+ time2 = System.nanoTime();
+ duration = ((time2 - time1) / 1000000) / (float) number;
+ System.out.println("Duration for r=" + number + " was " + duration + " ms/load.");
+ // cobertura may make it very slow
+ if (duration > 3) {
+ System.err.println("!!!!!! Too long. Expected <1 but was " + duration);
+ }
+ // assertTrue("duration=" + duration, duration < 3);
+ }
+ }
}
\ No newline at end of file
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/AliasTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/AliasTokenTest.java
index 6ef56e8..9585da8 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/AliasTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/AliasTokenTest.java
@@ -1,43 +1,43 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class AliasTokenTest extends TestCase {
-
- public void testEquals() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- AliasToken token = new AliasToken("*id123", mark, mark);
- assertFalse(token.equals(mark));
- }
-
- public void testGetArguments() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- AliasToken token = new AliasToken("*id123", mark, mark);
- assertEquals("value=*id123", token.getArguments());
- }
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- AliasToken token = new AliasToken("&id123", mark, mark);
- assertEquals(ID.Alias, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class AliasTokenTest extends TestCase {
+
+ public void testEquals() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ AliasToken token = new AliasToken("*id123", mark, mark);
+ assertFalse(token.equals(mark));
+ }
+
+ public void testGetArguments() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ AliasToken token = new AliasToken("*id123", mark, mark);
+ assertEquals("value=*id123", token.getArguments());
+ }
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ AliasToken token = new AliasToken("&id123", mark, mark);
+ assertEquals(ID.Alias, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/AnchorTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/AnchorTokenTest.java
index abd2d1d..11f6ef4 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/AnchorTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/AnchorTokenTest.java
@@ -1,37 +1,37 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class AnchorTokenTest extends TestCase {
-
- public void testGetArguments() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- AnchorToken token = new AnchorToken("&id123", mark, mark);
- assertEquals("value=&id123", token.getArguments());
- }
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- AnchorToken token = new AnchorToken("&id123", mark, mark);
- assertEquals(ID.Anchor, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class AnchorTokenTest extends TestCase {
+
+ public void testGetArguments() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ AnchorToken token = new AnchorToken("&id123", mark, mark);
+ assertEquals("value=&id123", token.getArguments());
+ }
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ AnchorToken token = new AnchorToken("&id123", mark, mark);
+ assertEquals(ID.Anchor, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/BlockEndTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/BlockEndTokenTest.java
index a87cb39..a30e54e 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/BlockEndTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/BlockEndTokenTest.java
@@ -1,37 +1,37 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class BlockEndTokenTest extends TestCase {
-
- public void testGetArguments() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- BlockEndToken token = new BlockEndToken(mark, mark);
- assertEquals("", token.getArguments());
- }
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- BlockEndToken token = new BlockEndToken(mark, mark);
- assertEquals(ID.BlockEnd, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class BlockEndTokenTest extends TestCase {
+
+ public void testGetArguments() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ BlockEndToken token = new BlockEndToken(mark, mark);
+ assertEquals("", token.getArguments());
+ }
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ BlockEndToken token = new BlockEndToken(mark, mark);
+ assertEquals(ID.BlockEnd, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/BlockEntryTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/BlockEntryTokenTest.java
index 14f3dd8..550e208 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/BlockEntryTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/BlockEntryTokenTest.java
@@ -1,32 +1,32 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class BlockEntryTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- BlockEntryToken token = new BlockEntryToken(mark, mark);
- assertEquals(ID.BlockEntry, token.getTokenId());
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class BlockEntryTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ BlockEntryToken token = new BlockEntryToken(mark, mark);
+ assertEquals(ID.BlockEntry, token.getTokenId());
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/BlockSequenceStartTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/BlockSequenceStartTokenTest.java
index 71ff671..838fab6 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/BlockSequenceStartTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/BlockSequenceStartTokenTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class BlockSequenceStartTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- BlockSequenceStartToken token = new BlockSequenceStartToken(mark, mark);
- assertEquals(ID.BlockSequenceStart, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class BlockSequenceStartTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ BlockSequenceStartToken token = new BlockSequenceStartToken(mark, mark);
+ assertEquals(ID.BlockSequenceStart, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/DirectiveTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/DirectiveTokenTest.java
index ba367ee..e73a842 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/DirectiveTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/DirectiveTokenTest.java
@@ -1,70 +1,70 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class DirectiveTokenTest extends TestCase {
-
- public void testGetArguments() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- DirectiveToken<Integer> token = new DirectiveToken<Integer>("YAML", null, mark, mark);
- assertEquals("name=YAML", token.getArguments());
- }
-
- public void testInvalidList() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- List<Integer> list = new ArrayList<Integer>();
- list.add(new Integer(1));
- try {
- new DirectiveToken<Integer>("YAML", list, mark, mark);
- fail("List must have 2 values.");
- } catch (Exception e) {
- assertEquals("Two strings must be provided instead of 1", e.getMessage());
- }
- }
-
- public void testTag() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- List<String> list = new ArrayList<String>();
- list.add("!foo");
- list.add("!bar");
- DirectiveToken<String> token = new DirectiveToken<String>("TAG", list, mark, mark);
- assertEquals("name=TAG, value=[!foo, !bar]", token.getArguments());
- }
-
- public void testList() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- List<Integer> list = new ArrayList<Integer>();
- list.add(new Integer(1));
- list.add(new Integer(1));
- DirectiveToken<Integer> token = new DirectiveToken<Integer>("YAML", list, mark, mark);
- assertEquals("name=YAML, value=[1, 1]", token.getArguments());
- }
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- DirectiveToken<Integer> token = new DirectiveToken<Integer>("YAML", null, mark, mark);
- assertEquals(ID.Directive, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class DirectiveTokenTest extends TestCase {
+
+ public void testGetArguments() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ DirectiveToken<Integer> token = new DirectiveToken<Integer>("YAML", null, mark, mark);
+ assertEquals("name=YAML", token.getArguments());
+ }
+
+ public void testInvalidList() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(new Integer(1));
+ try {
+ new DirectiveToken<Integer>("YAML", list, mark, mark);
+ fail("List must have 2 values.");
+ } catch (Exception e) {
+ assertEquals("Two strings must be provided instead of 1", e.getMessage());
+ }
+ }
+
+ public void testTag() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ List<String> list = new ArrayList<String>();
+ list.add("!foo");
+ list.add("!bar");
+ DirectiveToken<String> token = new DirectiveToken<String>("TAG", list, mark, mark);
+ assertEquals("name=TAG, value=[!foo, !bar]", token.getArguments());
+ }
+
+ public void testList() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ List<Integer> list = new ArrayList<Integer>();
+ list.add(new Integer(1));
+ list.add(new Integer(1));
+ DirectiveToken<Integer> token = new DirectiveToken<Integer>("YAML", list, mark, mark);
+ assertEquals("name=YAML, value=[1, 1]", token.getArguments());
+ }
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ DirectiveToken<Integer> token = new DirectiveToken<Integer>("YAML", null, mark, mark);
+ assertEquals(ID.Directive, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/DocumentEndTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/DocumentEndTokenTest.java
index ee6af4b..1a09121 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/DocumentEndTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/DocumentEndTokenTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class DocumentEndTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- DocumentEndToken token = new DocumentEndToken(mark, mark);
- assertEquals(ID.DocumentEnd, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class DocumentEndTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ DocumentEndToken token = new DocumentEndToken(mark, mark);
+ assertEquals(ID.DocumentEnd, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/DocumentStartTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/DocumentStartTokenTest.java
index a81f889..b3a3ee4 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/DocumentStartTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/DocumentStartTokenTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class DocumentStartTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- DocumentStartToken token = new DocumentStartToken(mark, mark);
- assertEquals(ID.DocumentStart, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class DocumentStartTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ DocumentStartToken token = new DocumentStartToken(mark, mark);
+ assertEquals(ID.DocumentStart, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/FlowEntryTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/FlowEntryTokenTest.java
index ee8f244..ee327fd 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/FlowEntryTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/FlowEntryTokenTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class FlowEntryTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- FlowEntryToken token = new FlowEntryToken(mark, mark);
- assertEquals(ID.FlowEntry, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class FlowEntryTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ FlowEntryToken token = new FlowEntryToken(mark, mark);
+ assertEquals(ID.FlowEntry, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/FlowMappingStartTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/FlowMappingStartTokenTest.java
index 93ace44..88904c6 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/FlowMappingStartTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/FlowMappingStartTokenTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class FlowMappingStartTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- FlowMappingStartToken token = new FlowMappingStartToken(mark, mark);
- assertEquals(ID.FlowMappingStart, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class FlowMappingStartTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ FlowMappingStartToken token = new FlowMappingStartToken(mark, mark);
+ assertEquals(ID.FlowMappingStart, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/FlowSequenceStartTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/FlowSequenceStartTokenTest.java
index 0ba47a2..8d6ea7a 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/FlowSequenceStartTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/FlowSequenceStartTokenTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class FlowSequenceStartTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- FlowSequenceStartToken token = new FlowSequenceStartToken(mark, mark);
- assertEquals(ID.FlowSequenceStart, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class FlowSequenceStartTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ FlowSequenceStartToken token = new FlowSequenceStartToken(mark, mark);
+ assertEquals(ID.FlowSequenceStart, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/StreamStartTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/StreamStartTokenTest.java
index 1c5bf47..c5fdeb3 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/StreamStartTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/StreamStartTokenTest.java
@@ -1,31 +1,31 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class StreamStartTokenTest extends TestCase {
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- StreamStartToken token = new StreamStartToken(mark, mark);
- assertEquals(ID.StreamStart, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class StreamStartTokenTest extends TestCase {
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ StreamStartToken token = new StreamStartToken(mark, mark);
+ assertEquals(ID.StreamStart, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/tokens/TagTokenTest.java b/src/test/java/org/yaml/snakeyaml/tokens/TagTokenTest.java
index daf8127..11b3cce 100644
--- a/src/test/java/org/yaml/snakeyaml/tokens/TagTokenTest.java
+++ b/src/test/java/org/yaml/snakeyaml/tokens/TagTokenTest.java
@@ -1,64 +1,64 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.tokens;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.error.Mark;
-import org.yaml.snakeyaml.error.YAMLException;
-import org.yaml.snakeyaml.tokens.Token.ID;
-
-public class TagTokenTest extends TestCase {
-
- public void testGetArguments() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- TagToken token = new TagToken(new TagTuple("!foo", "!bar"), mark, mark);
- assertEquals("value=[!foo, !bar]", token.getArguments());
- }
-
- public void testNoMarks() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- try {
- new TagToken(new TagTuple("!foo", "!bar"), null, mark);
- fail("Token without start mark should not be accepted.");
- } catch (YAMLException e) {
- assertEquals("Token requires marks.", e.getMessage());
- }
- try {
- new TagToken(new TagTuple("!foo", "!bar"), mark, null);
- fail("Token without end mark should not be accepted.");
- } catch (YAMLException e) {
- assertEquals("Token requires marks.", e.getMessage());
- }
- }
-
- public void testNoTag() {
- try {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- new TagToken(new TagTuple("!foo", null), mark, mark);
- fail("Marks must be provided.");
- } catch (NullPointerException e) {
- assertEquals("Suffix must be provided.", e.getMessage());
- }
- }
-
- public void testGetTokenId() {
- Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
- TagToken token = new TagToken(new TagTuple("!foo", "!bar"), mark, mark);
- assertEquals(ID.Tag, token.getTokenId());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.tokens;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.error.Mark;
+import org.yaml.snakeyaml.error.YAMLException;
+import org.yaml.snakeyaml.tokens.Token.ID;
+
+public class TagTokenTest extends TestCase {
+
+ public void testGetArguments() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ TagToken token = new TagToken(new TagTuple("!foo", "!bar"), mark, mark);
+ assertEquals("value=[!foo, !bar]", token.getArguments());
+ }
+
+ public void testNoMarks() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ try {
+ new TagToken(new TagTuple("!foo", "!bar"), null, mark);
+ fail("Token without start mark should not be accepted.");
+ } catch (YAMLException e) {
+ assertEquals("Token requires marks.", e.getMessage());
+ }
+ try {
+ new TagToken(new TagTuple("!foo", "!bar"), mark, null);
+ fail("Token without end mark should not be accepted.");
+ } catch (YAMLException e) {
+ assertEquals("Token requires marks.", e.getMessage());
+ }
+ }
+
+ public void testNoTag() {
+ try {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ new TagToken(new TagTuple("!foo", null), mark, mark);
+ fail("Marks must be provided.");
+ } catch (NullPointerException e) {
+ assertEquals("Suffix must be provided.", e.getMessage());
+ }
+ }
+
+ public void testGetTokenId() {
+ Mark mark = new Mark("test1", 0, 0, 0, "*The first line.\nThe last line.", 0);
+ TagToken token = new TagToken(new TagTuple("!foo", "!bar"), mark, mark);
+ assertEquals(ID.Tag, token.getTokenId());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/AbstractTest.java b/src/test/java/org/yaml/snakeyaml/types/AbstractTest.java
index 06fbc74..de8e2d0 100644
--- a/src/test/java/org/yaml/snakeyaml/types/AbstractTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/AbstractTest.java
@@ -1,48 +1,48 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.yaml.snakeyaml.Yaml;
-
-public abstract class AbstractTest extends TestCase {
- @SuppressWarnings("unchecked")
- protected Map<String, Object> getMap(String data) {
- Yaml yaml = new Yaml();
- Map<String, Object> nativeData = (Map<String, Object>) yaml.load(data);
- return nativeData;
- }
-
- protected Object load(String data) {
- Yaml yaml = new Yaml();
- Object obj = yaml.load(data);
- return obj;
- }
-
- protected String dump(Object data) {
- Yaml yaml = new Yaml();
- return yaml.dump(data);
- }
-
- protected Object getMapValue(String data, String key) {
- Map<String, Object> nativeData = getMap(data);
- return nativeData.get(key);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.Yaml;
+
+public abstract class AbstractTest extends TestCase {
+ @SuppressWarnings("unchecked")
+ protected Map<String, Object> getMap(String data) {
+ Yaml yaml = new Yaml();
+ Map<String, Object> nativeData = (Map<String, Object>) yaml.load(data);
+ return nativeData;
+ }
+
+ protected Object load(String data) {
+ Yaml yaml = new Yaml();
+ Object obj = yaml.load(data);
+ return obj;
+ }
+
+ protected String dump(Object data) {
+ Yaml yaml = new Yaml();
+ return yaml.dump(data);
+ }
+
+ protected Object getMapValue(String data, String key) {
+ Map<String, Object> nativeData = getMap(data);
+ return nativeData.get(key);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/BinaryTagTest.java b/src/test/java/org/yaml/snakeyaml/types/BinaryTagTest.java
index beaa7c5..c00cc37 100644
--- a/src/test/java/org/yaml/snakeyaml/types/BinaryTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/BinaryTagTest.java
@@ -1,77 +1,77 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @see http://yaml.org/type/binary.html
- */
-public class BinaryTagTest extends AbstractTest {
- String line1 = "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5";
- String line2 = "OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+";
- String line3 = "+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC";
- String line4 = "AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=";
- String content = line1 + line2 + line3 + line4;
-
- public void testBinary() {
- byte[] binary = (byte[]) getMapValue("canonical: !!binary " + content, "canonical");
- assertEquals((byte) 'G', binary[0]);
- assertEquals((byte) 'I', binary[1]);
- assertEquals((byte) 'F', binary[2]);
- assertEquals((byte) '8', binary[3]);
- assertEquals((byte) '9', binary[4]);
- }
-
- public void testBinary2() {
- byte[] binary = (byte[]) load("!!binary \"MQ==\"");
- assertEquals(1, binary.length);
- assertEquals((byte) '1', binary[0]);
- }
-
- public void testBinaryTag() {
- byte[] binary = (byte[]) getMapValue("canonical: !<tag:yaml.org,2002:binary> " + content,
- "canonical");
- assertEquals((byte) 'G', binary[0]);
- assertEquals((byte) 'I', binary[1]);
- assertEquals((byte) 'F', binary[2]);
- assertEquals((byte) '8', binary[3]);
- assertEquals((byte) '9', binary[4]);
- }
-
- public void testBinaryOut() throws IOException {
- byte[] data = "GIF89\tbi\u0003\u0000nary\n\u001Fimage\n".getBytes("ISO-8859-1");
- Map<String, String> map = new HashMap<String, String>();
- String value = new String(data, "ISO-8859-1");
- map.put("canonical", value);
- String output = dump(map);
- assertEquals("canonical: !!binary |-\n R0lGODkJYmkDAG5hcnkKH2ltYWdlCg==\n", output);
- }
-
- public void testByteArray() {
- byte[] data = { 8, 14, 15, 10, 126, 32, 65, 65, 65 };
- String output = dump(data);
- assertEquals("!!binary |-\n CA4PCn4gQUFB\n", output);
- byte[] parsed = (byte[]) load(output);
- assertEquals(data.length, parsed.length);
- for (int i = 0; i < data.length; i++) {
- assertEquals(data[i], parsed[i]);
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @see http://yaml.org/type/binary.html
+ */
+public class BinaryTagTest extends AbstractTest {
+ String line1 = "R0lGODlhDAAMAIQAAP//9/X17unp5WZmZgAAAOfn515eXvPz7Y6OjuDg4J+fn5";
+ String line2 = "OTk6enp56enmlpaWNjY6Ojo4SEhP/++f/++f/++f/++f/++f/++f/++f/++f/+";
+ String line3 = "+f/++f/++f/++f/++f/++SH+Dk1hZGUgd2l0aCBHSU1QACwAAAAADAAMAAAFLC";
+ String line4 = "AgjoEwnuNAFOhpEMTRiggcz4BNJHrv/zCFcLiwMWYNG84BwwEeECcgggoBADs=";
+ String content = line1 + line2 + line3 + line4;
+
+ public void testBinary() {
+ byte[] binary = (byte[]) getMapValue("canonical: !!binary " + content, "canonical");
+ assertEquals((byte) 'G', binary[0]);
+ assertEquals((byte) 'I', binary[1]);
+ assertEquals((byte) 'F', binary[2]);
+ assertEquals((byte) '8', binary[3]);
+ assertEquals((byte) '9', binary[4]);
+ }
+
+ public void testBinary2() {
+ byte[] binary = (byte[]) load("!!binary \"MQ==\"");
+ assertEquals(1, binary.length);
+ assertEquals((byte) '1', binary[0]);
+ }
+
+ public void testBinaryTag() {
+ byte[] binary = (byte[]) getMapValue("canonical: !<tag:yaml.org,2002:binary> " + content,
+ "canonical");
+ assertEquals((byte) 'G', binary[0]);
+ assertEquals((byte) 'I', binary[1]);
+ assertEquals((byte) 'F', binary[2]);
+ assertEquals((byte) '8', binary[3]);
+ assertEquals((byte) '9', binary[4]);
+ }
+
+ public void testBinaryOut() throws IOException {
+ byte[] data = "GIF89\tbi\u0003\u0000nary\n\u001Fimage\n".getBytes("ISO-8859-1");
+ Map<String, String> map = new HashMap<String, String>();
+ String value = new String(data, "ISO-8859-1");
+ map.put("canonical", value);
+ String output = dump(map);
+ assertEquals("canonical: !!binary |-\n R0lGODkJYmkDAG5hcnkKH2ltYWdlCg==\n", output);
+ }
+
+ public void testByteArray() {
+ byte[] data = { 8, 14, 15, 10, 126, 32, 65, 65, 65 };
+ String output = dump(data);
+ assertEquals("!!binary |-\n CA4PCn4gQUFB\n", output);
+ byte[] parsed = (byte[]) load(output);
+ assertEquals(data.length, parsed.length);
+ for (int i = 0; i < data.length; i++) {
+ assertEquals(data[i], parsed[i]);
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/BoolTagTest.java b/src/test/java/org/yaml/snakeyaml/types/BoolTagTest.java
index c1c52e8..a2e859a 100644
--- a/src/test/java/org/yaml/snakeyaml/types/BoolTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/BoolTagTest.java
@@ -1,134 +1,134 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Represent;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * @see http://yaml.org/type/bool.html
- */
-public class BoolTagTest extends AbstractTest {
- public void testBool() {
- assertEquals(Boolean.TRUE, getMapValue("canonical: true", "canonical"));
- assertEquals(Boolean.FALSE, getMapValue("answer: NO", "answer"));
- assertEquals(Boolean.TRUE, getMapValue("logical: True", "logical"));
- assertEquals(Boolean.TRUE, getMapValue("option: on", "option"));
- }
-
- public void testBoolCanonical() {
- assertEquals(Boolean.TRUE, getMapValue("canonical: Yes", "canonical"));
- assertEquals(Boolean.TRUE, getMapValue("canonical: yes", "canonical"));
- assertEquals(Boolean.TRUE, getMapValue("canonical: YES", "canonical"));
- assertEquals("yES", getMapValue("canonical: yES", "canonical"));
- assertEquals(Boolean.FALSE, getMapValue("canonical: No", "canonical"));
- assertEquals(Boolean.FALSE, getMapValue("canonical: NO", "canonical"));
- assertEquals(Boolean.FALSE, getMapValue("canonical: no", "canonical"));
- assertEquals(Boolean.FALSE, getMapValue("canonical: off", "canonical"));
- assertEquals(Boolean.FALSE, getMapValue("canonical: Off", "canonical"));
- assertEquals(Boolean.FALSE, getMapValue("canonical: OFF", "canonical"));
- assertEquals(Boolean.TRUE, getMapValue("canonical: ON", "canonical"));
- assertEquals(Boolean.TRUE, getMapValue("canonical: On", "canonical"));
- assertEquals(Boolean.TRUE, getMapValue("canonical: on", "canonical"));
- // it looks like it is against the specification but it is like in
- // PyYAML
- assertEquals("n", getMapValue("canonical: n", "canonical"));
- assertEquals("N", getMapValue("canonical: N", "canonical"));
- assertEquals("y", getMapValue("canonical: y", "canonical"));
- assertEquals("Y", getMapValue("canonical: Y", "canonical"));
- }
-
- public void testBoolShorthand() {
- assertEquals(Boolean.TRUE, getMapValue("boolean: !!bool true", "boolean"));
- }
-
- public void testBoolTag() {
- assertEquals(Boolean.TRUE,
- getMapValue("boolean: !<tag:yaml.org,2002:bool> true", "boolean"));
- }
-
- public void testBoolOut() {
- Map<String, Boolean> map = new HashMap<String, Boolean>();
- map.put("boolean", Boolean.TRUE);
- String output = dump(map);
- assertTrue(output, output.contains("boolean: true"));
- }
-
- public void testBoolOutAsYes() {
- Yaml yaml = new Yaml(new BoolRepresenter("YES"));
- String output = yaml.dump(true);
- assertEquals("YES\n", output);
- }
-
- /**
- * test flow style
- */
- public void testBoolOutAsEmpty2() {
- Yaml yaml = new Yaml(new BoolRepresenter("on"));
- Map<String, Boolean> map = new HashMap<String, Boolean>();
- map.put("aaa", false);
- map.put("bbb", true);
- String output = yaml.dump(map);
- assertEquals("{aaa: false, bbb: on}\n", output);
- }
-
- /**
- * test block style
- */
- public void testBoolOutAsEmpty3() {
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.BLOCK);
- Yaml yaml = new Yaml(new BoolRepresenter("True"), options);
- Map<String, Boolean> map = new HashMap<String, Boolean>();
- map.put("aaa", false);
- map.put("bbb", true);
- String output = yaml.dump(map);
- assertEquals("aaa: false\nbbb: True\n", output);
- }
-
- private class BoolRepresenter extends Representer {
- private String value;
-
- public BoolRepresenter(String value) {
- super();
- this.value = value;
- this.representers.put(Boolean.class, new RepresentBool());
- }
-
- // possible values are here http://yaml.org/type/bool.html
- // y, Y, n, N should not be used
- private class RepresentBool implements Represent {
- public Node representData(Object data) {
- String v;
- if (Boolean.TRUE.equals(data)) {
- v = value;
- } else {
- v = "false";
- }
- return representScalar(Tag.BOOL, v);
- }
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Represent;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * @see http://yaml.org/type/bool.html
+ */
+public class BoolTagTest extends AbstractTest {
+ public void testBool() {
+ assertEquals(Boolean.TRUE, getMapValue("canonical: true", "canonical"));
+ assertEquals(Boolean.FALSE, getMapValue("answer: NO", "answer"));
+ assertEquals(Boolean.TRUE, getMapValue("logical: True", "logical"));
+ assertEquals(Boolean.TRUE, getMapValue("option: on", "option"));
+ }
+
+ public void testBoolCanonical() {
+ assertEquals(Boolean.TRUE, getMapValue("canonical: Yes", "canonical"));
+ assertEquals(Boolean.TRUE, getMapValue("canonical: yes", "canonical"));
+ assertEquals(Boolean.TRUE, getMapValue("canonical: YES", "canonical"));
+ assertEquals("yES", getMapValue("canonical: yES", "canonical"));
+ assertEquals(Boolean.FALSE, getMapValue("canonical: No", "canonical"));
+ assertEquals(Boolean.FALSE, getMapValue("canonical: NO", "canonical"));
+ assertEquals(Boolean.FALSE, getMapValue("canonical: no", "canonical"));
+ assertEquals(Boolean.FALSE, getMapValue("canonical: off", "canonical"));
+ assertEquals(Boolean.FALSE, getMapValue("canonical: Off", "canonical"));
+ assertEquals(Boolean.FALSE, getMapValue("canonical: OFF", "canonical"));
+ assertEquals(Boolean.TRUE, getMapValue("canonical: ON", "canonical"));
+ assertEquals(Boolean.TRUE, getMapValue("canonical: On", "canonical"));
+ assertEquals(Boolean.TRUE, getMapValue("canonical: on", "canonical"));
+ // it looks like it is against the specification but it is like in
+ // PyYAML
+ assertEquals("n", getMapValue("canonical: n", "canonical"));
+ assertEquals("N", getMapValue("canonical: N", "canonical"));
+ assertEquals("y", getMapValue("canonical: y", "canonical"));
+ assertEquals("Y", getMapValue("canonical: Y", "canonical"));
+ }
+
+ public void testBoolShorthand() {
+ assertEquals(Boolean.TRUE, getMapValue("boolean: !!bool true", "boolean"));
+ }
+
+ public void testBoolTag() {
+ assertEquals(Boolean.TRUE,
+ getMapValue("boolean: !<tag:yaml.org,2002:bool> true", "boolean"));
+ }
+
+ public void testBoolOut() {
+ Map<String, Boolean> map = new HashMap<String, Boolean>();
+ map.put("boolean", Boolean.TRUE);
+ String output = dump(map);
+ assertTrue(output, output.contains("boolean: true"));
+ }
+
+ public void testBoolOutAsYes() {
+ Yaml yaml = new Yaml(new BoolRepresenter("YES"));
+ String output = yaml.dump(true);
+ assertEquals("YES\n", output);
+ }
+
+ /**
+ * test flow style
+ */
+ public void testBoolOutAsEmpty2() {
+ Yaml yaml = new Yaml(new BoolRepresenter("on"));
+ Map<String, Boolean> map = new HashMap<String, Boolean>();
+ map.put("aaa", false);
+ map.put("bbb", true);
+ String output = yaml.dump(map);
+ assertEquals("{aaa: false, bbb: on}\n", output);
+ }
+
+ /**
+ * test block style
+ */
+ public void testBoolOutAsEmpty3() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(new BoolRepresenter("True"), options);
+ Map<String, Boolean> map = new HashMap<String, Boolean>();
+ map.put("aaa", false);
+ map.put("bbb", true);
+ String output = yaml.dump(map);
+ assertEquals("aaa: false\nbbb: True\n", output);
+ }
+
+ private class BoolRepresenter extends Representer {
+ private String value;
+
+ public BoolRepresenter(String value) {
+ super();
+ this.value = value;
+ this.representers.put(Boolean.class, new RepresentBool());
+ }
+
+ // possible values are here http://yaml.org/type/bool.html
+ // y, Y, n, N should not be used
+ private class RepresentBool implements Represent {
+ public Node representData(Object data) {
+ String v;
+ if (Boolean.TRUE.equals(data)) {
+ v = value;
+ } else {
+ v = "false";
+ }
+ return representScalar(Tag.BOOL, v);
+ }
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/FloatTagTest.java b/src/test/java/org/yaml/snakeyaml/types/FloatTagTest.java
index f0deac8..dfc374c 100644
--- a/src/test/java/org/yaml/snakeyaml/types/FloatTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/FloatTagTest.java
@@ -1,78 +1,78 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @see http://yaml.org/type/float.html
- */
-public class FloatTagTest extends AbstractTest {
-
- public void testFloat() {
- assertEquals(new Double(6.8523015e+5), getMapValue("canonical: 6.8523015e+5", "canonical"));
- assertEquals(new Double(6.8523015e+5),
- getMapValue("exponentioal: 685.230_15e+03", "exponentioal"));
- assertEquals(new Double(6.8523015e+5), getMapValue("fixed: 685_230.15", "fixed"));
- assertEquals(new Double(6.8523015e+5),
- getMapValue("sexagesimal: 190:20:30.15", "sexagesimal"));
- assertEquals(Double.NEGATIVE_INFINITY,
- getMapValue("negative infinity: -.inf", "negative infinity"));
- assertEquals(Double.NaN, getMapValue("not a number: .NaN", "not a number"));
- }
-
- public void testFloatShorthand() {
- assertEquals(new Double(1), getMapValue("number: !!float 1", "number"));
- }
-
- public void testFloatTag() {
- assertEquals(new Double(1), getMapValue("number: !<tag:yaml.org,2002:float> 1", "number"));
- }
-
- public void testFloatOut() {
- Map<String, Object> map = new HashMap<String, Object>();
- map.put("number", new Double(1));
- String output = dump(map);
- assertEquals("{number: 1.0}\n", output);
- }
-
- public void testBasicDoubleScalarLoad() {
- assertEquals(new Double(47.0), load("47.0"));
- assertEquals(new Double(0.0), load("0.0"));
- assertEquals(new Double(-1.0), load("-1.0"));
- }
-
- public void testDumpStr() {
- assertEquals("'1.0'\n", dump("1.0"));
- }
-
- public void testDump() {
- assertEquals("1.0\n", dump(1.0));
- }
-
- /**
- * to test http://code.google.com/p/snakeyaml/issues/detail?id=130
- */
- public void testScientificFloatWithoutDecimalDot() {
- assertEquals(new Double(8e-06), load("8e-06"));
- assertEquals(new Double(8e06), load("8e06"));
- assertEquals(new Double(8e06), load("8e+06"));
- assertEquals(new Double(8000e06), load("8_000e06"));
- assertEquals(new Double(123e-06), load("123e-06"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @see http://yaml.org/type/float.html
+ */
+public class FloatTagTest extends AbstractTest {
+
+ public void testFloat() {
+ assertEquals(new Double(6.8523015e+5), getMapValue("canonical: 6.8523015e+5", "canonical"));
+ assertEquals(new Double(6.8523015e+5),
+ getMapValue("exponentioal: 685.230_15e+03", "exponentioal"));
+ assertEquals(new Double(6.8523015e+5), getMapValue("fixed: 685_230.15", "fixed"));
+ assertEquals(new Double(6.8523015e+5),
+ getMapValue("sexagesimal: 190:20:30.15", "sexagesimal"));
+ assertEquals(Double.NEGATIVE_INFINITY,
+ getMapValue("negative infinity: -.inf", "negative infinity"));
+ assertEquals(Double.NaN, getMapValue("not a number: .NaN", "not a number"));
+ }
+
+ public void testFloatShorthand() {
+ assertEquals(new Double(1), getMapValue("number: !!float 1", "number"));
+ }
+
+ public void testFloatTag() {
+ assertEquals(new Double(1), getMapValue("number: !<tag:yaml.org,2002:float> 1", "number"));
+ }
+
+ public void testFloatOut() {
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("number", new Double(1));
+ String output = dump(map);
+ assertEquals("{number: 1.0}\n", output);
+ }
+
+ public void testBasicDoubleScalarLoad() {
+ assertEquals(new Double(47.0), load("47.0"));
+ assertEquals(new Double(0.0), load("0.0"));
+ assertEquals(new Double(-1.0), load("-1.0"));
+ }
+
+ public void testDumpStr() {
+ assertEquals("'1.0'\n", dump("1.0"));
+ }
+
+ public void testDump() {
+ assertEquals("1.0\n", dump(1.0));
+ }
+
+ /**
+ * to test http://code.google.com/p/snakeyaml/issues/detail?id=130
+ */
+ public void testScientificFloatWithoutDecimalDot() {
+ assertEquals(new Double(8e-06), load("8e-06"));
+ assertEquals(new Double(8e06), load("8e06"));
+ assertEquals(new Double(8e06), load("8e+06"));
+ assertEquals(new Double(8000e06), load("8_000e06"));
+ assertEquals(new Double(123e-06), load("123e-06"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/IntTagTest.java b/src/test/java/org/yaml/snakeyaml/types/IntTagTest.java
index dd71e38..ae4a373 100644
--- a/src/test/java/org/yaml/snakeyaml/types/IntTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/IntTagTest.java
@@ -1,66 +1,66 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.math.BigInteger;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @see http://yaml.org/type/int.html
- */
-public class IntTagTest extends AbstractTest {
-
- public void testInt() {
- assertEquals(new Integer(685230), getMapValue("canonical: 685230", "canonical"));
- assertEquals(new Integer(685230), getMapValue("number: 685_230", "number"));
- assertEquals(new Integer(685230), getMapValue("decimal: +685230", "decimal"));
- assertEquals(new Integer(-685230), getMapValue("number: -685230", "number"));
- assertEquals(new Integer(685230), getMapValue("octal: 02472256", "octal"));
- assertEquals(new Integer(685230), getMapValue("hexadecimal: 0x_0A_74_AE", "hexadecimal"));
- assertEquals(new Integer(685230),
- getMapValue("binary: 0b1010_0111_0100_1010_1110", "binary"));
- assertEquals(new Integer(685230), getMapValue("sexagesimal: 190:20:30", "sexagesimal"));
- assertEquals(new Integer(0), load("0"));
- assertEquals(new Integer(0), load("-0"));
- assertEquals(new Integer(0), load("+0"));
- assertEquals(Integer.MIN_VALUE, load(dump(Integer.MIN_VALUE)));
- assertEquals(Integer.MAX_VALUE, load(dump(Integer.MAX_VALUE)));
- }
-
- public void testBigInt() {
- assertEquals(new Long(922337203685477580L), load("922337203685477580"));
- assertEquals(new BigInteger("9223372036854775809999999999"),
- load("9223372036854775809999999999"));
- assertEquals(Long.MIN_VALUE, load("-9223372036854775808"));
- }
-
- public void testIntShorthand() {
- assertEquals(new Integer(1), getMapValue("number: !!int 1", "number"));
- }
-
- public void testIntTag() {
- assertEquals(new Integer(1), getMapValue("number: !<tag:yaml.org,2002:int> 1", "number"));
- }
-
- public void testIntOut() {
- Map<String, Integer> map = new HashMap<String, Integer>();
- map.put("number", new Integer(1));
- String output = dump(map);
- assertTrue(output.contains("number: 1"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.math.BigInteger;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @see http://yaml.org/type/int.html
+ */
+public class IntTagTest extends AbstractTest {
+
+ public void testInt() {
+ assertEquals(new Integer(685230), getMapValue("canonical: 685230", "canonical"));
+ assertEquals(new Integer(685230), getMapValue("number: 685_230", "number"));
+ assertEquals(new Integer(685230), getMapValue("decimal: +685230", "decimal"));
+ assertEquals(new Integer(-685230), getMapValue("number: -685230", "number"));
+ assertEquals(new Integer(685230), getMapValue("octal: 02472256", "octal"));
+ assertEquals(new Integer(685230), getMapValue("hexadecimal: 0x_0A_74_AE", "hexadecimal"));
+ assertEquals(new Integer(685230),
+ getMapValue("binary: 0b1010_0111_0100_1010_1110", "binary"));
+ assertEquals(new Integer(685230), getMapValue("sexagesimal: 190:20:30", "sexagesimal"));
+ assertEquals(new Integer(0), load("0"));
+ assertEquals(new Integer(0), load("-0"));
+ assertEquals(new Integer(0), load("+0"));
+ assertEquals(Integer.MIN_VALUE, load(dump(Integer.MIN_VALUE)));
+ assertEquals(Integer.MAX_VALUE, load(dump(Integer.MAX_VALUE)));
+ }
+
+ public void testBigInt() {
+ assertEquals(new Long(922337203685477580L), load("922337203685477580"));
+ assertEquals(new BigInteger("9223372036854775809999999999"),
+ load("9223372036854775809999999999"));
+ assertEquals(Long.MIN_VALUE, load("-9223372036854775808"));
+ }
+
+ public void testIntShorthand() {
+ assertEquals(new Integer(1), getMapValue("number: !!int 1", "number"));
+ }
+
+ public void testIntTag() {
+ assertEquals(new Integer(1), getMapValue("number: !<tag:yaml.org,2002:int> 1", "number"));
+ }
+
+ public void testIntOut() {
+ Map<String, Integer> map = new HashMap<String, Integer>();
+ map.put("number", new Integer(1));
+ String output = dump(map);
+ assertTrue(output.contains("number: 1"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/MapTagTest.java b/src/test/java/org/yaml/snakeyaml/types/MapTagTest.java
index ddeb73e..d2e1d9a 100644
--- a/src/test/java/org/yaml/snakeyaml/types/MapTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/MapTagTest.java
@@ -1,71 +1,71 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.Map;
-
-import org.yaml.snakeyaml.YamlDocument;
-
-/**
- * @see http://yaml.org/type/map.html
- */
-public class MapTagTest extends AbstractTest {
-
- @SuppressWarnings("unchecked")
- public void testMap() {
- YamlDocument document = new YamlDocument("types/map.yaml");
- Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) document
- .getNativeData();
- assertEquals(2, map.size());
- Map<String, String> map1 = (Map<String, String>) map.get("Block style");
- assertEquals(3, map1.size());
- assertEquals("Evans", map1.get("Clark"));
- assertEquals("Ingerson", map1.get("Brian"));
- assertEquals("Ben-Kiki", map1.get("Oren"));
- //
- Map<String, String> map2 = (Map<String, String>) map.get("Flow style");
- assertEquals(3, map2.size());
- assertEquals("Evans", map2.get("Clark"));
- assertEquals("Ingerson", map2.get("Brian"));
- assertEquals("Ben-Kiki", map2.get("Oren"));
- //
- assertEquals(map1, map2);
- assertNotSame(map1, map2);
- }
-
- @SuppressWarnings("unchecked")
- public void testMapYaml11() {
- YamlDocument document = new YamlDocument("types/map_mixed_tags.yaml");
- Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) document
- .getNativeData();
- assertEquals(2, map.size());
- Map<String, String> map1 = (Map<String, String>) map.get("Block style");
- assertEquals(3, map1.size());
- assertEquals("Evans", map1.get("Clark"));
- assertEquals("Ingerson", map1.get("Brian"));
- assertEquals("Ben-Kiki", map1.get("Oren"));
- //
- Map<String, String> map2 = (Map<String, String>) map.get("Flow style");
- assertEquals(3, map2.size());
- assertEquals("Evans", map2.get("Clark"));
- assertEquals("Ingerson", map2.get("Brian"));
- assertEquals("Ben-Kiki", map2.get("Oren"));
- //
- assertEquals(map1, map2);
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.Map;
+
+import org.yaml.snakeyaml.YamlDocument;
+
+/**
+ * @see http://yaml.org/type/map.html
+ */
+public class MapTagTest extends AbstractTest {
+
+ @SuppressWarnings("unchecked")
+ public void testMap() {
+ YamlDocument document = new YamlDocument("types/map.yaml");
+ Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) document
+ .getNativeData();
+ assertEquals(2, map.size());
+ Map<String, String> map1 = (Map<String, String>) map.get("Block style");
+ assertEquals(3, map1.size());
+ assertEquals("Evans", map1.get("Clark"));
+ assertEquals("Ingerson", map1.get("Brian"));
+ assertEquals("Ben-Kiki", map1.get("Oren"));
+ //
+ Map<String, String> map2 = (Map<String, String>) map.get("Flow style");
+ assertEquals(3, map2.size());
+ assertEquals("Evans", map2.get("Clark"));
+ assertEquals("Ingerson", map2.get("Brian"));
+ assertEquals("Ben-Kiki", map2.get("Oren"));
+ //
+ assertEquals(map1, map2);
+ assertNotSame(map1, map2);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testMapYaml11() {
+ YamlDocument document = new YamlDocument("types/map_mixed_tags.yaml");
+ Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) document
+ .getNativeData();
+ assertEquals(2, map.size());
+ Map<String, String> map1 = (Map<String, String>) map.get("Block style");
+ assertEquals(3, map1.size());
+ assertEquals("Evans", map1.get("Clark"));
+ assertEquals("Ingerson", map1.get("Brian"));
+ assertEquals("Ben-Kiki", map1.get("Oren"));
+ //
+ Map<String, String> map2 = (Map<String, String>) map.get("Flow style");
+ assertEquals(3, map2.size());
+ assertEquals("Evans", map2.get("Clark"));
+ assertEquals("Ingerson", map2.get("Brian"));
+ assertEquals("Ben-Kiki", map2.get("Oren"));
+ //
+ assertEquals(map1, map2);
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/MergeTagTest.java b/src/test/java/org/yaml/snakeyaml/types/MergeTagTest.java
index ff23711..8fdc1c0 100644
--- a/src/test/java/org/yaml/snakeyaml/types/MergeTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/MergeTagTest.java
@@ -1,71 +1,71 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.YamlDocument;
-
-/**
- * @see http://yaml.org/type/merge.html
- */
-public class MergeTagTest extends AbstractTest {
-
- @SuppressWarnings("unchecked")
- public void testMerge() {
- YamlDocument document = new YamlDocument("types/merge.yaml");
- List<Object> list = (List<Object>) document.getNativeData();
- assertEquals(8, list.size());
- Map<Object, Object> center = (Map<Object, Object>) list.get(0);
- assertEquals(2, center.size());
- assertEquals(new Integer(1), center.get("x"));
- assertEquals(new Integer(2), center.get("y"));
- //
- Map<Object, Object> left = (Map<Object, Object>) list.get(1);
- assertEquals(2, left.size());
- assertEquals(left.get("x").getClass().toString(), new Integer(0), left.get("x"));
- assertEquals(new Integer(2), left.get("y"));
- //
- Map<Object, Object> big = (Map<Object, Object>) list.get(2);
- assertEquals(1, big.size());
- assertEquals(new Integer(10), big.get("r"));
- //
- Map<Object, Object> small = (Map<Object, Object>) list.get(3);
- assertEquals(1, small.size());
- assertEquals(new Integer(1), small.get("r"));
- // Explicit keys
- Map<Object, Object> explicit = (Map<Object, Object>) list.get(4);
- assertEquals(4, explicit.size());
- assertEquals(new Integer(1), explicit.get("x"));
- assertEquals(new Integer(2), explicit.get("y"));
- assertEquals(new Integer(10), explicit.get("r"));
- assertEquals("center/big", explicit.get("label"));
- // Merge one map
- Map<Object, Object> merged1 = (Map<Object, Object>) list.get(5);
- assertEquals(explicit, merged1);
- assertNotSame(explicit, merged1);
- // Merge multiple maps
- Map<Object, Object> merged2 = (Map<Object, Object>) list.get(6);
- assertEquals(explicit, merged2);
- assertNotSame(explicit, merged2);
- // Override
- Map<Object, Object> merged3 = (Map<Object, Object>) list.get(7);
- assertEquals(explicit, merged3);
- assertNotSame(explicit, merged3);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.YamlDocument;
+
+/**
+ * @see http://yaml.org/type/merge.html
+ */
+public class MergeTagTest extends AbstractTest {
+
+ @SuppressWarnings("unchecked")
+ public void testMerge() {
+ YamlDocument document = new YamlDocument("types/merge.yaml");
+ List<Object> list = (List<Object>) document.getNativeData();
+ assertEquals(8, list.size());
+ Map<Object, Object> center = (Map<Object, Object>) list.get(0);
+ assertEquals(2, center.size());
+ assertEquals(new Integer(1), center.get("x"));
+ assertEquals(new Integer(2), center.get("y"));
+ //
+ Map<Object, Object> left = (Map<Object, Object>) list.get(1);
+ assertEquals(2, left.size());
+ assertEquals(left.get("x").getClass().toString(), new Integer(0), left.get("x"));
+ assertEquals(new Integer(2), left.get("y"));
+ //
+ Map<Object, Object> big = (Map<Object, Object>) list.get(2);
+ assertEquals(1, big.size());
+ assertEquals(new Integer(10), big.get("r"));
+ //
+ Map<Object, Object> small = (Map<Object, Object>) list.get(3);
+ assertEquals(1, small.size());
+ assertEquals(new Integer(1), small.get("r"));
+ // Explicit keys
+ Map<Object, Object> explicit = (Map<Object, Object>) list.get(4);
+ assertEquals(4, explicit.size());
+ assertEquals(new Integer(1), explicit.get("x"));
+ assertEquals(new Integer(2), explicit.get("y"));
+ assertEquals(new Integer(10), explicit.get("r"));
+ assertEquals("center/big", explicit.get("label"));
+ // Merge one map
+ Map<Object, Object> merged1 = (Map<Object, Object>) list.get(5);
+ assertEquals(explicit, merged1);
+ assertNotSame(explicit, merged1);
+ // Merge multiple maps
+ Map<Object, Object> merged2 = (Map<Object, Object>) list.get(6);
+ assertEquals(explicit, merged2);
+ assertNotSame(explicit, merged2);
+ // Override
+ Map<Object, Object> merged3 = (Map<Object, Object>) list.get(7);
+ assertEquals(explicit, merged3);
+ assertNotSame(explicit, merged3);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/NullTagTest.java b/src/test/java/org/yaml/snakeyaml/types/NullTagTest.java
index 0510c78..25cfcb1 100644
--- a/src/test/java/org/yaml/snakeyaml/types/NullTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/NullTagTest.java
@@ -1,153 +1,153 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.FlowStyle;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.nodes.Node;
-import org.yaml.snakeyaml.nodes.Tag;
-import org.yaml.snakeyaml.representer.Represent;
-import org.yaml.snakeyaml.representer.Representer;
-
-/**
- * @see http://yaml.org/type/null.html
- */
-public class NullTagTest extends AbstractTest {
-
- public void testNull() {
- assertNull("Got: '" + load("---\n") + "'", load("---\n"));
- assertNull(load("---\n..."));
- assertNull(load("---\n...\n"));
- assertNull(load("\n"));
- assertNull(load(""));
- assertNull(load(" "));
- assertNull(load("~"));
- assertNull(load("---\n~"));
- assertNull(load("null"));
- assertNull(load("Null"));
- assertNull(load("NULL"));
- assertNull(getMapValue("empty:\n", "empty"));
- assertNull(getMapValue("canonical: ~", "canonical"));
- assertNull(getMapValue("english: null", "english"));
- assertNull(getMapValue("english: Null", "english"));
- assertNull(getMapValue("english: NULL", "english"));
- assertEquals("null key", getMapValue("~: null key\n", null));
- }
-
- @SuppressWarnings("unchecked")
- public void testSequenceNull() {
- String input = "---\n# This sequence has five\n# entries, two have values.\nsparse:\n - ~\n - 2nd entry\n -\n - 4th entry\n - Null\n";
- List<String> parsed = (List<String>) getMapValue(input, "sparse");
- assertEquals(5, parsed.size());
- assertNull(parsed.get(0));
- assertEquals("2nd entry", parsed.get(1));
- assertNull("Got: '" + parsed.get(2) + "'", parsed.get(2));
- assertEquals("4th entry", parsed.get(3));
- assertNull(parsed.get(4));
- }
-
- public void testNullInMap() {
- String input = "key1: null\n~: value1";
- Map<String, Object> parsed = getMap(input);
- assertEquals(2, parsed.size());
- assertTrue(parsed.containsKey(null));
- Object value1 = parsed.get(null);
- assertEquals("value1", value1);
- //
- assertNull(parsed.get("key1"));
- //
- assertFalse(getMap("key2: value2").containsKey(null));
- }
-
- public void testNullShorthand() {
- assertNull(getMapValue("nothing: !!null null", "nothing"));
- }
-
- public void testNullTag() {
- assertNull(getMapValue("nothing: !<tag:yaml.org,2002:null> null", "nothing"));
- }
-
- public void testNullOut() {
- String output = dump(null);
- assertEquals("null\n", output);
- }
-
- public void testNullOutAsEmpty() {
- Yaml yaml = new Yaml(new NullRepresenter());
- String output = yaml.dump(null);
- assertEquals("", output);
- }
-
- /**
- * test flow style
- */
- public void testNullOutAsEmpty2() {
- Yaml yaml = new Yaml(new NullRepresenter());
- Map<String, String> map = new HashMap<String, String>();
- map.put("aaa", "foo");
- map.put("bbb", null);
- String output = yaml.dump(map);
- assertEquals("{aaa: foo, bbb: !!null ''}\n", output);
- }
-
- /**
- * test block style
- */
- public void testBoolOutAsEmpty3() {
- DumperOptions options = new DumperOptions();
- options.setDefaultFlowStyle(FlowStyle.BLOCK);
- Yaml yaml = new Yaml(new NullRepresenter(), options);
- Map<String, String> map = new HashMap<String, String>();
- map.put("aaa", "foo");
- map.put("bbb", null);
- String output = yaml.dump(map);
- assertEquals("aaa: foo\nbbb:\n", output);
- }
-
- private class NullRepresenter extends Representer {
- public NullRepresenter() {
- super();
- // null representer is exceptional and it is stored as an instance
- // variable.
- this.nullRepresenter = new RepresentNull();
- }
-
- private class RepresentNull implements Represent {
- public Node representData(Object data) {
- // possible values are here http://yaml.org/type/null.html
- return representScalar(Tag.NULL, "");
- }
- }
- }
-
- public void testNoAnchors() {
- List<String> list = new ArrayList<String>(3);
- list.add(null);
- list.add("value");
- list.add(null);
- Yaml yaml = new Yaml();
- String output = yaml.dump(list);
- assertEquals("Null values must not get anchors and aliases.", "[null, value, null]\n",
- output);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.FlowStyle;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.nodes.Node;
+import org.yaml.snakeyaml.nodes.Tag;
+import org.yaml.snakeyaml.representer.Represent;
+import org.yaml.snakeyaml.representer.Representer;
+
+/**
+ * @see http://yaml.org/type/null.html
+ */
+public class NullTagTest extends AbstractTest {
+
+ public void testNull() {
+ assertNull("Got: '" + load("---\n") + "'", load("---\n"));
+ assertNull(load("---\n..."));
+ assertNull(load("---\n...\n"));
+ assertNull(load("\n"));
+ assertNull(load(""));
+ assertNull(load(" "));
+ assertNull(load("~"));
+ assertNull(load("---\n~"));
+ assertNull(load("null"));
+ assertNull(load("Null"));
+ assertNull(load("NULL"));
+ assertNull(getMapValue("empty:\n", "empty"));
+ assertNull(getMapValue("canonical: ~", "canonical"));
+ assertNull(getMapValue("english: null", "english"));
+ assertNull(getMapValue("english: Null", "english"));
+ assertNull(getMapValue("english: NULL", "english"));
+ assertEquals("null key", getMapValue("~: null key\n", null));
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testSequenceNull() {
+ String input = "---\n# This sequence has five\n# entries, two have values.\nsparse:\n - ~\n - 2nd entry\n -\n - 4th entry\n - Null\n";
+ List<String> parsed = (List<String>) getMapValue(input, "sparse");
+ assertEquals(5, parsed.size());
+ assertNull(parsed.get(0));
+ assertEquals("2nd entry", parsed.get(1));
+ assertNull("Got: '" + parsed.get(2) + "'", parsed.get(2));
+ assertEquals("4th entry", parsed.get(3));
+ assertNull(parsed.get(4));
+ }
+
+ public void testNullInMap() {
+ String input = "key1: null\n~: value1";
+ Map<String, Object> parsed = getMap(input);
+ assertEquals(2, parsed.size());
+ assertTrue(parsed.containsKey(null));
+ Object value1 = parsed.get(null);
+ assertEquals("value1", value1);
+ //
+ assertNull(parsed.get("key1"));
+ //
+ assertFalse(getMap("key2: value2").containsKey(null));
+ }
+
+ public void testNullShorthand() {
+ assertNull(getMapValue("nothing: !!null null", "nothing"));
+ }
+
+ public void testNullTag() {
+ assertNull(getMapValue("nothing: !<tag:yaml.org,2002:null> null", "nothing"));
+ }
+
+ public void testNullOut() {
+ String output = dump(null);
+ assertEquals("null\n", output);
+ }
+
+ public void testNullOutAsEmpty() {
+ Yaml yaml = new Yaml(new NullRepresenter());
+ String output = yaml.dump(null);
+ assertEquals("", output);
+ }
+
+ /**
+ * test flow style
+ */
+ public void testNullOutAsEmpty2() {
+ Yaml yaml = new Yaml(new NullRepresenter());
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("aaa", "foo");
+ map.put("bbb", null);
+ String output = yaml.dump(map);
+ assertEquals("{aaa: foo, bbb: !!null ''}\n", output);
+ }
+
+ /**
+ * test block style
+ */
+ public void testBoolOutAsEmpty3() {
+ DumperOptions options = new DumperOptions();
+ options.setDefaultFlowStyle(FlowStyle.BLOCK);
+ Yaml yaml = new Yaml(new NullRepresenter(), options);
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("aaa", "foo");
+ map.put("bbb", null);
+ String output = yaml.dump(map);
+ assertEquals("aaa: foo\nbbb:\n", output);
+ }
+
+ private class NullRepresenter extends Representer {
+ public NullRepresenter() {
+ super();
+ // null representer is exceptional and it is stored as an instance
+ // variable.
+ this.nullRepresenter = new RepresentNull();
+ }
+
+ private class RepresentNull implements Represent {
+ public Node representData(Object data) {
+ // possible values are here http://yaml.org/type/null.html
+ return representScalar(Tag.NULL, "");
+ }
+ }
+ }
+
+ public void testNoAnchors() {
+ List<String> list = new ArrayList<String>(3);
+ list.add(null);
+ list.add("value");
+ list.add(null);
+ Yaml yaml = new Yaml();
+ String output = yaml.dump(list);
+ assertEquals("Null values must not get anchors and aliases.", "[null, value, null]\n",
+ output);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/OmapTagTest.java b/src/test/java/org/yaml/snakeyaml/types/OmapTagTest.java
index d10c73e..2beac6e 100644
--- a/src/test/java/org/yaml/snakeyaml/types/OmapTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/OmapTagTest.java
@@ -1,47 +1,47 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.Map;
-
-import org.yaml.snakeyaml.YamlDocument;
-
-/**
- * @see http://yaml.org/type/omap.html
- */
-public class OmapTagTest extends AbstractTest {
-
- @SuppressWarnings("unchecked")
- public void testOmap() {
- YamlDocument document = new YamlDocument("types/omap.yaml");
- Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) document
- .getNativeData();
- assertEquals(2, map.size());
- Map<String, String> map1 = (Map<String, String>) map.get("Bestiary");
- assertEquals(3, map1.size());
- assertEquals("African pig-like ant eater. Ugly.", map1.get("aardvark"));
- assertEquals("South-American ant eater. Two species.", map1.get("anteater"));
- assertEquals("South-American constrictor snake. Scaly.", map1.get("anaconda"));
- //
- Map<String, String> map2 = (Map<String, String>) map.get("Numbers");
- assertEquals(3, map2.size());
- assertEquals(new Integer(1), map2.get("one"));
- assertEquals(new Integer(2), map2.get("two"));
- assertEquals(new Integer(3), map2.get("three"));
- }
-
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.Map;
+
+import org.yaml.snakeyaml.YamlDocument;
+
+/**
+ * @see http://yaml.org/type/omap.html
+ */
+public class OmapTagTest extends AbstractTest {
+
+ @SuppressWarnings("unchecked")
+ public void testOmap() {
+ YamlDocument document = new YamlDocument("types/omap.yaml");
+ Map<String, Map<String, String>> map = (Map<String, Map<String, String>>) document
+ .getNativeData();
+ assertEquals(2, map.size());
+ Map<String, String> map1 = (Map<String, String>) map.get("Bestiary");
+ assertEquals(3, map1.size());
+ assertEquals("African pig-like ant eater. Ugly.", map1.get("aardvark"));
+ assertEquals("South-American ant eater. Two species.", map1.get("anteater"));
+ assertEquals("South-American constrictor snake. Scaly.", map1.get("anaconda"));
+ //
+ Map<String, String> map2 = (Map<String, String>) map.get("Numbers");
+ assertEquals(3, map2.size());
+ assertEquals(new Integer(1), map2.get("one"));
+ assertEquals(new Integer(2), map2.get("two"));
+ assertEquals(new Integer(3), map2.get("three"));
+ }
+
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/PairsTagTest.java b/src/test/java/org/yaml/snakeyaml/types/PairsTagTest.java
index c1b846c..f3d5f52 100644
--- a/src/test/java/org/yaml/snakeyaml/types/PairsTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/PairsTagTest.java
@@ -1,71 +1,71 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.YamlDocument;
-
-/**
- * @see http://yaml.org/type/pairs.html
- */
-public class PairsTagTest extends AbstractTest {
-
- @SuppressWarnings("unchecked")
- public void testPairs() {
- YamlDocument document = new YamlDocument("types/pairs.yaml", false);
- Map<String, List<String[]>> map = (Map<String, List<String[]>>) document.getNativeData();
- assertEquals(2, map.size());
- List<String[]> list1 = (List<String[]>) map.get("Block tasks");
- assertEquals(4, list1.size());
- Object[] tuple1 = list1.get(0);
- assertEquals(2, tuple1.length);
- assertEquals("meeting", tuple1[0]);
- assertEquals("with team.", tuple1[1]);
- //
-
- Object[] tuple2 = list1.get(1);
- assertEquals(2, tuple2.length);
- assertEquals("meeting", tuple2[0]);
- assertEquals("with boss.", tuple2[1]);
- //
-
- Object[] tuple3 = list1.get(2);
- assertEquals(2, tuple3.length);
- assertEquals("break", tuple3[0]);
- assertEquals("lunch.", tuple3[1]);
- //
-
- Object[] tuple4 = list1.get(3);
- assertEquals(2, tuple4.length);
- assertEquals("meeting", tuple4[0]);
- assertEquals("with client.", tuple4[1]);
- //
- List<String[]> list2 = (List<String[]>) map.get("Flow tasks");
- assertEquals(2, list2.size());
- Object[] tuple2_1 = list2.get(0);
- assertEquals(2, tuple2_1.length);
- assertEquals("meeting", tuple2_1[0]);
- assertEquals("with team", tuple2_1[1]);
- //
- Object[] tuple2_2 = list2.get(1);
- assertEquals(2, tuple2_2.length);
- assertEquals("meeting", tuple2_2[0]);
- assertEquals("with boss", tuple2_2[1]);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.YamlDocument;
+
+/**
+ * @see http://yaml.org/type/pairs.html
+ */
+public class PairsTagTest extends AbstractTest {
+
+ @SuppressWarnings("unchecked")
+ public void testPairs() {
+ YamlDocument document = new YamlDocument("types/pairs.yaml", false);
+ Map<String, List<String[]>> map = (Map<String, List<String[]>>) document.getNativeData();
+ assertEquals(2, map.size());
+ List<String[]> list1 = (List<String[]>) map.get("Block tasks");
+ assertEquals(4, list1.size());
+ Object[] tuple1 = list1.get(0);
+ assertEquals(2, tuple1.length);
+ assertEquals("meeting", tuple1[0]);
+ assertEquals("with team.", tuple1[1]);
+ //
+
+ Object[] tuple2 = list1.get(1);
+ assertEquals(2, tuple2.length);
+ assertEquals("meeting", tuple2[0]);
+ assertEquals("with boss.", tuple2[1]);
+ //
+
+ Object[] tuple3 = list1.get(2);
+ assertEquals(2, tuple3.length);
+ assertEquals("break", tuple3[0]);
+ assertEquals("lunch.", tuple3[1]);
+ //
+
+ Object[] tuple4 = list1.get(3);
+ assertEquals(2, tuple4.length);
+ assertEquals("meeting", tuple4[0]);
+ assertEquals("with client.", tuple4[1]);
+ //
+ List<String[]> list2 = (List<String[]>) map.get("Flow tasks");
+ assertEquals(2, list2.size());
+ Object[] tuple2_1 = list2.get(0);
+ assertEquals(2, tuple2_1.length);
+ assertEquals("meeting", tuple2_1[0]);
+ assertEquals("with team", tuple2_1[1]);
+ //
+ Object[] tuple2_2 = list2.get(1);
+ assertEquals(2, tuple2_2.length);
+ assertEquals("meeting", tuple2_2[0]);
+ assertEquals("with boss", tuple2_2[1]);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/SeqTagTest.java b/src/test/java/org/yaml/snakeyaml/types/SeqTagTest.java
index e46f597..1558b88 100644
--- a/src/test/java/org/yaml/snakeyaml/types/SeqTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/SeqTagTest.java
@@ -1,107 +1,107 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.YamlDocument;
-
-/**
- * @see http://yaml.org/type/seq.html
- */
-public class SeqTagTest extends AbstractTest {
-
- @SuppressWarnings("unchecked")
- public void testSeq() {
- YamlDocument document = new YamlDocument("types/seq.yaml");
- Map<String, List<String>> map = (Map<String, List<String>>) document.getNativeData();
- assertEquals(2, map.size());
- List<String> list1 = (List<String>) map.get("Block style");
- assertEquals(9, list1.size());
- assertEquals("Mercury", list1.get(0));
- assertEquals("Venus", list1.get(1));
- assertEquals("Earth", list1.get(2));
- assertEquals("Mars", list1.get(3));
- assertEquals("Jupiter", list1.get(4));
- assertEquals("Saturn", list1.get(5));
- assertEquals("Uranus", list1.get(6));
- assertEquals("Neptune", list1.get(7));
- assertEquals("Pluto", list1.get(8));
- //
- List<String> list2 = (List<String>) map.get("Flow style");
- assertEquals(9, list2.size());
- assertEquals("Mercury", list2.get(0));
- assertEquals("Venus", list2.get(1));
- assertEquals("Earth", list2.get(2));
- assertEquals("Mars", list2.get(3));
- assertEquals("Jupiter", list2.get(4));
- assertEquals("Saturn", list2.get(5));
- assertEquals("Uranus", list2.get(6));
- assertEquals("Neptune", list2.get(7));
- assertEquals("Pluto", list2.get(8));
- //
- assertEquals(list1, list2);
- assertNotSame(list1, list2);
- }
-
- @SuppressWarnings("unchecked")
- public void testCollection() {
- Collection<Integer> collection = new LinkedList<Integer>();
- collection.add(1);
- collection.add(2);
- collection.add(3);
- String output = dump(collection);
- assertEquals("[1, 2, 3]\n", output);
- Collection<Integer> obj = (Collection<Integer>) load(output);
- // System.out.println(obj);
- assertEquals(3, obj.size());
- assertTrue("Create ArrayList by default: " + obj.getClass().toString(),
- obj instanceof ArrayList);
- }
-
- public void testArray() {
- Integer[] array = new Integer[3];
- array[0] = new Integer(1);
- array[1] = new Integer(1);
- array[2] = new Integer(2);
- String output = dump(array);
- assertEquals("[1, 1, 2]\n", output);
- }
-
- public void testStringArray() {
- String[] array = new String[] { "aaa", "bbb", "ccc" };
- String output = dump(array);
- assertEquals("[aaa, bbb, ccc]\n", output);
- }
-
- public void testArrayPrimitives() {
- int[] array = new int[3];
- array[0] = 1;
- array[1] = 1;
- array[2] = 2;
- try {
- dump(array);
- fail("Arrays of primitives are not supported.");
- } catch (RuntimeException e) {
- assertEquals("Arrays of primitives are not fully supported.", e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.YamlDocument;
+
+/**
+ * @see http://yaml.org/type/seq.html
+ */
+public class SeqTagTest extends AbstractTest {
+
+ @SuppressWarnings("unchecked")
+ public void testSeq() {
+ YamlDocument document = new YamlDocument("types/seq.yaml");
+ Map<String, List<String>> map = (Map<String, List<String>>) document.getNativeData();
+ assertEquals(2, map.size());
+ List<String> list1 = (List<String>) map.get("Block style");
+ assertEquals(9, list1.size());
+ assertEquals("Mercury", list1.get(0));
+ assertEquals("Venus", list1.get(1));
+ assertEquals("Earth", list1.get(2));
+ assertEquals("Mars", list1.get(3));
+ assertEquals("Jupiter", list1.get(4));
+ assertEquals("Saturn", list1.get(5));
+ assertEquals("Uranus", list1.get(6));
+ assertEquals("Neptune", list1.get(7));
+ assertEquals("Pluto", list1.get(8));
+ //
+ List<String> list2 = (List<String>) map.get("Flow style");
+ assertEquals(9, list2.size());
+ assertEquals("Mercury", list2.get(0));
+ assertEquals("Venus", list2.get(1));
+ assertEquals("Earth", list2.get(2));
+ assertEquals("Mars", list2.get(3));
+ assertEquals("Jupiter", list2.get(4));
+ assertEquals("Saturn", list2.get(5));
+ assertEquals("Uranus", list2.get(6));
+ assertEquals("Neptune", list2.get(7));
+ assertEquals("Pluto", list2.get(8));
+ //
+ assertEquals(list1, list2);
+ assertNotSame(list1, list2);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void testCollection() {
+ Collection<Integer> collection = new LinkedList<Integer>();
+ collection.add(1);
+ collection.add(2);
+ collection.add(3);
+ String output = dump(collection);
+ assertEquals("[1, 2, 3]\n", output);
+ Collection<Integer> obj = (Collection<Integer>) load(output);
+ // System.out.println(obj);
+ assertEquals(3, obj.size());
+ assertTrue("Create ArrayList by default: " + obj.getClass().toString(),
+ obj instanceof ArrayList);
+ }
+
+ public void testArray() {
+ Integer[] array = new Integer[3];
+ array[0] = new Integer(1);
+ array[1] = new Integer(1);
+ array[2] = new Integer(2);
+ String output = dump(array);
+ assertEquals("[1, 1, 2]\n", output);
+ }
+
+ public void testStringArray() {
+ String[] array = new String[] { "aaa", "bbb", "ccc" };
+ String output = dump(array);
+ assertEquals("[aaa, bbb, ccc]\n", output);
+ }
+
+ public void testArrayPrimitives() {
+ int[] array = new int[3];
+ array[0] = 1;
+ array[1] = 1;
+ array[2] = 2;
+ try {
+ dump(array);
+ fail("Arrays of primitives are not supported.");
+ } catch (RuntimeException e) {
+ assertEquals("Arrays of primitives are not fully supported.", e.getMessage());
+ }
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/SetTagTest.java b/src/test/java/org/yaml/snakeyaml/types/SetTagTest.java
index 995f0f8..1a1516d 100644
--- a/src/test/java/org/yaml/snakeyaml/types/SetTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/SetTagTest.java
@@ -1,46 +1,46 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.yaml.snakeyaml.YamlDocument;
-
-/**
- * @see http://yaml.org/type/set.html
- */
-public class SetTagTest extends AbstractTest {
-
- @SuppressWarnings("unchecked")
- public void testSet() {
- YamlDocument document = new YamlDocument("types/set.yaml");
- Map<String, Set<String>> map = (Map<String, Set<String>>) document.getNativeData();
- assertEquals(2, map.size());
- Set<String> set1 = (Set<String>) map.get("baseball players");
- assertEquals(3, set1.size());
- assertTrue(set1.contains("Mark McGwire"));
- assertTrue(set1.contains("Sammy Sosa"));
- assertTrue(set1.contains("Ken Griffey"));
- //
- Set<String> set2 = (Set<String>) map.get("baseball teams");
- assertEquals(3, set2.size());
- assertTrue(set2.contains("Boston Red Sox"));
- assertTrue(set2.contains("Detroit Tigers"));
- assertTrue(set2.contains("New York Yankees"));
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.Map;
+import java.util.Set;
+
+import org.yaml.snakeyaml.YamlDocument;
+
+/**
+ * @see http://yaml.org/type/set.html
+ */
+public class SetTagTest extends AbstractTest {
+
+ @SuppressWarnings("unchecked")
+ public void testSet() {
+ YamlDocument document = new YamlDocument("types/set.yaml");
+ Map<String, Set<String>> map = (Map<String, Set<String>>) document.getNativeData();
+ assertEquals(2, map.size());
+ Set<String> set1 = (Set<String>) map.get("baseball players");
+ assertEquals(3, set1.size());
+ assertTrue(set1.contains("Mark McGwire"));
+ assertTrue(set1.contains("Sammy Sosa"));
+ assertTrue(set1.contains("Ken Griffey"));
+ //
+ Set<String> set2 = (Set<String>) map.get("baseball teams");
+ assertEquals(3, set2.size());
+ assertTrue(set2.contains("Boston Red Sox"));
+ assertTrue(set2.contains("Detroit Tigers"));
+ assertTrue(set2.contains("New York Yankees"));
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/StrTagTest.java b/src/test/java/org/yaml/snakeyaml/types/StrTagTest.java
index fd6c852..d0fff76 100644
--- a/src/test/java/org/yaml/snakeyaml/types/StrTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/StrTagTest.java
@@ -1,174 +1,174 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.io.ByteArrayOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.DumperOptions;
-import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
-import org.yaml.snakeyaml.Yaml;
-
-/**
- * @see http://yaml.org/type/str.html
- */
-public class StrTagTest extends AbstractTest {
- private String getData(String data, String key) {
- return (String) getMapValue(data, key);
- }
-
- public void testString() {
- assertEquals("abcd", getData("string: abcd", "string"));
- }
-
- public void testStringShorthand() {
- assertEquals("abcd", getData("string: !!str abcd", "string"));
- }
-
- public void testStringTag() {
- assertEquals("abcd", getData("string: !<tag:yaml.org,2002:str> abcd", "string"));
- }
-
- public void testUnicode() {
- // escaped 8-bit unicode character (u-umlaut):
- assertEquals("\u00fc", load("\"\\xfc\""));
- assertEquals("\\xfc", load("\\xfc"));
-
- // 2 escaped 8-bit unicode characters (u-umlaut following by e-grave):
- assertEquals("\u00fc\u00e8", load("\"\\xfc\\xe8\""));
-
- // escaped 16-bit unicode character (em dash):
- assertEquals("\u2014", load("\"\\u2014\""));
-
- // UTF-32 encoding is explicitly not supported
- assertEquals("\\U2014AAAA", load("'\\U2014AAAA'"));
-
- // (and I don't have a surrogate pair handy at the moment)
- // raw unicode characters in the stream (em dash)
- assertEquals("\u2014", load("\u2014"));
- }
-
- /**
- * @see http://code.google.com/p/jvyamlb/issues/detail?id=6
- */
- @SuppressWarnings("unchecked")
- public void testIssueId6() {
- Map<String, String> map = (Map<String, String>) load("---\ntest: |-\n \"Test\r\r (* error here)\"");
- assertEquals("\"Test\n\n(* error here)\"", map.get("test"));
- }
-
- public void testStrDump() {
- assertEquals("abc\n", dump("abc"));
- }
-
- public void testUnicodeDump() {
- assertEquals("\\u263a\n", dump("\\u263a"));
- assertEquals("The leading zero must be preserved.", "\\u063a\n", dump("\\u063a"));
- }
-
- public void testStringIntOut() {
- Map<String, String> map = new HashMap<String, String>();
- map.put("number", "1");
- String output = dump(map);
- assertTrue(output, output.contains("number: '1'"));
- }
-
- public void testStringFloatOut() {
- Map<String, String> map = new HashMap<String, String>();
- map.put("number", "1.1");
- String output = dump(map);
- assertTrue(output, output.contains("number: '1.1'"));
- }
-
- public void testStringBoolOut() {
- Map<String, String> map = new HashMap<String, String>();
- map.put("number", "True");
- String output = dump(map);
- assertTrue(output, output.contains("number: 'True'"));
- }
-
- public void testEmitLongString() {
- String str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
- String output = dump(str);
- assertEquals(str + "\n", output);
- }
-
- public void testEmitLongStringWithCR() {
- String str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\n";
- String output = dump(str);
- assertEquals("|+\n " + str, output);
- }
-
- public void testEmitDoubleQuoted() {
- String str = "\"xx\"";
- String output = dump(str);
- assertEquals("'" + str + "'\n", output);
- }
-
- /**
- * http://pyyaml.org/ticket/196
- */
- public void testEmitQuoted() {
- List<String> list = new ArrayList<String>(3);
- list.add("This is an 'example'.");
- list.add("This is an \"example\".");
- list.add("123");
- String output = dump(list);
- assertEquals("[This is an 'example'., This is an \"example\"., '123']\n", output);
- // single quoted
- DumperOptions options = new DumperOptions();
- options.setDefaultScalarStyle(ScalarStyle.SINGLE_QUOTED);
- Yaml yaml = new Yaml(options);
- String output2 = yaml.dump(list);
- // System.out.println(output2);
- assertEquals("- 'This is an ''example''.'\n- 'This is an \"example\".'\n- '123'\n", output2);
- // double quoted
- DumperOptions options2 = new DumperOptions();
- options2.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
- yaml = new Yaml(options2);
- String output3 = yaml.dump(list);
- // System.out.println(output2);
- assertEquals("- \"This is an 'example'.\"\n- \"This is an \\\"example\\\".\"\n- \"123\"\n",
- output3);
- }
-
- public void testEmitEndOfLine() {
- String str = "xxxxxxx\n";
- String output = dump(str);
- assertEquals("|\n " + str, output);
- }
-
- public void testDumpUtf16() throws UnsupportedEncodingException {
- String str = "xxx";
- assertEquals(3, str.toString().length());
- Yaml yaml = new Yaml();
- Charset charset = Charset.forName("UTF-16");
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- Writer writer = new OutputStreamWriter(stream, charset);
- yaml.dump(str, writer);
- assertEquals(str + "\n", stream.toString("UTF-16"));
- assertEquals("Must include BOM: " + stream.toString(), (1 + 3 + 1) * 2, stream.toString()
- .length());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.UnsupportedEncodingException;
+import java.io.Writer;
+import java.nio.charset.Charset;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.DumperOptions;
+import org.yaml.snakeyaml.DumperOptions.ScalarStyle;
+import org.yaml.snakeyaml.Yaml;
+
+/**
+ * @see http://yaml.org/type/str.html
+ */
+public class StrTagTest extends AbstractTest {
+ private String getData(String data, String key) {
+ return (String) getMapValue(data, key);
+ }
+
+ public void testString() {
+ assertEquals("abcd", getData("string: abcd", "string"));
+ }
+
+ public void testStringShorthand() {
+ assertEquals("abcd", getData("string: !!str abcd", "string"));
+ }
+
+ public void testStringTag() {
+ assertEquals("abcd", getData("string: !<tag:yaml.org,2002:str> abcd", "string"));
+ }
+
+ public void testUnicode() {
+ // escaped 8-bit unicode character (u-umlaut):
+ assertEquals("\u00fc", load("\"\\xfc\""));
+ assertEquals("\\xfc", load("\\xfc"));
+
+ // 2 escaped 8-bit unicode characters (u-umlaut following by e-grave):
+ assertEquals("\u00fc\u00e8", load("\"\\xfc\\xe8\""));
+
+ // escaped 16-bit unicode character (em dash):
+ assertEquals("\u2014", load("\"\\u2014\""));
+
+ // UTF-32 encoding is explicitly not supported
+ assertEquals("\\U2014AAAA", load("'\\U2014AAAA'"));
+
+ // (and I don't have a surrogate pair handy at the moment)
+ // raw unicode characters in the stream (em dash)
+ assertEquals("\u2014", load("\u2014"));
+ }
+
+ /**
+ * @see http://code.google.com/p/jvyamlb/issues/detail?id=6
+ */
+ @SuppressWarnings("unchecked")
+ public void testIssueId6() {
+ Map<String, String> map = (Map<String, String>) load("---\ntest: |-\n \"Test\r\r (* error here)\"");
+ assertEquals("\"Test\n\n(* error here)\"", map.get("test"));
+ }
+
+ public void testStrDump() {
+ assertEquals("abc\n", dump("abc"));
+ }
+
+ public void testUnicodeDump() {
+ assertEquals("\\u263a\n", dump("\\u263a"));
+ assertEquals("The leading zero must be preserved.", "\\u063a\n", dump("\\u063a"));
+ }
+
+ public void testStringIntOut() {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("number", "1");
+ String output = dump(map);
+ assertTrue(output, output.contains("number: '1'"));
+ }
+
+ public void testStringFloatOut() {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("number", "1.1");
+ String output = dump(map);
+ assertTrue(output, output.contains("number: '1.1'"));
+ }
+
+ public void testStringBoolOut() {
+ Map<String, String> map = new HashMap<String, String>();
+ map.put("number", "True");
+ String output = dump(map);
+ assertTrue(output, output.contains("number: 'True'"));
+ }
+
+ public void testEmitLongString() {
+ String str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+ String output = dump(str);
+ assertEquals(str + "\n", output);
+ }
+
+ public void testEmitLongStringWithCR() {
+ String str = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\n\n";
+ String output = dump(str);
+ assertEquals("|+\n " + str, output);
+ }
+
+ public void testEmitDoubleQuoted() {
+ String str = "\"xx\"";
+ String output = dump(str);
+ assertEquals("'" + str + "'\n", output);
+ }
+
+ /**
+ * http://pyyaml.org/ticket/196
+ */
+ public void testEmitQuoted() {
+ List<String> list = new ArrayList<String>(3);
+ list.add("This is an 'example'.");
+ list.add("This is an \"example\".");
+ list.add("123");
+ String output = dump(list);
+ assertEquals("[This is an 'example'., This is an \"example\"., '123']\n", output);
+ // single quoted
+ DumperOptions options = new DumperOptions();
+ options.setDefaultScalarStyle(ScalarStyle.SINGLE_QUOTED);
+ Yaml yaml = new Yaml(options);
+ String output2 = yaml.dump(list);
+ // System.out.println(output2);
+ assertEquals("- 'This is an ''example''.'\n- 'This is an \"example\".'\n- '123'\n", output2);
+ // double quoted
+ DumperOptions options2 = new DumperOptions();
+ options2.setDefaultScalarStyle(ScalarStyle.DOUBLE_QUOTED);
+ yaml = new Yaml(options2);
+ String output3 = yaml.dump(list);
+ // System.out.println(output2);
+ assertEquals("- \"This is an 'example'.\"\n- \"This is an \\\"example\\\".\"\n- \"123\"\n",
+ output3);
+ }
+
+ public void testEmitEndOfLine() {
+ String str = "xxxxxxx\n";
+ String output = dump(str);
+ assertEquals("|\n " + str, output);
+ }
+
+ public void testDumpUtf16() throws UnsupportedEncodingException {
+ String str = "xxx";
+ assertEquals(3, str.toString().length());
+ Yaml yaml = new Yaml();
+ Charset charset = Charset.forName("UTF-16");
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ Writer writer = new OutputStreamWriter(stream, charset);
+ yaml.dump(str, writer);
+ assertEquals(str + "\n", stream.toString("UTF-16"));
+ assertEquals("Must include BOM: " + stream.toString(), (1 + 3 + 1) * 2, stream.toString()
+ .length());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/TimestampTagTest.java b/src/test/java/org/yaml/snakeyaml/types/TimestampTagTest.java
index f95d2f5..b9ab8b2 100644
--- a/src/test/java/org/yaml/snakeyaml/types/TimestampTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/TimestampTagTest.java
@@ -1,124 +1,124 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-/**
- * @see http://yaml.org/type/timestamp.html
- */
-public class TimestampTagTest extends AbstractTest {
-
- public void testTimestamp() {
- assertEquals("2001-12-15 at 2:59:43 (100)",
- getText("canonical: 2001-12-15T02:59:43.1Z", "canonical"));
- // zero miliseconds
- assertEquals("2001-12-15 at 2:59:43 (0)",
- getText("canonical: 2001-12-15T02:59:43.000Z", "canonical"));
- assertEquals("2001-12-15 at 2:59:43 (100)",
- getText("valid iso8601: 2001-12-14t21:59:43.10-05:00", "valid iso8601"));
- // half hour time zone
- assertEquals("2001-12-14 at 22:29:43 (100)",
- getText("valid iso8601: 2001-12-14t21:59:43.10-0:30", "valid iso8601"));
- // + time zone
- assertEquals("2001-12-14 at 19:59:43 (100)",
- getText("valid iso8601: 2001-12-14t21:59:43.10+2:00", "valid iso8601"));
- assertEquals("2001-12-15 at 2:59:43 (100)",
- getText("space separated: 2001-12-14 21:59:43.10 -5", "space separated"));
- assertEquals("2001-12-15 at 2:59:43 (100)",
- getText("no time zone (Z): 2001-12-15 2:59:43.10", "no time zone (Z)"));
- assertEquals("2002-12-14 at 0:0:0 (0)",
- getText("date (00:00:00Z): 2002-12-14", "date (00:00:00Z)"));
- assertEquals("2010-5-16 at 3:6:11 (3)",
- getText("milliseconds: 2010-05-16 03:06:11.003", "milliseconds"));
- assertEquals("2010-5-16 at 3:6:11 (7)",
- getText("milliseconds: 2010-05-16 03:06:11.0068", "milliseconds"));
- assertEquals("2010-5-16 at 3:6:11 (0)",
- getText("milliseconds: 2010-05-16 03:06:11.0000", "milliseconds"));
- assertEquals("2010-5-16 at 3:6:11 (0)",
- getText("milliseconds: 2010-05-16 03:06:11.0004", "milliseconds"));
- assertEquals("2010-5-16 at 3:6:11 (25)",
- getText("milliseconds: 2010-05-16 03:06:11.0250", "milliseconds"));
- }
-
- public void testTimestampShorthand() {
- assertTrue(getMapValue("canonical: !!timestamp 2001-12-15T02:59:43.1Z", "canonical") instanceof Date);
- }
-
- public void testTimestampTag() {
- assertTrue(getMapValue("canonical: !<tag:yaml.org,2002:timestamp> 2001-12-15T02:59:43.1Z",
- "canonical") instanceof Date);
- }
-
- public void testTimestampOut() {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Moscow"));
- cal.clear();
- cal.set(2008, 8, 23, 14, 35, 4);
- Date date = cal.getTime();
- String output = dump(date);
- assertEquals("2008-09-23T10:35:04Z\n", output);
- }
-
- public void testTimestampOutMap() {
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Moscow"));
- cal.clear();
- cal.set(2008, 8, 23, 14, 35, 4);
- Date date = cal.getTime();
- Map<String, Date> map = new HashMap<String, Date>();
- map.put("canonical", date);
- String output = dump(map);
- assertEquals("{canonical: !!timestamp '2008-09-23T10:35:04Z'}\n", output);
- }
-
- private String getText(String yaml, String key) {
- Date date = (Date) getMapValue(yaml, key);
- Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
- cal.setTime(date);
- int years = cal.get(Calendar.YEAR);
- int months = cal.get(Calendar.MONTH) + 1; // 0..12
- int days = cal.get(Calendar.DAY_OF_MONTH); // 1..31
- int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..24
- int minutes = cal.get(Calendar.MINUTE); // 0..59
- int seconds = cal.get(Calendar.SECOND); // 0..59
- int millis = cal.get(Calendar.MILLISECOND);
- String result = String.valueOf(years) + "-" + String.valueOf(months) + "-"
- + String.valueOf(days) + " at " + String.valueOf(hour24) + ":"
- + String.valueOf(minutes) + ":" + String.valueOf(seconds) + " ("
- + String.valueOf(millis) + ")";
- return result;
- }
-
- public void testTimestampReadWrite() {
- Date date = (Date) getMapValue("Time: 2001-11-23 15:01:42 -5", "Time");
- Map<String, Date> map = new HashMap<String, Date>();
- map.put("canonical", date);
- String output = dump(map);
- assertEquals("{canonical: !!timestamp '2001-11-23T20:01:42Z'}\n", output);
- }
-
- public void testSqlDate() {
- java.sql.Date date = new java.sql.Date(1000000000000L);
- Map<String, java.sql.Date> map = new HashMap<String, java.sql.Date>();
- map.put("canonical", date);
- String output = dump(map);
- assertEquals("{canonical: !!timestamp '2001-09-09T01:46:40Z'}\n", output);
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+/**
+ * @see http://yaml.org/type/timestamp.html
+ */
+public class TimestampTagTest extends AbstractTest {
+
+ public void testTimestamp() {
+ assertEquals("2001-12-15 at 2:59:43 (100)",
+ getText("canonical: 2001-12-15T02:59:43.1Z", "canonical"));
+ // zero miliseconds
+ assertEquals("2001-12-15 at 2:59:43 (0)",
+ getText("canonical: 2001-12-15T02:59:43.000Z", "canonical"));
+ assertEquals("2001-12-15 at 2:59:43 (100)",
+ getText("valid iso8601: 2001-12-14t21:59:43.10-05:00", "valid iso8601"));
+ // half hour time zone
+ assertEquals("2001-12-14 at 22:29:43 (100)",
+ getText("valid iso8601: 2001-12-14t21:59:43.10-0:30", "valid iso8601"));
+ // + time zone
+ assertEquals("2001-12-14 at 19:59:43 (100)",
+ getText("valid iso8601: 2001-12-14t21:59:43.10+2:00", "valid iso8601"));
+ assertEquals("2001-12-15 at 2:59:43 (100)",
+ getText("space separated: 2001-12-14 21:59:43.10 -5", "space separated"));
+ assertEquals("2001-12-15 at 2:59:43 (100)",
+ getText("no time zone (Z): 2001-12-15 2:59:43.10", "no time zone (Z)"));
+ assertEquals("2002-12-14 at 0:0:0 (0)",
+ getText("date (00:00:00Z): 2002-12-14", "date (00:00:00Z)"));
+ assertEquals("2010-5-16 at 3:6:11 (3)",
+ getText("milliseconds: 2010-05-16 03:06:11.003", "milliseconds"));
+ assertEquals("2010-5-16 at 3:6:11 (7)",
+ getText("milliseconds: 2010-05-16 03:06:11.0068", "milliseconds"));
+ assertEquals("2010-5-16 at 3:6:11 (0)",
+ getText("milliseconds: 2010-05-16 03:06:11.0000", "milliseconds"));
+ assertEquals("2010-5-16 at 3:6:11 (0)",
+ getText("milliseconds: 2010-05-16 03:06:11.0004", "milliseconds"));
+ assertEquals("2010-5-16 at 3:6:11 (25)",
+ getText("milliseconds: 2010-05-16 03:06:11.0250", "milliseconds"));
+ }
+
+ public void testTimestampShorthand() {
+ assertTrue(getMapValue("canonical: !!timestamp 2001-12-15T02:59:43.1Z", "canonical") instanceof Date);
+ }
+
+ public void testTimestampTag() {
+ assertTrue(getMapValue("canonical: !<tag:yaml.org,2002:timestamp> 2001-12-15T02:59:43.1Z",
+ "canonical") instanceof Date);
+ }
+
+ public void testTimestampOut() {
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Moscow"));
+ cal.clear();
+ cal.set(2008, 8, 23, 14, 35, 4);
+ Date date = cal.getTime();
+ String output = dump(date);
+ assertEquals("2008-09-23T10:35:04Z\n", output);
+ }
+
+ public void testTimestampOutMap() {
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Moscow"));
+ cal.clear();
+ cal.set(2008, 8, 23, 14, 35, 4);
+ Date date = cal.getTime();
+ Map<String, Date> map = new HashMap<String, Date>();
+ map.put("canonical", date);
+ String output = dump(map);
+ assertEquals("{canonical: !!timestamp '2008-09-23T10:35:04Z'}\n", output);
+ }
+
+ private String getText(String yaml, String key) {
+ Date date = (Date) getMapValue(yaml, key);
+ Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ cal.setTime(date);
+ int years = cal.get(Calendar.YEAR);
+ int months = cal.get(Calendar.MONTH) + 1; // 0..12
+ int days = cal.get(Calendar.DAY_OF_MONTH); // 1..31
+ int hour24 = cal.get(Calendar.HOUR_OF_DAY); // 0..24
+ int minutes = cal.get(Calendar.MINUTE); // 0..59
+ int seconds = cal.get(Calendar.SECOND); // 0..59
+ int millis = cal.get(Calendar.MILLISECOND);
+ String result = String.valueOf(years) + "-" + String.valueOf(months) + "-"
+ + String.valueOf(days) + " at " + String.valueOf(hour24) + ":"
+ + String.valueOf(minutes) + ":" + String.valueOf(seconds) + " ("
+ + String.valueOf(millis) + ")";
+ return result;
+ }
+
+ public void testTimestampReadWrite() {
+ Date date = (Date) getMapValue("Time: 2001-11-23 15:01:42 -5", "Time");
+ Map<String, Date> map = new HashMap<String, Date>();
+ map.put("canonical", date);
+ String output = dump(map);
+ assertEquals("{canonical: !!timestamp '2001-11-23T20:01:42Z'}\n", output);
+ }
+
+ public void testSqlDate() {
+ java.sql.Date date = new java.sql.Date(1000000000000L);
+ Map<String, java.sql.Date> map = new HashMap<String, java.sql.Date>();
+ map.put("canonical", date);
+ String output = dump(map);
+ assertEquals("{canonical: !!timestamp '2001-09-09T01:46:40Z'}\n", output);
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/types/ValueTagTest.java b/src/test/java/org/yaml/snakeyaml/types/ValueTagTest.java
index 012e2ea..18df721 100644
--- a/src/test/java/org/yaml/snakeyaml/types/ValueTagTest.java
+++ b/src/test/java/org/yaml/snakeyaml/types/ValueTagTest.java
@@ -1,61 +1,61 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.types;
-
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.YamlDocument;
-
-/**
- * @see http://yaml.org/type/value.html
- */
-public class ValueTagTest extends AbstractTest {
-
- /**
- * The 'value' tag does not work as defined in the specification but exactly
- * as in PyYAML
- */
- @SuppressWarnings("unchecked")
- public void testValue() {
- InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
- YamlDocument.ROOT + "types/value.yaml");
- Yaml yaml = new Yaml();
- Iterator<Object> iter = (Iterator<Object>) yaml.loadAll(input).iterator();
- Map<String, List<String>> oldSchema = (Map<String, List<String>>) iter.next();
- assertEquals(1, oldSchema.size());
- List<String> list = oldSchema.get("link with");
- assertEquals(2, list.size());
- assertEquals("library1.dll", list.get(0));
- assertEquals("library2.dll", list.get(1));
- //
- Map<String, List<Map<String, String>>> newSchema = (Map<String, List<Map<String, String>>>) iter
- .next();
- assertEquals(1, newSchema.size());
- //
- List<Map<String, String>> list2 = newSchema.get("link with");
- assertEquals(2, list2.size());
- Map<String, String> map1 = list2.get(0);
- assertEquals(2, map1.size());
- assertEquals("library1.dll", map1.get("="));
- assertEquals(new Double(1.2), map1.get("version"));
- assertFalse(iter.hasNext());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.types;
+
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.YamlDocument;
+
+/**
+ * @see http://yaml.org/type/value.html
+ */
+public class ValueTagTest extends AbstractTest {
+
+ /**
+ * The 'value' tag does not work as defined in the specification but exactly
+ * as in PyYAML
+ */
+ @SuppressWarnings("unchecked")
+ public void testValue() {
+ InputStream input = YamlDocument.class.getClassLoader().getResourceAsStream(
+ YamlDocument.ROOT + "types/value.yaml");
+ Yaml yaml = new Yaml();
+ Iterator<Object> iter = (Iterator<Object>) yaml.loadAll(input).iterator();
+ Map<String, List<String>> oldSchema = (Map<String, List<String>>) iter.next();
+ assertEquals(1, oldSchema.size());
+ List<String> list = oldSchema.get("link with");
+ assertEquals(2, list.size());
+ assertEquals("library1.dll", list.get(0));
+ assertEquals("library2.dll", list.get(1));
+ //
+ Map<String, List<Map<String, String>>> newSchema = (Map<String, List<Map<String, String>>>) iter
+ .next();
+ assertEquals(1, newSchema.size());
+ //
+ List<Map<String, String>> list2 = newSchema.get("link with");
+ assertEquals(2, list2.size());
+ Map<String, String> map1 = list2.get(0);
+ assertEquals(2, map1.size());
+ assertEquals("library1.dll", map1.get("="));
+ assertEquals(new Double(1.2), map1.get("version"));
+ assertFalse(iter.hasNext());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/util/ArrayStackTest.java b/src/test/java/org/yaml/snakeyaml/util/ArrayStackTest.java
index 4d07ff0..9ad7554 100644
--- a/src/test/java/org/yaml/snakeyaml/util/ArrayStackTest.java
+++ b/src/test/java/org/yaml/snakeyaml/util/ArrayStackTest.java
@@ -1,32 +1,32 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.util;
-
-import junit.framework.TestCase;
-
-public class ArrayStackTest extends TestCase {
-
- public void testClear() {
- ArrayStack<Integer> stack = new ArrayStack<Integer>(25);
- assertTrue(stack.isEmpty());
- stack.push(new Integer(1));
- stack.push(new Integer(2));
- assertFalse(stack.isEmpty());
- stack.clear();
- assertTrue(stack.isEmpty());
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.util;
+
+import junit.framework.TestCase;
+
+public class ArrayStackTest extends TestCase {
+
+ public void testClear() {
+ ArrayStack<Integer> stack = new ArrayStack<Integer>(25);
+ assertTrue(stack.isEmpty());
+ stack.push(new Integer(1));
+ stack.push(new Integer(2));
+ assertFalse(stack.isEmpty());
+ stack.clear();
+ assertTrue(stack.isEmpty());
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/util/UriEncoderTest.java b/src/test/java/org/yaml/snakeyaml/util/UriEncoderTest.java
index 4c5db90..9dd2092 100644
--- a/src/test/java/org/yaml/snakeyaml/util/UriEncoderTest.java
+++ b/src/test/java/org/yaml/snakeyaml/util/UriEncoderTest.java
@@ -1,52 +1,52 @@
-/**
- * Copyright (c) 2008-2011, http://www.snakeyaml.org
- *
- * 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.yaml.snakeyaml.util;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.CharacterCodingException;
-
-import junit.framework.TestCase;
-
-public class UriEncoderTest extends TestCase {
-
- public void testEncode() {
- assertEquals("Acad%C3%A9mico", UriEncoder.encode("Académico"));
- assertEquals("Check http://yaml.org/spec/1.1/#escaping%20in%20URI/", "[]",
- UriEncoder.encode("[]"));
- }
-
- public void testDecode() throws CharacterCodingException {
- ByteBuffer buff = ByteBuffer.allocate(10);
- buff.put((byte) 0x34);
- buff.put((byte) 0x35);
- buff.flip();
- assertEquals("45", UriEncoder.decode(buff));
- }
-
- public void testFailDecode() throws CharacterCodingException {
- ByteBuffer buff = ByteBuffer.allocate(10);
- buff.put((byte) 0x34);
- buff.put((byte) 0xC1);
- buff.flip();
- try {
- UriEncoder.decode(buff);
- fail("Invalid UTF-8 must not be accepted.");
- } catch (Exception e) {
- assertEquals("Input length = 1", e.getMessage());
- }
- }
-}
+/**
+ * Copyright (c) 2008-2011, http://www.snakeyaml.org
+ *
+ * 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.yaml.snakeyaml.util;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.CharacterCodingException;
+
+import junit.framework.TestCase;
+
+public class UriEncoderTest extends TestCase {
+
+ public void testEncode() {
+ assertEquals("Acad%C3%A9mico", UriEncoder.encode("Académico"));
+ assertEquals("Check http://yaml.org/spec/1.1/#escaping%20in%20URI/", "[]",
+ UriEncoder.encode("[]"));
+ }
+
+ public void testDecode() throws CharacterCodingException {
+ ByteBuffer buff = ByteBuffer.allocate(10);
+ buff.put((byte) 0x34);
+ buff.put((byte) 0x35);
+ buff.flip();
+ assertEquals("45", UriEncoder.decode(buff));
+ }
+
+ public void testFailDecode() throws CharacterCodingException {
+ ByteBuffer buff = ByteBuffer.allocate(10);
+ buff.put((byte) 0x34);
+ buff.put((byte) 0xC1);
+ buff.flip();
+ try {
+ UriEncoder.decode(buff);
+ fail("Invalid UTF-8 must not be accepted.");
+ } catch (Exception e) {
+ assertEquals("Input length = 1", e.getMessage());
+ }
+ }
+}
diff --git a/src/test/resources/compactnotation/error1.yaml b/src/test/resources/compactnotation/error1.yaml
index d3edca0..1107bc9 100644
--- a/src/test/resources/compactnotation/error1.yaml
+++ b/src/test/resources/compactnotation/error1.yaml
@@ -1,2 +1,2 @@
-Table(id12, A table)
-
+Table(id12, A table)
+
diff --git a/src/test/resources/compactnotation/error2.yaml b/src/test/resources/compactnotation/error2.yaml
index a43b6cb..2f3fa3e 100644
--- a/src/test/resources/compactnotation/error2.yaml
+++ b/src/test/resources/compactnotation/error2.yaml
@@ -1,2 +1,2 @@
-Table(id12)
-
+Table(id12)
+
diff --git a/src/test/resources/compactnotation/error3.yaml b/src/test/resources/compactnotation/error3.yaml
index 17d3a7a..c97fa44 100644
--- a/src/test/resources/compactnotation/error3.yaml
+++ b/src/test/resources/compactnotation/error3.yaml
@@ -1,2 +1,2 @@
-Table(id12, orders):
- - Row(id111, size=17, description=text)
+Table(id12, orders):
+ - Row(id111, size=17, description=text)
diff --git a/src/test/resources/compactnotation/error4.yaml b/src/test/resources/compactnotation/error4.yaml
index ff29937..0cd4995 100644
--- a/src/test/resources/compactnotation/error4.yaml
+++ b/src/test/resources/compactnotation/error4.yaml
@@ -1,4 +1,4 @@
-Table(id12, table):
- - Row(id111, description = text) {size: 15}
-
-
+Table(id12, table):
+ - Row(id111, description = text) {size: 15}
+
+
diff --git a/src/test/resources/compactnotation/error5.yaml b/src/test/resources/compactnotation/error5.yaml
index a5e82a1..68c081d 100644
--- a/src/test/resources/compactnotation/error5.yaml
+++ b/src/test/resources/compactnotation/error5.yaml
@@ -1,11 +1,11 @@
-Table(id12, table):
- - Row(id222):
- size: 17
- ratio: 0.333
- description: >
- We do not need new lines
- here, just replace them
- all with spaces
-
-
-
+Table(id12, table):
+ - Row(id222):
+ size: 17
+ ratio: 0.333
+ description: >
+ We do not need new lines
+ here, just replace them
+ all with spaces
+
+
+
diff --git a/src/test/resources/compactnotation/error6.yaml b/src/test/resources/compactnotation/error6.yaml
index 897db39..f17ecfb 100644
--- a/src/test/resources/compactnotation/error6.yaml
+++ b/src/test/resources/compactnotation/error6.yaml
@@ -1,4 +1,4 @@
-Table(id12, table, foo=bar)
-
-
-
+Table(id12, table, foo=bar)
+
+
+
diff --git a/src/test/resources/compactnotation/error7.yaml b/src/test/resources/compactnotation/error7.yaml
index 521fc59..bf0f8c0 100644
--- a/src/test/resources/compactnotation/error7.yaml
+++ b/src/test/resources/compactnotation/error7.yaml
@@ -1,5 +1,5 @@
-Table(id12, table):
- foo: bar
-
-
-
+Table(id12, table):
+ foo: bar
+
+
+
diff --git a/src/test/resources/compactnotation/error8.yaml b/src/test/resources/compactnotation/error8.yaml
index 9a84ab9..382d5e4 100644
--- a/src/test/resources/compactnotation/error8.yaml
+++ b/src/test/resources/compactnotation/error8.yaml
@@ -1,11 +1,11 @@
-Row(id12):
- - Row(id222):
- size: 17
- ratio: 0.333
- description: >
- We do not need new lines
- here, just replace them
- all with spaces
-
-
-
+Row(id12):
+ - Row(id222):
+ size: 17
+ ratio: 0.333
+ description: >
+ We do not need new lines
+ here, just replace them
+ all with spaces
+
+
+
diff --git a/src/test/resources/compactnotation/error9.yaml b/src/test/resources/compactnotation/error9.yaml
index 241c2fa..d8a3ae9 100644
--- a/src/test/resources/compactnotation/error9.yaml
+++ b/src/test/resources/compactnotation/error9.yaml
@@ -1,11 +1,11 @@
-ManyListsTable(id12):
- - Row(id111, description = text)
- - Row(id222):
- size: 17
- ratio: 0.333
- description: >
- We do not need new lines
- here, just replace them
- all with spaces
-
-
+ManyListsTable(id12):
+ - Row(id111, description = text)
+ - Row(id222):
+ size: 17
+ ratio: 0.333
+ description: >
+ We do not need new lines
+ here, just replace them
+ all with spaces
+
+
diff --git a/src/test/resources/compactnotation/example1.yaml b/src/test/resources/compactnotation/example1.yaml
index 485f14c..c6a6ae5 100644
--- a/src/test/resources/compactnotation/example1.yaml
+++ b/src/test/resources/compactnotation/example1.yaml
@@ -1 +1 @@
-org.yaml.snakeyaml.extensions.compactnotation.Container(name=parent, id=123)
+org.yaml.snakeyaml.extensions.compactnotation.Container(name=parent, id=123)
diff --git a/src/test/resources/compactnotation/example10.yaml b/src/test/resources/compactnotation/example10.yaml
index f1f9e0a..03b94c2 100644
--- a/src/test/resources/compactnotation/example10.yaml
+++ b/src/test/resources/compactnotation/example10.yaml
@@ -1,5 +1,5 @@
-something:
- - org.yaml.snakeyaml.extensions.compactnotation.Container(t7, id=id7): { name: child7 }
- - org.yaml.snakeyaml.extensions.compactnotation.Container(t9, id=id9): { name: child9 }
- - org.yaml.snakeyaml.extensions.compactnotation.Container(t10, id=id10): { name: child10 }
-
+something:
+ - org.yaml.snakeyaml.extensions.compactnotation.Container(t7, id=id7): { name: child7 }
+ - org.yaml.snakeyaml.extensions.compactnotation.Container(t9, id=id9): { name: child9 }
+ - org.yaml.snakeyaml.extensions.compactnotation.Container(t10, id=id10): { name: child10 }
+
diff --git a/src/test/resources/compactnotation/example11.yaml b/src/test/resources/compactnotation/example11.yaml
index 3e3bb19..6b09d2d 100644
--- a/src/test/resources/compactnotation/example11.yaml
+++ b/src/test/resources/compactnotation/example11.yaml
@@ -1,4 +1,4 @@
-Box(id11, Main box):
- top: Item(id003, price=25.0, name=parrot)
- bottom: Item(id004, price=3.5, name=sweet)
-
+Box(id11, Main box):
+ top: Item(id003, price=25.0, name=parrot)
+ bottom: Item(id004, price=3.5, name=sweet)
+
diff --git a/src/test/resources/compactnotation/example12.yaml b/src/test/resources/compactnotation/example12.yaml
index 737c0df..1c2797d 100644
--- a/src/test/resources/compactnotation/example12.yaml
+++ b/src/test/resources/compactnotation/example12.yaml
@@ -1,17 +1,17 @@
-Table(id12, A table):
- - Row(id111, description = I think; therefore I am.): {size: 15, ratio: 0.125}
- - Row(id222):
- size: 17
- ratio: 0.333
- description: >
- We do not need new lines
- here, just replace them
- all with spaces
- - Row(id333):
- size: 52
- ratio: 0.88
- description: |-
- Please preserve all
- the lines because they may be
- important, but do not include the last one !!!
-
+Table(id12, A table):
+ - Row(id111, description = I think; therefore I am.): {size: 15, ratio: 0.125}
+ - Row(id222):
+ size: 17
+ ratio: 0.333
+ description: >
+ We do not need new lines
+ here, just replace them
+ all with spaces
+ - Row(id333):
+ size: 52
+ ratio: 0.88
+ description: |-
+ Please preserve all
+ the lines because they may be
+ important, but do not include the last one !!!
+
diff --git a/src/test/resources/compactnotation/example2.yaml b/src/test/resources/compactnotation/example2.yaml
index 26919ad..6105cd0 100644
--- a/src/test/resources/compactnotation/example2.yaml
+++ b/src/test/resources/compactnotation/example2.yaml
@@ -1 +1 @@
-org.yaml.snakeyaml.extensions.compactnotation.Container(title)
+org.yaml.snakeyaml.extensions.compactnotation.Container(title)
diff --git a/src/test/resources/compactnotation/example4.yaml b/src/test/resources/compactnotation/example4.yaml
index 430169d..3c3f25f 100644
--- a/src/test/resources/compactnotation/example4.yaml
+++ b/src/test/resources/compactnotation/example4.yaml
@@ -1,2 +1,2 @@
-org.yaml.snakeyaml.extensions.compactnotation.Container(title4, name=parent4, id=444):
- name: child4
+org.yaml.snakeyaml.extensions.compactnotation.Container(title4, name=parent4, id=444):
+ name: child4
diff --git a/src/test/resources/compactnotation/example5.yaml b/src/test/resources/compactnotation/example5.yaml
index 229d12e..21dd668 100644
--- a/src/test/resources/compactnotation/example5.yaml
+++ b/src/test/resources/compactnotation/example5.yaml
@@ -1,4 +1,4 @@
-org.yaml.snakeyaml.extensions.compactnotation.Container(title4):
- name: child5
- id: ID555
-
+org.yaml.snakeyaml.extensions.compactnotation.Container(title4):
+ name: child5
+ id: ID555
+
diff --git a/src/test/resources/compactnotation/example6.yaml b/src/test/resources/compactnotation/example6.yaml
index 50d1475..e29f097 100644
--- a/src/test/resources/compactnotation/example6.yaml
+++ b/src/test/resources/compactnotation/example6.yaml
@@ -1,2 +1,2 @@
-org.yaml.snakeyaml.extensions.compactnotation.Container(title4): { name: child6, id: ID6}
-
+org.yaml.snakeyaml.extensions.compactnotation.Container(title4): { name: child6, id: ID6}
+
diff --git a/src/test/resources/compactnotation/example7.yaml b/src/test/resources/compactnotation/example7.yaml
index f11cab7..86dd082 100644
--- a/src/test/resources/compactnotation/example7.yaml
+++ b/src/test/resources/compactnotation/example7.yaml
@@ -1,2 +1,2 @@
-org.yaml.snakeyaml.extensions.compactnotation.Container(The title, id=id7): { name: child7 }
-
+org.yaml.snakeyaml.extensions.compactnotation.Container(The title, id=id7): { name: child7 }
+
diff --git a/src/test/resources/compactnotation/example9.yaml b/src/test/resources/compactnotation/example9.yaml
index 4b0808b..3dd6e6f 100644
--- a/src/test/resources/compactnotation/example9.yaml
+++ b/src/test/resources/compactnotation/example9.yaml
@@ -1,4 +1,4 @@
-something:
- org.yaml.snakeyaml.extensions.compactnotation.Container(t7, id=id7): { name: child7 }
- org.yaml.snakeyaml.extensions.compactnotation.Container(t9, id=id9): { name: child9 }
-
+something:
+ org.yaml.snakeyaml.extensions.compactnotation.Container(t7, id=id7): { name: child7 }
+ org.yaml.snakeyaml.extensions.compactnotation.Container(t9, id=id9): { name: child9 }
+
diff --git a/src/test/resources/constructor/car-no-root-class-map.yaml b/src/test/resources/constructor/car-no-root-class-map.yaml
index a2b9f31..7677d1b 100644
--- a/src/test/resources/constructor/car-no-root-class-map.yaml
+++ b/src/test/resources/constructor/car-no-root-class-map.yaml
@@ -1,15 +1,15 @@
-plate: 00-FF-Q2
-wheels:
- ? {brand: Pirelli, id: 1}
- : 2008-01-16
- ? {brand: Dunkel, id: 2}
- : 2002-12-24
- ? {brand: Pirelli, id: 3}
- : 2008-01-16
- ? {brand: Pirelli, id: 4}
- : 2008-01-16
- ? {brand: Pirelli, id: 5}
- : 2008-01-16
-windows:
- front: 0
+plate: 00-FF-Q2
+wheels:
+ ? {brand: Pirelli, id: 1}
+ : 2008-01-16
+ ? {brand: Dunkel, id: 2}
+ : 2002-12-24
+ ? {brand: Pirelli, id: 3}
+ : 2008-01-16
+ ? {brand: Pirelli, id: 4}
+ : 2008-01-16
+ ? {brand: Pirelli, id: 5}
+ : 2008-01-16
+windows:
+ front: 0
back: 1
\ No newline at end of file
diff --git a/src/test/resources/constructor/car-no-root-class.yaml b/src/test/resources/constructor/car-no-root-class.yaml
index a645194..9fcc390 100644
--- a/src/test/resources/constructor/car-no-root-class.yaml
+++ b/src/test/resources/constructor/car-no-root-class.yaml
@@ -1,8 +1,8 @@
-# No root class defined
-plate: 12-XP-F4
-wheels:
-- {id: 1}
-- {id: 2}
-- {id: 3}
-- {id: 4}
+# No root class defined
+plate: 12-XP-F4
+wheels:
+- {id: 1}
+- {id: 2}
+- {id: 3}
+- {id: 4}
- {id: 5}
\ No newline at end of file
diff --git a/src/test/resources/constructor/car-with-tags.yaml b/src/test/resources/constructor/car-with-tags.yaml
index 2f7e823..886c55b 100644
--- a/src/test/resources/constructor/car-with-tags.yaml
+++ b/src/test/resources/constructor/car-with-tags.yaml
@@ -1,8 +1,8 @@
-!!org.yaml.snakeyaml.constructor.Car
-plate: 12-XP-F4
-wheels:
-- {id: 1}
-- {id: 2}
-- {id: 3}
-- {id: 4}
+!!org.yaml.snakeyaml.constructor.Car
+plate: 12-XP-F4
+wheels:
+- {id: 1}
+- {id: 2}
+- {id: 3}
+- {id: 4}
- {id: 5}
\ No newline at end of file
diff --git a/src/test/resources/constructor/car-without-root-tag.yaml b/src/test/resources/constructor/car-without-root-tag.yaml
index b91b184..852a888 100644
--- a/src/test/resources/constructor/car-without-root-tag.yaml
+++ b/src/test/resources/constructor/car-without-root-tag.yaml
@@ -1,5 +1,5 @@
-map: {id: 3}
-part: null
-plate: 12-XP-F4
-wheel: {id: 2}
+map: {id: 3}
+part: null
+plate: 12-XP-F4
+wheel: {id: 2}
year: '2008'
\ No newline at end of file
diff --git a/src/test/resources/constructor/car-without-tags.yaml b/src/test/resources/constructor/car-without-tags.yaml
index 20f5556..6f515c5 100644
--- a/src/test/resources/constructor/car-without-tags.yaml
+++ b/src/test/resources/constructor/car-without-tags.yaml
@@ -1,8 +1,8 @@
-!car
-plate: 12-XP-F4
-wheels:
-- {id: 1}
-- {id: 2}
-- {id: 3}
-- {id: 4}
+!car
+plate: 12-XP-F4
+wheels:
+- {id: 1}
+- {id: 2}
+- {id: 3}
+- {id: 4}
- {id: 5}
\ No newline at end of file
diff --git a/src/test/resources/constructor/cararray-with-tags-flow-auto.yaml b/src/test/resources/constructor/cararray-with-tags-flow-auto.yaml
index fed7cda..b658266 100644
--- a/src/test/resources/constructor/cararray-with-tags-flow-auto.yaml
+++ b/src/test/resources/constructor/cararray-with-tags-flow-auto.yaml
@@ -1,8 +1,8 @@
-!!org.yaml.snakeyaml.constructor.ArrayTagsTest$CarWithArray
-plate: 12-XP-F4
-wheels:
-- {id: 1}
-- {id: 2}
-- {id: 3}
-- {id: 4}
+!!org.yaml.snakeyaml.constructor.ArrayTagsTest$CarWithArray
+plate: 12-XP-F4
+wheels:
+- {id: 1}
+- {id: 2}
+- {id: 3}
+- {id: 4}
- {id: 5}
\ No newline at end of file
diff --git a/src/test/resources/constructor/cararray-with-tags.yaml b/src/test/resources/constructor/cararray-with-tags.yaml
index f3a8c03..0ee6472 100644
--- a/src/test/resources/constructor/cararray-with-tags.yaml
+++ b/src/test/resources/constructor/cararray-with-tags.yaml
@@ -1,8 +1,8 @@
-!!org.yaml.snakeyaml.constructor.ArrayTagsTest$CarWithArray
-plate: 12-XP-F4
-wheels:
-- id: 1
-- id: 2
-- id: 3
-- id: 4
+!!org.yaml.snakeyaml.constructor.ArrayTagsTest$CarWithArray
+plate: 12-XP-F4
+wheels:
+- id: 1
+- id: 2
+- id: 3
+- id: 4
- id: 5
\ No newline at end of file
diff --git a/src/test/resources/constructor/carwheel-root-map.yaml b/src/test/resources/constructor/carwheel-root-map.yaml
index d7ea885..f5eb144 100644
--- a/src/test/resources/constructor/carwheel-root-map.yaml
+++ b/src/test/resources/constructor/carwheel-root-map.yaml
@@ -1,3 +1,3 @@
-wheel: !!org.yaml.snakeyaml.constructor.Wheel {id: 2}
-map: {id: 3}
-plate: 12-XP-F4
+wheel: !!org.yaml.snakeyaml.constructor.Wheel {id: 2}
+map: {id: 3}
+plate: 12-XP-F4
diff --git a/src/test/resources/constructor/carwheel-without-tags.yaml b/src/test/resources/constructor/carwheel-without-tags.yaml
index ab0ac44..59fdc76 100644
--- a/src/test/resources/constructor/carwheel-without-tags.yaml
+++ b/src/test/resources/constructor/carwheel-without-tags.yaml
@@ -1,6 +1,6 @@
-!!org.yaml.snakeyaml.constructor.ImplicitTagsTest$CarWithWheel
-map: {id: 3}
-part: !!org.yaml.snakeyaml.constructor.Wheel {id: 4}
-plate: 12-XP-F4
-wheel: {id: 2}
-year: '2008'
+!!org.yaml.snakeyaml.constructor.ImplicitTagsTest$CarWithWheel
+map: {id: 3}
+part: !!org.yaml.snakeyaml.constructor.Wheel {id: 4}
+plate: 12-XP-F4
+wheel: {id: 2}
+year: '2008'
diff --git a/src/test/resources/constructor/test-primitives1.yaml b/src/test/resources/constructor/test-primitives1.yaml
index 7403c37..5e2c948 100644
--- a/src/test/resources/constructor/test-primitives1.yaml
+++ b/src/test/resources/constructor/test-primitives1.yaml
@@ -1,23 +1,23 @@
-# TestBean1
-byteClass: 1
-bytePrimitive: -3
-shortClass: +0
-shortPrimitive: -015 # octal
-integer: 5
-intPrimitive: 17
-text: the text
-id: 13
-longClass: 11111111111
-longPrimitive: 9999999999
-booleanClass: True
-booleanPrimitive: on
-charClass: 2
-charPrimitive: '#'
-bigInteger: 1234567890123456789012345678901234567890
-floatClass: 2
-floatPrimitive: 3.1416
-doubleClass: 4.0
-doublePrimitive: +1.12e4
-date: 2008-01-09
-publicField: public
-
+# TestBean1
+byteClass: 1
+bytePrimitive: -3
+shortClass: +0
+shortPrimitive: -015 # octal
+integer: 5
+intPrimitive: 17
+text: the text
+id: 13
+longClass: 11111111111
+longPrimitive: 9999999999
+booleanClass: True
+booleanPrimitive: on
+charClass: 2
+charPrimitive: '#'
+bigInteger: 1234567890123456789012345678901234567890
+floatClass: 2
+floatPrimitive: 3.1416
+doubleClass: 4.0
+doublePrimitive: +1.12e4
+date: 2008-01-09
+publicField: public
+
diff --git a/src/test/resources/examples/any-object-example.yaml b/src/test/resources/examples/any-object-example.yaml
index 2ba2be5..b5092ee 100644
--- a/src/test/resources/examples/any-object-example.yaml
+++ b/src/test/resources/examples/any-object-example.yaml
@@ -1,6 +1,6 @@
-none: [~, null]
-bool: [true, false, on, off]
-int: 42
-float: 3.14159
-list: [LITE, RES_ACID, SUS_DEXT]
-dict: {hp: 13, sp: 5}
+none: [~, null]
+bool: [true, false, on, off]
+int: 42
+float: 3.14159
+list: [LITE, RES_ACID, SUS_DEXT]
+dict: {hp: 13, sp: 5}
diff --git a/src/test/resources/examples/list-bean-1.yaml b/src/test/resources/examples/list-bean-1.yaml
index b8efaaa..124a4af 100644
--- a/src/test/resources/examples/list-bean-1.yaml
+++ b/src/test/resources/examples/list-bean-1.yaml
@@ -1,9 +1,9 @@
-children:
-- aaa
-- bbb
-developers:
-- name: Fred
- role: creator
-- name: John
- role: committer
-name: Bean123
+children:
+- aaa
+- bbb
+developers:
+- name: Fred
+ role: creator
+- name: John
+ role: committer
+name: Bean123
diff --git a/src/test/resources/examples/list-bean-2.yaml b/src/test/resources/examples/list-bean-2.yaml
index 8124d51..82cd9f6 100644
--- a/src/test/resources/examples/list-bean-2.yaml
+++ b/src/test/resources/examples/list-bean-2.yaml
@@ -1,12 +1,12 @@
-children:
-- aaa
-- bbb
-developers:
-- !!examples.collections.TypeSafeListWithInterfaceTest$Developer
- name: Fred
- role: creator
-- !!examples.collections.TypeSafeListWithInterfaceTest$Committer
- key: 34
- name: John
- role: committer
+children:
+- aaa
+- bbb
+developers:
+- !!examples.collections.TypeSafeListWithInterfaceTest$Developer
+ name: Fred
+ role: creator
+- !!examples.collections.TypeSafeListWithInterfaceTest$Committer
+ key: 34
+ name: John
+ role: committer
name: Bean123
\ No newline at end of file
diff --git a/src/test/resources/examples/list-bean-3.yaml b/src/test/resources/examples/list-bean-3.yaml
index 2d9efbf..d2ffdac 100644
--- a/src/test/resources/examples/list-bean-3.yaml
+++ b/src/test/resources/examples/list-bean-3.yaml
@@ -1,6 +1,6 @@
-developers:
-- name: Fred
- role: creator
-- name: John
- role: committer
-name: Bean123
+developers:
+- name: Fred
+ role: creator
+- name: John
+ role: committer
+name: Bean123
diff --git a/src/test/resources/examples/list-bean-4.yaml b/src/test/resources/examples/list-bean-4.yaml
index 589682c..518e2d3 100644
--- a/src/test/resources/examples/list-bean-4.yaml
+++ b/src/test/resources/examples/list-bean-4.yaml
@@ -1,12 +1,12 @@
-children:
-- aaa
-- bbb
-developers:
-- !!examples.collections.TypeSafeListNoGerericsTest$Developer
- name: Fred
- role: creator
-- !!examples.collections.TypeSafeListNoGerericsTest$Developer
- name: John
- role: committer
-name: Bean123
-
+children:
+- aaa
+- bbb
+developers:
+- !!examples.collections.TypeSafeListNoGerericsTest$Developer
+ name: Fred
+ role: creator
+- !!examples.collections.TypeSafeListNoGerericsTest$Developer
+ name: John
+ role: committer
+name: Bean123
+
diff --git a/src/test/resources/examples/map-bean-1.yaml b/src/test/resources/examples/map-bean-1.yaml
index 9e8e357..a8e9eb1 100644
--- a/src/test/resources/examples/map-bean-1.yaml
+++ b/src/test/resources/examples/map-bean-1.yaml
@@ -1,7 +1,7 @@
-name: Bean123
-properties:
- key2: value2
- key1: value1
-sorted:
- '1': one
+name: Bean123
+properties:
+ key2: value2
+ key1: value1
+sorted:
+ '1': one
'2': two
\ No newline at end of file
diff --git a/src/test/resources/examples/map-bean-10.yaml b/src/test/resources/examples/map-bean-10.yaml
index 9b2138c..c26c79e 100644
--- a/src/test/resources/examples/map-bean-10.yaml
+++ b/src/test/resources/examples/map-bean-10.yaml
@@ -1,12 +1,12 @@
-data:
- aaa: 1
- bbb: 2
- zzz: 3
-developers:
- team1:
- name: Fred
- role: creator
- team2:
- name: John
- role: committer
-name: Bean123
+data:
+ aaa: 1
+ bbb: 2
+ zzz: 3
+developers:
+ team1:
+ name: Fred
+ role: creator
+ team2:
+ name: John
+ role: committer
+name: Bean123
diff --git a/src/test/resources/examples/map-bean-11.yaml b/src/test/resources/examples/map-bean-11.yaml
index 0cdfd16..24fe91d 100644
--- a/src/test/resources/examples/map-bean-11.yaml
+++ b/src/test/resources/examples/map-bean-11.yaml
@@ -1,15 +1,15 @@
-data:
- aaa: 1
- bbb: 2
-developers:
- team1:
- name: Fred
- role: creator
- team2:
- name: John
- role: committer
- team3: !!examples.collections.TypeSafeMapTest$Developer222
- name: Bill
- role: head
-name: Bean123
-
+data:
+ aaa: 1
+ bbb: 2
+developers:
+ team1:
+ name: Fred
+ role: creator
+ team2:
+ name: John
+ role: committer
+ team3: !!examples.collections.TypeSafeMapTest$Developer222
+ name: Bill
+ role: head
+name: Bean123
+
diff --git a/src/test/resources/examples/map-bean-12.yaml b/src/test/resources/examples/map-bean-12.yaml
index 600e751..feb5a85 100644
--- a/src/test/resources/examples/map-bean-12.yaml
+++ b/src/test/resources/examples/map-bean-12.yaml
@@ -1,16 +1,16 @@
-data:
- ? name: Andy
- role: tester
- : BLACK
- ? name: Lisa
- role: owner
- : RED
-developers:
- WHITE:
- name: Fred
- role: creator
- BLACK:
- name: John
- role: committer
-name: Bean123
-
+data:
+ ? name: Andy
+ role: tester
+ : BLACK
+ ? name: Lisa
+ role: owner
+ : RED
+developers:
+ WHITE:
+ name: Fred
+ role: creator
+ BLACK:
+ name: John
+ role: committer
+name: Bean123
+
diff --git a/src/test/resources/examples/map-bean-13.yaml b/src/test/resources/examples/map-bean-13.yaml
index 0c2e3ea..17974ce 100644
--- a/src/test/resources/examples/map-bean-13.yaml
+++ b/src/test/resources/examples/map-bean-13.yaml
@@ -1,25 +1,25 @@
-data:
- ? name: Andy
- role: tester
- : BLACK
- ? !!examples.collections.TypeSafeMap2Test$SuperMan
- name: Bill
- role: cleaner
- smart: false
- : BLACK
- ? name: Lisa
- role: owner
- : RED
-developers:
- WHITE:
- name: Fred
- role: creator
- RED: !!examples.collections.TypeSafeMap2Test$SuperMan
- name: Jason
- role: contributor
- smart: true
- BLACK:
- name: John
- role: committer
-name: Bean123
-
+data:
+ ? name: Andy
+ role: tester
+ : BLACK
+ ? !!examples.collections.TypeSafeMap2Test$SuperMan
+ name: Bill
+ role: cleaner
+ smart: false
+ : BLACK
+ ? name: Lisa
+ role: owner
+ : RED
+developers:
+ WHITE:
+ name: Fred
+ role: creator
+ RED: !!examples.collections.TypeSafeMap2Test$SuperMan
+ name: Jason
+ role: contributor
+ smart: true
+ BLACK:
+ name: John
+ role: committer
+name: Bean123
+
diff --git a/src/test/resources/examples/map-bean-2.yaml b/src/test/resources/examples/map-bean-2.yaml
index 22d6669..742792d 100644
--- a/src/test/resources/examples/map-bean-2.yaml
+++ b/src/test/resources/examples/map-bean-2.yaml
@@ -1,3 +1,3 @@
-- {'1': one, '2': two}
-- {key2: value2, key1: value1}
-- aaa
+- {'1': one, '2': two}
+- {key2: value2, key1: value1}
+- aaa
diff --git a/src/test/resources/examples/map-recursive-1.yaml b/src/test/resources/examples/map-recursive-1.yaml
index 9ab9c07..6352266 100644
--- a/src/test/resources/examples/map-recursive-1.yaml
+++ b/src/test/resources/examples/map-recursive-1.yaml
@@ -1,4 +1,4 @@
-&id001
-'1': one
-'2': two
-'3': *id001
+&id001
+'1': one
+'2': two
+'3': *id001
diff --git a/src/test/resources/examples/map-recursive-1_1.yaml b/src/test/resources/examples/map-recursive-1_1.yaml
index e54daa9..8830184 100644
--- a/src/test/resources/examples/map-recursive-1_1.yaml
+++ b/src/test/resources/examples/map-recursive-1_1.yaml
@@ -1,4 +1,4 @@
-&id001
-'2': two
-'1': one
-'3': *id001
+&id001
+'2': two
+'1': one
+'3': *id001
diff --git a/src/test/resources/examples/map-recursive-2.yaml b/src/test/resources/examples/map-recursive-2.yaml
index 01b4a94..3b582d4 100644
--- a/src/test/resources/examples/map-recursive-2.yaml
+++ b/src/test/resources/examples/map-recursive-2.yaml
@@ -1,4 +1,4 @@
-&id001
-key3: *id001
-key2: value2
-key1: value1
+&id001
+key3: *id001
+key2: value2
+key1: value1
diff --git a/src/test/resources/examples/map-recursive-3.yaml b/src/test/resources/examples/map-recursive-3.yaml
index 7dca8c0..0d58727 100644
--- a/src/test/resources/examples/map-recursive-3.yaml
+++ b/src/test/resources/examples/map-recursive-3.yaml
@@ -1,4 +1,4 @@
-&id001 !!java.util.SortedMap
-'2': two
-'1': one
-'3': *id001
+&id001 !!java.util.SortedMap
+'2': two
+'1': one
+'3': *id001
diff --git a/src/test/resources/examples/map-recursive-4.yaml b/src/test/resources/examples/map-recursive-4.yaml
index 0f68f30..217ab88 100644
--- a/src/test/resources/examples/map-recursive-4.yaml
+++ b/src/test/resources/examples/map-recursive-4.yaml
@@ -1,4 +1,4 @@
-&id001 !!java.util.Properties
-key3: *id001
-key2: value2
-key1: value1
+&id001 !!java.util.Properties
+key3: *id001
+key2: value2
+key1: value1
diff --git a/src/test/resources/examples/set-bean-1.yaml b/src/test/resources/examples/set-bean-1.yaml
index b3ae3ae..82c174e 100644
--- a/src/test/resources/examples/set-bean-1.yaml
+++ b/src/test/resources/examples/set-bean-1.yaml
@@ -1,12 +1,12 @@
-developers: !!set
- ? name: John
- role: founder
- : null
- ? name: Karl
- role: user
- : null
-name: Bean123
-sorted: !!set
- one: null
- three: null
+developers: !!set
+ ? name: John
+ role: founder
+ : null
+ ? name: Karl
+ role: user
+ : null
+name: Bean123
+sorted: !!set
+ one: null
+ three: null
two: null
\ No newline at end of file
diff --git a/src/test/resources/examples/set-bean-2.yaml b/src/test/resources/examples/set-bean-2.yaml
index 219d081..3d219e2 100644
--- a/src/test/resources/examples/set-bean-2.yaml
+++ b/src/test/resources/examples/set-bean-2.yaml
@@ -1,14 +1,14 @@
-developers: !!set
- ? name: Karl
- role: user
- : null
- ? name: John
- role: founder
- : null
-
-name: Bean123
-
-sorted: !!set
- two: null
- one: null
+developers: !!set
+ ? name: Karl
+ role: user
+ : null
+ ? name: John
+ role: founder
+ : null
+
+name: Bean123
+
+sorted: !!set
+ two: null
+ one: null
three: null
\ No newline at end of file
diff --git a/src/test/resources/examples/set-bean-3.yaml b/src/test/resources/examples/set-bean-3.yaml
index 1ab2534..9d27d23 100644
--- a/src/test/resources/examples/set-bean-3.yaml
+++ b/src/test/resources/examples/set-bean-3.yaml
@@ -1,7 +1,7 @@
-&id001 !!set
-? !!examples.collections.TypeSafeSetImplementationsTest$Box
- id: id123
- set: *id001
-: null
-111: null
-aaa: null
+&id001 !!set
+? !!examples.collections.TypeSafeSetImplementationsTest$Box
+ id: id123
+ set: *id001
+: null
+111: null
+aaa: null
diff --git a/src/test/resources/examples/set-bean-6.yaml b/src/test/resources/examples/set-bean-6.yaml
index c416520..2a5243c 100644
--- a/src/test/resources/examples/set-bean-6.yaml
+++ b/src/test/resources/examples/set-bean-6.yaml
@@ -1,16 +1,16 @@
-developers: !!set
- ? !!examples.collections.TypeSafeSetImplementationsTest$SuperDeveloper
- name: Bill
- role: super
- : null
- ? name: John
- role: founder
- : null
- ? name: Karl
- role: user
- : null
-name: Bean123
-sorted: !!set
- one: null
- three: null
+developers: !!set
+ ? !!examples.collections.TypeSafeSetImplementationsTest$SuperDeveloper
+ name: Bill
+ role: super
+ : null
+ ? name: John
+ role: founder
+ : null
+ ? name: Karl
+ role: user
+ : null
+name: Bean123
+sorted: !!set
+ one: null
+ three: null
two: null
\ No newline at end of file
diff --git a/src/test/resources/examples/spring.xml b/src/test/resources/examples/spring.xml
index 41d817e..66a3ad6 100644
--- a/src/test/resources/examples/spring.xml
+++ b/src/test/resources/examples/spring.xml
@@ -1,30 +1,30 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p"
- xsi:schemaLocation="
-http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
-http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
-
- <!-- the most powerful way -->
- <bean id="yamlConstructor" class="examples.CustomConstructor" scope="prototype" />
- <bean id="yamlRepresenter" class="org.yaml.snakeyaml.representer.Representer" scope="prototype" />
- <bean id="yamlOptions" class="org.yaml.snakeyaml.DumperOptions" scope="prototype">
- <property name="indent" value="2" />
- </bean>
- <bean id="snakeYaml" class="org.yaml.snakeyaml.Yaml" scope="prototype">
- <constructor-arg ref="yamlConstructor" />
- <constructor-arg ref="yamlRepresenter" />
- <constructor-arg ref="yamlOptions" />
- </bean>
-
- <!-- for a single JavaBean -->
- <bean id="beanConstructor" class="org.yaml.snakeyaml.constructor.Constructor" scope="prototype">
- <constructor-arg value="org.yaml.snakeyaml.Invoice" />
- </bean>
- <bean id="javabeanYaml" class="org.yaml.snakeyaml.Yaml" scope="prototype">
- <constructor-arg ref="beanConstructor" />
- </bean>
-
- <!-- the simplest way -->
- <bean id="standardYaml" class="org.yaml.snakeyaml.Yaml" scope="prototype" />
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
+
+ <!-- the most powerful way -->
+ <bean id="yamlConstructor" class="examples.CustomConstructor" scope="prototype" />
+ <bean id="yamlRepresenter" class="org.yaml.snakeyaml.representer.Representer" scope="prototype" />
+ <bean id="yamlOptions" class="org.yaml.snakeyaml.DumperOptions" scope="prototype">
+ <property name="indent" value="2" />
+ </bean>
+ <bean id="snakeYaml" class="org.yaml.snakeyaml.Yaml" scope="prototype">
+ <constructor-arg ref="yamlConstructor" />
+ <constructor-arg ref="yamlRepresenter" />
+ <constructor-arg ref="yamlOptions" />
+ </bean>
+
+ <!-- for a single JavaBean -->
+ <bean id="beanConstructor" class="org.yaml.snakeyaml.constructor.Constructor" scope="prototype">
+ <constructor-arg value="org.yaml.snakeyaml.Invoice" />
+ </bean>
+ <bean id="javabeanYaml" class="org.yaml.snakeyaml.Yaml" scope="prototype">
+ <constructor-arg ref="beanConstructor" />
+ </bean>
+
+ <!-- the simplest way -->
+ <bean id="standardYaml" class="org.yaml.snakeyaml.Yaml" scope="prototype" />
</beans>
\ No newline at end of file
diff --git a/src/test/resources/examples/unknown-tags-example.yaml b/src/test/resources/examples/unknown-tags-example.yaml
index c8ecf23..7177a58 100644
--- a/src/test/resources/examples/unknown-tags-example.yaml
+++ b/src/test/resources/examples/unknown-tags-example.yaml
@@ -1,8 +1,8 @@
---- !Foo
-aaa: !Bar1 123
-bbb: !Bar2
-- 111
-- ddd
-ccc: !Bar3
- x: !!float 1
- y: 3.1416
+--- !Foo
+aaa: !Bar1 123
+bbb: !Bar2
+- 111
+- ddd
+ccc: !Bar3
+ x: !!float 1
+ y: 3.1416
diff --git a/src/test/resources/immutable/shape1.yaml b/src/test/resources/immutable/shape1.yaml
index 48fd0d4..1ab581f 100644
--- a/src/test/resources/immutable/shape1.yaml
+++ b/src/test/resources/immutable/shape1.yaml
@@ -1,9 +1,9 @@
-!!org.yaml.snakeyaml.immutable.Shape
-color: BLACK
-point:
-- 1.17
-- 3.14
-point3d: !!org.yaml.snakeyaml.immutable.Point3d
- - !!org.yaml.snakeyaml.immutable.Point [1.17, 3.14]
- - 345.1
+!!org.yaml.snakeyaml.immutable.Shape
+color: BLACK
+point:
+- 1.17
+- 3.14
+point3d: !!org.yaml.snakeyaml.immutable.Point3d
+ - !!org.yaml.snakeyaml.immutable.Point [1.17, 3.14]
+ - 345.1
id: 123
\ No newline at end of file
diff --git a/src/test/resources/immutable/shapeNoTags.yaml b/src/test/resources/immutable/shapeNoTags.yaml
index 3ae087a..1917739 100644
--- a/src/test/resources/immutable/shapeNoTags.yaml
+++ b/src/test/resources/immutable/shapeNoTags.yaml
@@ -1,8 +1,8 @@
-color: BLACK
-point:
-- 1.17
-- 3.14
-point3d:
- - [1.96, 1.78]
- - 345.1
+color: BLACK
+point:
+- 1.17
+- 3.14
+point3d:
+ - [1.96, 1.78]
+ - 345.1
id: 123
\ No newline at end of file
diff --git a/src/test/resources/issues/issue56-1.yaml b/src/test/resources/issues/issue56-1.yaml
index bba0884..e23c153 100644
--- a/src/test/resources/issues/issue56-1.yaml
+++ b/src/test/resources/issues/issue56-1.yaml
@@ -1,830 +1,830 @@
---- !de.oddb.org,2007/ODDB::Drugs::Product
-oid: 1724265
-name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: ARGATRA MITSUBISHI
- synonyms: []
-
-company: !de.oddb.org,2007/ODDB::Business::Company
- oid: 1724276
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Mitsubishi Ph Dt. GmbH
- synonyms: []
-
-sequences:
-- !de.oddb.org,2007/ODDB::Drugs::Sequence
- oid: 1724267
- codes: []
-
- data_origins:
- :substance: zdavatz@ywesee.com
- :atc: zdavatz@ywesee.com
- :registration: zdavatz@ywesee.com
- fachinfo_url: http://gripsdb.dimdi.de/amispb/doc/2162085-20050615/OBFM086D979C01C570B0.rtf
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical: {}
-
- synonyms: []
-
- patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2162085-20050615/OBFM6D3DDEAF01C570D8.rtf
- atc: !de.oddb.org,2007/ODDB::Drugs::Atc
- oid: 2250
- code: B01AE03
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :en: Argatroban
- :de: Argatroban
- synonyms: []
-
- compositions:
- - !de.oddb.org,2007/ODDB::Drugs::Composition
- oid: 1724261
- active_agents:
- - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
- oid: 1724263
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 250
- unit: mg
- substance: !de.oddb.org,2007/ODDB::Drugs::Substance
- oid: 1724260
- codes: []
-
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Argatroban
- synonyms: []
-
- parts:
- - &id002 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 1724270
- multi:
- quantity:
- size: 1
- unit: &id001 !de.oddb.org,2007/ODDB::Drugs::Unit
- oid: 19094
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Durchstechflasche
- synonyms: []
-
- - &id003 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 1727992
- multi:
- quantity:
- size: 1
- unit: *id001
- packages:
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 1724271
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "3081565"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: true
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: zuzahlungsbefreit
- value: false
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value:
- data_origins:
- :price_exfactory: hwyss@ywesee.com
- :code_festbetragsgruppe: zdavatz@ywesee.com
- :code_zuzahlungsbefreit: zdavatz@ywesee.com
- :code_festbetragsstufe: zdavatz@ywesee.com
- :size: hwyss@ywesee.com
- :name: zdavatz@ywesee.com
- :price_public: zdavatz@ywesee.com
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Argatra(R) 100 mg/ml Argatroban (N1)
- synonyms: []
-
- parts:
- - *id002
- prices:
- public: 238.11
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 1727993
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: true
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: zuzahlungsbefreit
- value: false
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "1022245"
- data_origins:
- :price_exfactory: hwyss@ywesee.com
- :code_festbetragsgruppe: zdavatz@ywesee.com
- :code_zuzahlungsbefreit: zdavatz@ywesee.com
- :code_festbetragsstufe: zdavatz@ywesee.com
- :size: hwyss@ywesee.com
- :code_cid: zdavatz@ywesee.com
- :name: zdavatz@ywesee.com
- :price_public: hwyss@ywesee.com
- :code_prescription: zdavatz@ywesee.com
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Argatra(R) 100 mg/ml Argatroban (Klinikpackung)
- synonyms: []
-
- parts:
- - *id003
- prices:
- exfactory: 158.0
---- !de.oddb.org,2007/ODDB::Drugs::Product
-oid: 1841680
-name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: ASTHMA BRONCHIALE STAUFEN
- synonyms: []
-
-company: !de.oddb.org,2007/ODDB::Business::Company
- oid: 1841686
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Staufen Pharma
- synonyms: []
-
-sequences:
-- !de.oddb.org,2007/ODDB::Drugs::Sequence
- oid: 1841675
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: EU
- type: registration
- value: 2510055.00.00
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical: {}
-
- synonyms: []
-
- patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2009/03/07/2510055/OBFME745B5B701C954E7.rtf
- compositions:
- - !de.oddb.org,2007/ODDB::Drugs::Composition
- oid: 1841672
- galenic_form: !de.oddb.org,2007/ODDB::Drugs::GalenicForm
- oid: 18210
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: AMP
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: AMP1
- description: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ampullen
- synonyms: []
-
- active_agents:
- - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
- oid: 1841674
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 1
- unit: ml
- substance: !de.oddb.org,2007/ODDB::Drugs::Substance
- oid: 1841670
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Asthma-bronchiale-Nosode (Pot.-Angaben)
- synonyms: []
-
- parts:
- - &id001 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 1841683
- multi:
- size: 10
- unit: !de.oddb.org,2007/ODDB::Drugs::Unit
- oid: 19684
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ampullen
- synonyms: []
-
- packages:
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 1841684
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "4661796"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: false
- data_origins:
- :price_public: :csv_product_infos
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Asthma Bronchiale Nosoden Ser. Ampullen
- synonyms: []
-
- parts:
- - *id001
- prices:
- public: 15.3866
---- !de.oddb.org,2007/ODDB::Drugs::Product
-oid: 27823
-name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Aarane
- synonyms: []
-
-company: !de.oddb.org,2007/ODDB::Business::Company
- oid: 213595
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Sanofi-Aventis Dt. GmbH
- synonyms: []
-
-sequences:
-- !de.oddb.org,2007/ODDB::Drugs::Sequence
- oid: 27830
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: EU
- type: registration
- value: 3159.00.00
- fachinfo_url: http://gripsdb.dimdi.de/amispb/doc/2009/02/27/2103159/OBFMDE81481A01C93A3F.rtf
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical: {}
-
- synonyms: []
-
- patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2009/02/27/2103159/OBFMDEDBE17601C93A3F.rtf
- atc: !de.oddb.org,2007/ODDB::Drugs::Atc
- oid: 13239
- code: R03AK05
- ddd_guidelines: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical: {}
-
- synonyms: []
-
- guidelines: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical: {}
-
- synonyms: []
-
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :en: Reproterol and Other Drugs for Obstructive Airway Diseases
- :de: "Reproterol und andere Mittel bei obstruktiven Atemwegserkrankungen "
- synonyms: []
-
- ddds: []
-
- compositions:
- - !de.oddb.org,2007/ODDB::Drugs::Composition
- oid: 27825
- equivalence_factor: 0.25
- galenic_form: !de.oddb.org,2007/ODDB::Drugs::GalenicForm
- oid: 18225
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: DA
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: DA1
- description: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Dosieraerosol
- synonyms: []
-
- active_agents:
- - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
- oid: 27827
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 0.5
- unit: mg
- substance: !de.oddb.org,2007/ODDB::Drugs::Substance
- oid: 258913
- codes: []
-
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Reproterolhydrochlorid
- synonyms: []
-
- - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
- oid: 27828
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 1
- unit: mg
- substance: !de.oddb.org,2007/ODDB::Drugs::Substance
- oid: 258916
- codes: []
-
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Natriumcromoglicat (Ph.Eur.)
- synonyms: []
-
- parts:
- - &id001 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 27834
- multi:
- quantity: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 10
- unit: ml
- size: 1
- unit: &id002 !de.oddb.org,2007/ODDB::Drugs::Unit
- oid: 27833
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Dosieraerosol
- synonyms: []
-
- packages:
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 27835
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "225437"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: true
- data_origins:
- :price_exfactory: :dimdi
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Aarane N Dos.-Aerosol
- synonyms: []
-
- parts:
- - *id001
- prices:
- festbetrag: 41.63
- exfactory: 27.483606557377
- public: 41.63
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 27846
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "225443"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: true
- data_origins:
- :price_exfactory: :dimdi
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Aarane N Dos.-Aerosol
- synonyms: []
-
- parts:
- - !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 27845
- multi:
- quantity: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 10
- unit: ml
- size: 2
- unit: *id002
- prices:
- festbetrag: 70.44
- exfactory: 51.0983606557377
- public: 70.44
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 27857
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "225466"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: true
- data_origins:
- :price_exfactory: :dimdi
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Aarane N Dos.-Aerosol
- synonyms: []
-
- parts:
- - !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 27856
- multi:
- quantity: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 10
- unit: ml
- size: 3
- unit: *id002
- prices:
- festbetrag: 98.14
- exfactory: 73.8032786885246
- public: 98.14
---- !de.oddb.org,2007/ODDB::Drugs::Product
-oid: 123058
-name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ass Stada
- synonyms: []
-
-company: !de.oddb.org,2007/ODDB::Business::Company
- oid: 213544
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Stadapharm GmbH
- synonyms: []
-
-sequences:
-- !de.oddb.org,2007/ODDB::Drugs::Sequence
- oid: 123064
- atc: !de.oddb.org,2007/ODDB::Drugs::Atc
- oid: 10794
- code: N02BA01
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :en: Acetylsalicylic Acid
- :de: "Acetylsalicyls\xC3\xA4ure"
- synonyms: []
-
- ddds:
- - !de.oddb.org,2007/ODDB::Drugs::Ddd
- oid: 17503
- administration: O
- comment:
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 3
- unit: g
- - !de.oddb.org,2007/ODDB::Drugs::Ddd
- oid: 17504
- administration: P
- comment: bezogen auf Lysinacetylsalicylat
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 1
- unit: g
- - !de.oddb.org,2007/ODDB::Drugs::Ddd
- oid: 17505
- administration: R
- comment:
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 3
- unit: g
- compositions:
- - !de.oddb.org,2007/ODDB::Drugs::Composition
- oid: 123060
- equivalence_factor: 500.0
- galenic_form: &id004 !de.oddb.org,2007/ODDB::Drugs::GalenicForm
- oid: 18322
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: TAB1
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: TABL
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: TABL1
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: TABL2
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: galenic_form
- value: TABL3
- description: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Tabletten
- synonyms:
- - Tablette
- group: !de.oddb.org,2007/ODDB::Drugs::GalenicGroup
- oid: 18348
- administration: O
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Tabletten
- synonyms: []
-
- active_agents:
- - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
- oid: 123062
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 500
- unit: mg
- substance: &id005 !de.oddb.org,2007/ODDB::Drugs::Substance
- oid: 18991
- codes: []
-
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: "Acetylsalicyls\xC3\xA4ure"
- synonyms:
- - ASS
- group: !de.oddb.org,2007/ODDB::Drugs::SubstanceGroup
- oid: 18993
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: ASS / ASS-Puffer
- synonyms: []
-
- parts:
- - &id002 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 123067
- multi:
- size: 10
- unit: &id001 !de.oddb.org,2007/ODDB::Drugs::Unit
- oid: 18979
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Tabletten
- synonyms: []
-
- - &id003 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 166317
- multi:
- size: 30
- unit: *id001
- packages:
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 123068
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "3366167"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: false
- data_origins:
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ass Stada 500 Tabletten
- synonyms: []
-
- parts:
- - *id002
- prices:
- festbetrag: 1.62
- public: 1.34
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 166318
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "4860432"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: false
- data_origins:
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ass Stada 500 Tabletten
- synonyms: []
-
- parts:
- - *id003
- prices:
- festbetrag: 3.45
- public: 1.59
-- !de.oddb.org,2007/ODDB::Drugs::Sequence
- oid: 187618
- codes: []
-
- fachinfo_url: http://gripsdb.dimdi.de/amispb/doc/2007/10/20/2149897/OBFME354082201C79E74.rtf
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical: {}
-
- synonyms: []
-
- patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2007/10/20/2149897/OBFME3351D5E01C79E74.rtf
- atc: !de.oddb.org,2007/ODDB::Drugs::Atc
- oid: 2160
- code: B01AC06
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :en: Acetylsalicylic Acid
- :de: "Acetylsalicyls\xC3\xA4ure"
- synonyms: []
-
- ddds:
- - !de.oddb.org,2007/ODDB::Drugs::Ddd
- oid: 16383
- administration: O
- comment: "unabh\xC3\xA4ngig von der Wirkst\xC3\xA4rke"
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 1
- unit: ""
- compositions:
- - !de.oddb.org,2007/ODDB::Drugs::Composition
- oid: 187614
- equivalence_factor: 100.0
- galenic_form: *id004
- active_agents:
- - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
- oid: 187616
- dose: !de.oddb.org,2007/ODDB::Drugs::Dose
- val: 100
- unit: mg
- substance: *id005
- parts:
- - &id006 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 187621
- multi:
- size: 50
- unit: *id001
- - &id007 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 187624
- multi:
- size: 100
- unit: *id001
- - &id008 !de.oddb.org,2007/ODDB::Drugs::Part
- oid: 188222
- multi:
- size: 20
- unit: *id001
- packages:
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 187622
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "7382275"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: false
- data_origins:
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ass Stada 100 Tabletten
- synonyms: []
-
- parts:
- - *id006
- prices:
- festbetrag: 2.64
- public: 1.64
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 187625
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "7382281"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: false
- data_origins:
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ass Stada 100 Tabletten
- synonyms: []
-
- parts:
- - *id007
- prices:
- festbetrag: 4.26
- public: 2.87
- - !de.oddb.org,2007/ODDB::Drugs::Package
- oid: 188223
- codes:
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: cid
- value: "7394433"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsgruppe
- value: "1"
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: festbetragsstufe
- value: 3
- - !de.oddb.org,2007/ODDB::Util::Code
- country: DE
- type: prescription
- value: false
- data_origins:
- :price_public: :dimdi
- :price_festbetrag: :dimdi
- name: !de.oddb.org,2007/ODDB::Util::Multilingual
- canonical:
- :de: Ass Stada 100 Tabletten
- synonyms: []
-
- parts:
- - *id008
- prices:
- festbetrag: 1.42
- public: 1.14
+--- !de.oddb.org,2007/ODDB::Drugs::Product
+oid: 1724265
+name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: ARGATRA MITSUBISHI
+ synonyms: []
+
+company: !de.oddb.org,2007/ODDB::Business::Company
+ oid: 1724276
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Mitsubishi Ph Dt. GmbH
+ synonyms: []
+
+sequences:
+- !de.oddb.org,2007/ODDB::Drugs::Sequence
+ oid: 1724267
+ codes: []
+
+ data_origins:
+ :substance: zdavatz@ywesee.com
+ :atc: zdavatz@ywesee.com
+ :registration: zdavatz@ywesee.com
+ fachinfo_url: http://gripsdb.dimdi.de/amispb/doc/2162085-20050615/OBFM086D979C01C570B0.rtf
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical: {}
+
+ synonyms: []
+
+ patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2162085-20050615/OBFM6D3DDEAF01C570D8.rtf
+ atc: !de.oddb.org,2007/ODDB::Drugs::Atc
+ oid: 2250
+ code: B01AE03
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :en: Argatroban
+ :de: Argatroban
+ synonyms: []
+
+ compositions:
+ - !de.oddb.org,2007/ODDB::Drugs::Composition
+ oid: 1724261
+ active_agents:
+ - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
+ oid: 1724263
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 250
+ unit: mg
+ substance: !de.oddb.org,2007/ODDB::Drugs::Substance
+ oid: 1724260
+ codes: []
+
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Argatroban
+ synonyms: []
+
+ parts:
+ - &id002 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 1724270
+ multi:
+ quantity:
+ size: 1
+ unit: &id001 !de.oddb.org,2007/ODDB::Drugs::Unit
+ oid: 19094
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Durchstechflasche
+ synonyms: []
+
+ - &id003 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 1727992
+ multi:
+ quantity:
+ size: 1
+ unit: *id001
+ packages:
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 1724271
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "3081565"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: true
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: zuzahlungsbefreit
+ value: false
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value:
+ data_origins:
+ :price_exfactory: hwyss@ywesee.com
+ :code_festbetragsgruppe: zdavatz@ywesee.com
+ :code_zuzahlungsbefreit: zdavatz@ywesee.com
+ :code_festbetragsstufe: zdavatz@ywesee.com
+ :size: hwyss@ywesee.com
+ :name: zdavatz@ywesee.com
+ :price_public: zdavatz@ywesee.com
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Argatra(R) 100 mg/ml Argatroban (N1)
+ synonyms: []
+
+ parts:
+ - *id002
+ prices:
+ public: 238.11
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 1727993
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: true
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: zuzahlungsbefreit
+ value: false
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "1022245"
+ data_origins:
+ :price_exfactory: hwyss@ywesee.com
+ :code_festbetragsgruppe: zdavatz@ywesee.com
+ :code_zuzahlungsbefreit: zdavatz@ywesee.com
+ :code_festbetragsstufe: zdavatz@ywesee.com
+ :size: hwyss@ywesee.com
+ :code_cid: zdavatz@ywesee.com
+ :name: zdavatz@ywesee.com
+ :price_public: hwyss@ywesee.com
+ :code_prescription: zdavatz@ywesee.com
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Argatra(R) 100 mg/ml Argatroban (Klinikpackung)
+ synonyms: []
+
+ parts:
+ - *id003
+ prices:
+ exfactory: 158.0
+--- !de.oddb.org,2007/ODDB::Drugs::Product
+oid: 1841680
+name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: ASTHMA BRONCHIALE STAUFEN
+ synonyms: []
+
+company: !de.oddb.org,2007/ODDB::Business::Company
+ oid: 1841686
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Staufen Pharma
+ synonyms: []
+
+sequences:
+- !de.oddb.org,2007/ODDB::Drugs::Sequence
+ oid: 1841675
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: EU
+ type: registration
+ value: 2510055.00.00
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical: {}
+
+ synonyms: []
+
+ patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2009/03/07/2510055/OBFME745B5B701C954E7.rtf
+ compositions:
+ - !de.oddb.org,2007/ODDB::Drugs::Composition
+ oid: 1841672
+ galenic_form: !de.oddb.org,2007/ODDB::Drugs::GalenicForm
+ oid: 18210
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: AMP
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: AMP1
+ description: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ampullen
+ synonyms: []
+
+ active_agents:
+ - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
+ oid: 1841674
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 1
+ unit: ml
+ substance: !de.oddb.org,2007/ODDB::Drugs::Substance
+ oid: 1841670
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Asthma-bronchiale-Nosode (Pot.-Angaben)
+ synonyms: []
+
+ parts:
+ - &id001 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 1841683
+ multi:
+ size: 10
+ unit: !de.oddb.org,2007/ODDB::Drugs::Unit
+ oid: 19684
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ampullen
+ synonyms: []
+
+ packages:
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 1841684
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "4661796"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: false
+ data_origins:
+ :price_public: :csv_product_infos
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Asthma Bronchiale Nosoden Ser. Ampullen
+ synonyms: []
+
+ parts:
+ - *id001
+ prices:
+ public: 15.3866
+--- !de.oddb.org,2007/ODDB::Drugs::Product
+oid: 27823
+name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Aarane
+ synonyms: []
+
+company: !de.oddb.org,2007/ODDB::Business::Company
+ oid: 213595
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Sanofi-Aventis Dt. GmbH
+ synonyms: []
+
+sequences:
+- !de.oddb.org,2007/ODDB::Drugs::Sequence
+ oid: 27830
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: EU
+ type: registration
+ value: 3159.00.00
+ fachinfo_url: http://gripsdb.dimdi.de/amispb/doc/2009/02/27/2103159/OBFMDE81481A01C93A3F.rtf
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical: {}
+
+ synonyms: []
+
+ patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2009/02/27/2103159/OBFMDEDBE17601C93A3F.rtf
+ atc: !de.oddb.org,2007/ODDB::Drugs::Atc
+ oid: 13239
+ code: R03AK05
+ ddd_guidelines: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical: {}
+
+ synonyms: []
+
+ guidelines: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical: {}
+
+ synonyms: []
+
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :en: Reproterol and Other Drugs for Obstructive Airway Diseases
+ :de: "Reproterol und andere Mittel bei obstruktiven Atemwegserkrankungen "
+ synonyms: []
+
+ ddds: []
+
+ compositions:
+ - !de.oddb.org,2007/ODDB::Drugs::Composition
+ oid: 27825
+ equivalence_factor: 0.25
+ galenic_form: !de.oddb.org,2007/ODDB::Drugs::GalenicForm
+ oid: 18225
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: DA
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: DA1
+ description: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Dosieraerosol
+ synonyms: []
+
+ active_agents:
+ - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
+ oid: 27827
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 0.5
+ unit: mg
+ substance: !de.oddb.org,2007/ODDB::Drugs::Substance
+ oid: 258913
+ codes: []
+
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Reproterolhydrochlorid
+ synonyms: []
+
+ - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
+ oid: 27828
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 1
+ unit: mg
+ substance: !de.oddb.org,2007/ODDB::Drugs::Substance
+ oid: 258916
+ codes: []
+
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Natriumcromoglicat (Ph.Eur.)
+ synonyms: []
+
+ parts:
+ - &id001 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 27834
+ multi:
+ quantity: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 10
+ unit: ml
+ size: 1
+ unit: &id002 !de.oddb.org,2007/ODDB::Drugs::Unit
+ oid: 27833
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Dosieraerosol
+ synonyms: []
+
+ packages:
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 27835
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "225437"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: true
+ data_origins:
+ :price_exfactory: :dimdi
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Aarane N Dos.-Aerosol
+ synonyms: []
+
+ parts:
+ - *id001
+ prices:
+ festbetrag: 41.63
+ exfactory: 27.483606557377
+ public: 41.63
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 27846
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "225443"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: true
+ data_origins:
+ :price_exfactory: :dimdi
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Aarane N Dos.-Aerosol
+ synonyms: []
+
+ parts:
+ - !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 27845
+ multi:
+ quantity: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 10
+ unit: ml
+ size: 2
+ unit: *id002
+ prices:
+ festbetrag: 70.44
+ exfactory: 51.0983606557377
+ public: 70.44
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 27857
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "225466"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: true
+ data_origins:
+ :price_exfactory: :dimdi
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Aarane N Dos.-Aerosol
+ synonyms: []
+
+ parts:
+ - !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 27856
+ multi:
+ quantity: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 10
+ unit: ml
+ size: 3
+ unit: *id002
+ prices:
+ festbetrag: 98.14
+ exfactory: 73.8032786885246
+ public: 98.14
+--- !de.oddb.org,2007/ODDB::Drugs::Product
+oid: 123058
+name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ass Stada
+ synonyms: []
+
+company: !de.oddb.org,2007/ODDB::Business::Company
+ oid: 213544
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Stadapharm GmbH
+ synonyms: []
+
+sequences:
+- !de.oddb.org,2007/ODDB::Drugs::Sequence
+ oid: 123064
+ atc: !de.oddb.org,2007/ODDB::Drugs::Atc
+ oid: 10794
+ code: N02BA01
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :en: Acetylsalicylic Acid
+ :de: "Acetylsalicyls\xC3\xA4ure"
+ synonyms: []
+
+ ddds:
+ - !de.oddb.org,2007/ODDB::Drugs::Ddd
+ oid: 17503
+ administration: O
+ comment:
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 3
+ unit: g
+ - !de.oddb.org,2007/ODDB::Drugs::Ddd
+ oid: 17504
+ administration: P
+ comment: bezogen auf Lysinacetylsalicylat
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 1
+ unit: g
+ - !de.oddb.org,2007/ODDB::Drugs::Ddd
+ oid: 17505
+ administration: R
+ comment:
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 3
+ unit: g
+ compositions:
+ - !de.oddb.org,2007/ODDB::Drugs::Composition
+ oid: 123060
+ equivalence_factor: 500.0
+ galenic_form: &id004 !de.oddb.org,2007/ODDB::Drugs::GalenicForm
+ oid: 18322
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: TAB1
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: TABL
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: TABL1
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: TABL2
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: galenic_form
+ value: TABL3
+ description: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Tabletten
+ synonyms:
+ - Tablette
+ group: !de.oddb.org,2007/ODDB::Drugs::GalenicGroup
+ oid: 18348
+ administration: O
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Tabletten
+ synonyms: []
+
+ active_agents:
+ - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
+ oid: 123062
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 500
+ unit: mg
+ substance: &id005 !de.oddb.org,2007/ODDB::Drugs::Substance
+ oid: 18991
+ codes: []
+
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: "Acetylsalicyls\xC3\xA4ure"
+ synonyms:
+ - ASS
+ group: !de.oddb.org,2007/ODDB::Drugs::SubstanceGroup
+ oid: 18993
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: ASS / ASS-Puffer
+ synonyms: []
+
+ parts:
+ - &id002 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 123067
+ multi:
+ size: 10
+ unit: &id001 !de.oddb.org,2007/ODDB::Drugs::Unit
+ oid: 18979
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Tabletten
+ synonyms: []
+
+ - &id003 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 166317
+ multi:
+ size: 30
+ unit: *id001
+ packages:
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 123068
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "3366167"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: false
+ data_origins:
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ass Stada 500 Tabletten
+ synonyms: []
+
+ parts:
+ - *id002
+ prices:
+ festbetrag: 1.62
+ public: 1.34
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 166318
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "4860432"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: false
+ data_origins:
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ass Stada 500 Tabletten
+ synonyms: []
+
+ parts:
+ - *id003
+ prices:
+ festbetrag: 3.45
+ public: 1.59
+- !de.oddb.org,2007/ODDB::Drugs::Sequence
+ oid: 187618
+ codes: []
+
+ fachinfo_url: http://gripsdb.dimdi.de/amispb/doc/2007/10/20/2149897/OBFME354082201C79E74.rtf
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical: {}
+
+ synonyms: []
+
+ patinfo_url: http://gripsdb.dimdi.de/amispb/doc/2007/10/20/2149897/OBFME3351D5E01C79E74.rtf
+ atc: !de.oddb.org,2007/ODDB::Drugs::Atc
+ oid: 2160
+ code: B01AC06
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :en: Acetylsalicylic Acid
+ :de: "Acetylsalicyls\xC3\xA4ure"
+ synonyms: []
+
+ ddds:
+ - !de.oddb.org,2007/ODDB::Drugs::Ddd
+ oid: 16383
+ administration: O
+ comment: "unabh\xC3\xA4ngig von der Wirkst\xC3\xA4rke"
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 1
+ unit: ""
+ compositions:
+ - !de.oddb.org,2007/ODDB::Drugs::Composition
+ oid: 187614
+ equivalence_factor: 100.0
+ galenic_form: *id004
+ active_agents:
+ - !de.oddb.org,2007/ODDB::Drugs::ActiveAgent
+ oid: 187616
+ dose: !de.oddb.org,2007/ODDB::Drugs::Dose
+ val: 100
+ unit: mg
+ substance: *id005
+ parts:
+ - &id006 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 187621
+ multi:
+ size: 50
+ unit: *id001
+ - &id007 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 187624
+ multi:
+ size: 100
+ unit: *id001
+ - &id008 !de.oddb.org,2007/ODDB::Drugs::Part
+ oid: 188222
+ multi:
+ size: 20
+ unit: *id001
+ packages:
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 187622
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "7382275"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: false
+ data_origins:
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ass Stada 100 Tabletten
+ synonyms: []
+
+ parts:
+ - *id006
+ prices:
+ festbetrag: 2.64
+ public: 1.64
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 187625
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "7382281"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: false
+ data_origins:
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ass Stada 100 Tabletten
+ synonyms: []
+
+ parts:
+ - *id007
+ prices:
+ festbetrag: 4.26
+ public: 2.87
+ - !de.oddb.org,2007/ODDB::Drugs::Package
+ oid: 188223
+ codes:
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: cid
+ value: "7394433"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsgruppe
+ value: "1"
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: festbetragsstufe
+ value: 3
+ - !de.oddb.org,2007/ODDB::Util::Code
+ country: DE
+ type: prescription
+ value: false
+ data_origins:
+ :price_public: :dimdi
+ :price_festbetrag: :dimdi
+ name: !de.oddb.org,2007/ODDB::Util::Multilingual
+ canonical:
+ :de: Ass Stada 100 Tabletten
+ synonyms: []
+
+ parts:
+ - *id008
+ prices:
+ festbetrag: 1.42
+ public: 1.14
diff --git a/src/test/resources/javabeans/genericArray-1.yaml b/src/test/resources/javabeans/genericArray-1.yaml
index 5573ef0..bca5836 100644
--- a/src/test/resources/javabeans/genericArray-1.yaml
+++ b/src/test/resources/javabeans/genericArray-1.yaml
@@ -1,7 +1,7 @@
-ga:
- home:
- - 1
- - 2
- - 3
- name: Array3
+ga:
+ home:
+ - 1
+ - 2
+ - 3
+ name: Array3
id: ID556677
\ No newline at end of file
diff --git a/src/test/resources/javabeans/house-dump1.yaml b/src/test/resources/javabeans/house-dump1.yaml
index 9bd095c..783d968 100644
--- a/src/test/resources/javabeans/house-dump1.yaml
+++ b/src/test/resources/javabeans/house-dump1.yaml
@@ -1,12 +1,12 @@
-frontDoor:
- height: 5
- id: qaz1
- keytype: qwerty123
-number: 1
-reminders:
- today: do nothig
- tomorrow: go shoping
-rooms:
-- name: Hall
-- name: Kitchen
+frontDoor:
+ height: 5
+ id: qaz1
+ keytype: qwerty123
+number: 1
+reminders:
+ today: do nothig
+ tomorrow: go shoping
+rooms:
+- name: Hall
+- name: Kitchen
street: Wall Street
\ No newline at end of file
diff --git a/src/test/resources/javabeans/house-dump2.yaml b/src/test/resources/javabeans/house-dump2.yaml
index b2fd5bc..4a3850b 100644
--- a/src/test/resources/javabeans/house-dump2.yaml
+++ b/src/test/resources/javabeans/house-dump2.yaml
@@ -1,13 +1,13 @@
-!!org.yaml.snakeyaml.javabeans.House
-frontDoor:
- height: 5
- id: qaz1
- keytype: qwerty123
-number: 1
-reminders:
- today: do nothig
- tomorrow: go shoping
-rooms:
-- name: Hall
-- name: Kitchen
+!!org.yaml.snakeyaml.javabeans.House
+frontDoor:
+ height: 5
+ id: qaz1
+ keytype: qwerty123
+number: 1
+reminders:
+ today: do nothig
+ tomorrow: go shoping
+rooms:
+- name: Hall
+- name: Kitchen
street: Wall Street
\ No newline at end of file
diff --git a/src/test/resources/javabeans/house-dump3.yaml b/src/test/resources/javabeans/house-dump3.yaml
index 448ce8b..514d921 100644
--- a/src/test/resources/javabeans/house-dump3.yaml
+++ b/src/test/resources/javabeans/house-dump3.yaml
@@ -1,12 +1,12 @@
-frontDoor:
- height: 5
- id: qaz1
- keytype: qwerty123
-number: 1
-reminders:
- today: do nothig
- tomorrow: go shoping
-rooms:
-- name: Hall
-- name: Kitchen
-street: Wall Street
+frontDoor:
+ height: 5
+ id: qaz1
+ keytype: qwerty123
+number: 1
+reminders:
+ today: do nothig
+ tomorrow: go shoping
+rooms:
+- name: Hall
+- name: Kitchen
+street: Wall Street
diff --git a/src/test/resources/javabeans/issue10-1.yaml b/src/test/resources/javabeans/issue10-1.yaml
index c221b91..83ddc87 100644
--- a/src/test/resources/javabeans/issue10-1.yaml
+++ b/src/test/resources/javabeans/issue10-1.yaml
@@ -1,9 +1,9 @@
-!!org.yaml.snakeyaml.issues.issue10.DataSources
-dataSources:
-- &id001 {name: null}
-- !!org.yaml.snakeyaml.issues.issue10.JDBCDataSource
- name: null
- parent: *id001
- password: null
- url: null
+!!org.yaml.snakeyaml.issues.issue10.DataSources
+dataSources:
+- &id001 {name: null}
+- !!org.yaml.snakeyaml.issues.issue10.JDBCDataSource
+ name: null
+ parent: *id001
+ password: null
+ url: null
username: null
\ No newline at end of file
diff --git a/src/test/resources/javabeans/issue10-2.yaml b/src/test/resources/javabeans/issue10-2.yaml
index 39aff58..0a83745 100644
--- a/src/test/resources/javabeans/issue10-2.yaml
+++ b/src/test/resources/javabeans/issue10-2.yaml
@@ -1,9 +1,9 @@
-dataSources:
-- &id001
- name: null
-- !!org.yaml.snakeyaml.issues.issue10.JDBCDataSource
- name: null
- parent: *id001
- password: null
- url: null
+dataSources:
+- &id001
+ name: null
+- !!org.yaml.snakeyaml.issues.issue10.JDBCDataSource
+ name: null
+ parent: *id001
+ password: null
+ url: null
username: null
\ No newline at end of file
diff --git a/src/test/resources/javabeans/issue10-3.yaml b/src/test/resources/javabeans/issue10-3.yaml
index 65d512e..390a9c7 100644
--- a/src/test/resources/javabeans/issue10-3.yaml
+++ b/src/test/resources/javabeans/issue10-3.yaml
@@ -1,9 +1,9 @@
-dataSources:
-- !!org.yaml.snakeyaml.issues.issue10.JDBCDataSource
- name: null
- parent: &id001
- name: null
- password: null
- url: null
- username: null
+dataSources:
+- !!org.yaml.snakeyaml.issues.issue10.JDBCDataSource
+ name: null
+ parent: &id001
+ name: null
+ password: null
+ url: null
+ username: null
- *id001
\ No newline at end of file
diff --git a/src/test/resources/reader/large.yaml b/src/test/resources/reader/large.yaml
index 1dbdbec..12d5495 100644
--- a/src/test/resources/reader/large.yaml
+++ b/src/test/resources/reader/large.yaml
@@ -1,182 +1,182 @@
-- !!map
- id: id0
- list: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
- map: {'3': 3, '2': 2, '1': 1, '0': 0, '7': 7, '6': 6, '5': 5, '4': 4, '9': 9, '8': 8}
-- !!map
- id: id1
- list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
- map: {'3': 4, '2': 3, '1': 2, '0': 1, '7': 8, '6': 7, '5': 6, '4': 5, '9': 10, '8': 9}
-- !!map
- id: id2
- list: ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11']
- map: {'3': 5, '2': 4, '1': 3, '0': 2, '7': 9, '6': 8, '5': 7, '4': 6, '9': 11, '8': 10}
-- !!map
- id: id3
- list: ['3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
- map: {'3': 6, '2': 5, '1': 4, '0': 3, '7': 10, '6': 9, '5': 8, '4': 7, '9': 12,
- '8': 11}
-- !!map
- id: id4
- list: ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13']
- map: {'3': 7, '2': 6, '1': 5, '0': 4, '7': 11, '6': 10, '5': 9, '4': 8, '9': 13,
- '8': 12}
-- !!map
- id: id5
- list: ['5', '6', '7', '8', '9', '10', '11', '12', '13', '14']
- map: {'3': 8, '2': 7, '1': 6, '0': 5, '7': 12, '6': 11, '5': 10, '4': 9, '9': 14,
- '8': 13}
-- !!map
- id: id6
- list: ['6', '7', '8', '9', '10', '11', '12', '13', '14', '15']
- map: {'3': 9, '2': 8, '1': 7, '0': 6, '7': 13, '6': 12, '5': 11, '4': 10, '9': 15,
- '8': 14}
-- !!map
- id: id7
- list: ['7', '8', '9', '10', '11', '12', '13', '14', '15', '16']
- map: {'3': 10, '2': 9, '1': 8, '0': 7, '7': 14, '6': 13, '5': 12, '4': 11, '9': 16,
- '8': 15}
-- !!map
- id: id8
- list: ['8', '9', '10', '11', '12', '13', '14', '15', '16', '17']
- map: {'3': 11, '2': 10, '1': 9, '0': 8, '7': 15, '6': 14, '5': 13, '4': 12, '9': 17,
- '8': 16}
-- !!map
- id: id9
- list: ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18']
- map: {'3': 12, '2': 11, '1': 10, '0': 9, '7': 16, '6': 15, '5': 14, '4': 13, '9': 18,
- '8': 17}
-- !!map
- id: id10
- list: ['10', '11', '12', '13', '14', '15', '16', '17', '18', '19']
- map: {'3': 13, '2': 12, '1': 11, '0': 10, '7': 17, '6': 16, '5': 15, '4': 14, '9': 19,
- '8': 18}
-- !!map
- id: id11
- list: ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20']
- map: {'3': 14, '2': 13, '1': 12, '0': 11, '7': 18, '6': 17, '5': 16, '4': 15, '9': 20,
- '8': 19}
-- !!map
- id: id12
- list: ['12', '13', '14', '15', '16', '17', '18', '19', '20', '21']
- map: {'3': 15, '2': 14, '1': 13, '0': 12, '7': 19, '6': 18, '5': 17, '4': 16, '9': 21,
- '8': 20}
-- !!map
- id: id13
- list: ['13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
- map: {'3': 16, '2': 15, '1': 14, '0': 13, '7': 20, '6': 19, '5': 18, '4': 17, '9': 22,
- '8': 21}
-- !!map
- id: id14
- list: ['14', '15', '16', '17', '18', '19', '20', '21', '22', '23']
- map: {'3': 17, '2': 16, '1': 15, '0': 14, '7': 21, '6': 20, '5': 19, '4': 18, '9': 23,
- '8': 22}
-- !!map
- id: id15
- list: ['15', '16', '17', '18', '19', '20', '21', '22', '23', '24']
- map: {'3': 18, '2': 17, '1': 16, '0': 15, '7': 22, '6': 21, '5': 20, '4': 19, '9': 24,
- '8': 23}
-- !!map
- id: id16
- list: ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25']
- map: {'3': 19, '2': 18, '1': 17, '0': 16, '7': 23, '6': 22, '5': 21, '4': 20, '9': 25,
- '8': 24}
-- !!map
- id: id17
- list: ['17', '18', '19', '20', '21', '22', '23', '24', '25', '26']
- map: {'3': 20, '2': 19, '1': 18, '0': 17, '7': 24, '6': 23, '5': 22, '4': 21, '9': 26,
- '8': 25}
-- !!map
- id: id18
- list: ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27']
- map: {'3': 21, '2': 20, '1': 19, '0': 18, '7': 25, '6': 24, '5': 23, '4': 22, '9': 27,
- '8': 26}
-- !!map
- id: id19
- list: ['19', '20', '21', '22', '23', '24', '25', '26', '27', '28']
- map: {'3': 22, '2': 21, '1': 20, '0': 19, '7': 26, '6': 25, '5': 24, '4': 23, '9': 28,
- '8': 27}
-- !!map
- id: id20
- list: ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29']
- map: {'3': 23, '2': 22, '1': 21, '0': 20, '7': 27, '6': 26, '5': 25, '4': 24, '9': 29,
- '8': 28}
-- !!map
- id: id21
- list: ['21', '22', '23', '24', '25', '26', '27', '28', '29', '30']
- map: {'3': 24, '2': 23, '1': 22, '0': 21, '7': 28, '6': 27, '5': 26, '4': 25, '9': 30,
- '8': 29}
-- !!map
- id: id22
- list: ['22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
- map: {'3': 25, '2': 24, '1': 23, '0': 22, '7': 29, '6': 28, '5': 27, '4': 26, '9': 31,
- '8': 30}
-- !!map
- id: id23
- list: ['23', '24', '25', '26', '27', '28', '29', '30', '31', '32']
- map: {'3': 26, '2': 25, '1': 24, '0': 23, '7': 30, '6': 29, '5': 28, '4': 27, '9': 32,
- '8': 31}
-- !!map
- id: id24
- list: ['24', '25', '26', '27', '28', '29', '30', '31', '32', '33']
- map: {'3': 27, '2': 26, '1': 25, '0': 24, '7': 31, '6': 30, '5': 29, '4': 28, '9': 33,
- '8': 32}
-- !!map
- id: id25
- list: ['25', '26', '27', '28', '29', '30', '31', '32', '33', '34']
- map: {'3': 28, '2': 27, '1': 26, '0': 25, '7': 32, '6': 31, '5': 30, '4': 29, '9': 34,
- '8': 33}
-- !!map
- id: id26
- list: ['26', '27', '28', '29', '30', '31', '32', '33', '34', '35']
- map: {'3': 29, '2': 28, '1': 27, '0': 26, '7': 33, '6': 32, '5': 31, '4': 30, '9': 35,
- '8': 34}
-- !!map
- id: id27
- list: ['27', '28', '29', '30', '31', '32', '33', '34', '35', '36']
- map: {'3': 30, '2': 29, '1': 28, '0': 27, '7': 34, '6': 33, '5': 32, '4': 31, '9': 36,
- '8': 35}
-- !!map
- id: id28
- list: ['28', '29', '30', '31', '32', '33', '34', '35', '36', '37']
- map: {'3': 31, '2': 30, '1': 29, '0': 28, '7': 35, '6': 34, '5': 33, '4': 32, '9': 37,
- '8': 36}
-- !!map
- id: id29
- list: ['29', '30', '31', '32', '33', '34', '35', '36', '37', '38']
- map: {'3': 32, '2': 31, '1': 30, '0': 29, '7': 36, '6': 35, '5': 34, '4': 33, '9': 38,
- '8': 37}
-- !!map
- id: id30
- list: ['30', '31', '32', '33', '34', '35', '36', '37', '38', '39']
- map: {'3': 33, '2': 32, '1': 31, '0': 30, '7': 37, '6': 36, '5': 35, '4': 34, '9': 39,
- '8': 38}
-- !!map
- id: id31
- list: ['31', '32', '33', '34', '35', '36', '37', '38', '39', '40']
- map: {'3': 34, '2': 33, '1': 32, '0': 31, '7': 38, '6': 37, '5': 36, '4': 35, '9': 40,
- '8': 39}
-- !!map
- id: id32
- list: ['32', '33', '34', '35', '36', '37', '38', '39', '40', '41']
- map: {'3': 35, '2': 34, '1': 33, '0': 32, '7': 39, '6': 38, '5': 37, '4': 36, '9': 41,
- '8': 40}
-- !!map
- id: id33
- list: ['33', '34', '35', '36', '37', '38', '39', '40', '41', '42']
- map: {'3': 36, '2': 35, '1': 34, '0': 33, '7': 40, '6': 39, '5': 38, '4': 37, '9': 42,
- '8': 41}
-- !!map
- id: id34
- list: ['34', '35', '36', '37', '38', '39', '40', '41', '42', '43']
- map: {'3': 37, '2': 36, '1': 35, '0': 34, '7': 41, '6': 40, '5': 39, '4': 38, '9': 43,
- '8': 42}
-- !!map
- id: id35
- list: ['35', '36', '37', '38', '39', '40', '41', '42', '43', '44']
- map: {'3': 38, '2': 37, '1': 36, '0': 35, '7': 42, '6': 41, '5': 40, '4': 39, '9': 44,
- '8': 43}
-- !!map
- id: id36
- list: ['36', '37', '38', '39', '40', '41', '42', '43', '44', '45']
- map: {'3': 39, '2': 38, '1': 37, '0': 36, '7': 43, '6': 42, '5': 41, '4': 40, '9': 45,
- '8': 44}
+- !!map
+ id: id0
+ list: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
+ map: {'3': 3, '2': 2, '1': 1, '0': 0, '7': 7, '6': 6, '5': 5, '4': 4, '9': 9, '8': 8}
+- !!map
+ id: id1
+ list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
+ map: {'3': 4, '2': 3, '1': 2, '0': 1, '7': 8, '6': 7, '5': 6, '4': 5, '9': 10, '8': 9}
+- !!map
+ id: id2
+ list: ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11']
+ map: {'3': 5, '2': 4, '1': 3, '0': 2, '7': 9, '6': 8, '5': 7, '4': 6, '9': 11, '8': 10}
+- !!map
+ id: id3
+ list: ['3', '4', '5', '6', '7', '8', '9', '10', '11', '12']
+ map: {'3': 6, '2': 5, '1': 4, '0': 3, '7': 10, '6': 9, '5': 8, '4': 7, '9': 12,
+ '8': 11}
+- !!map
+ id: id4
+ list: ['4', '5', '6', '7', '8', '9', '10', '11', '12', '13']
+ map: {'3': 7, '2': 6, '1': 5, '0': 4, '7': 11, '6': 10, '5': 9, '4': 8, '9': 13,
+ '8': 12}
+- !!map
+ id: id5
+ list: ['5', '6', '7', '8', '9', '10', '11', '12', '13', '14']
+ map: {'3': 8, '2': 7, '1': 6, '0': 5, '7': 12, '6': 11, '5': 10, '4': 9, '9': 14,
+ '8': 13}
+- !!map
+ id: id6
+ list: ['6', '7', '8', '9', '10', '11', '12', '13', '14', '15']
+ map: {'3': 9, '2': 8, '1': 7, '0': 6, '7': 13, '6': 12, '5': 11, '4': 10, '9': 15,
+ '8': 14}
+- !!map
+ id: id7
+ list: ['7', '8', '9', '10', '11', '12', '13', '14', '15', '16']
+ map: {'3': 10, '2': 9, '1': 8, '0': 7, '7': 14, '6': 13, '5': 12, '4': 11, '9': 16,
+ '8': 15}
+- !!map
+ id: id8
+ list: ['8', '9', '10', '11', '12', '13', '14', '15', '16', '17']
+ map: {'3': 11, '2': 10, '1': 9, '0': 8, '7': 15, '6': 14, '5': 13, '4': 12, '9': 17,
+ '8': 16}
+- !!map
+ id: id9
+ list: ['9', '10', '11', '12', '13', '14', '15', '16', '17', '18']
+ map: {'3': 12, '2': 11, '1': 10, '0': 9, '7': 16, '6': 15, '5': 14, '4': 13, '9': 18,
+ '8': 17}
+- !!map
+ id: id10
+ list: ['10', '11', '12', '13', '14', '15', '16', '17', '18', '19']
+ map: {'3': 13, '2': 12, '1': 11, '0': 10, '7': 17, '6': 16, '5': 15, '4': 14, '9': 19,
+ '8': 18}
+- !!map
+ id: id11
+ list: ['11', '12', '13', '14', '15', '16', '17', '18', '19', '20']
+ map: {'3': 14, '2': 13, '1': 12, '0': 11, '7': 18, '6': 17, '5': 16, '4': 15, '9': 20,
+ '8': 19}
+- !!map
+ id: id12
+ list: ['12', '13', '14', '15', '16', '17', '18', '19', '20', '21']
+ map: {'3': 15, '2': 14, '1': 13, '0': 12, '7': 19, '6': 18, '5': 17, '4': 16, '9': 21,
+ '8': 20}
+- !!map
+ id: id13
+ list: ['13', '14', '15', '16', '17', '18', '19', '20', '21', '22']
+ map: {'3': 16, '2': 15, '1': 14, '0': 13, '7': 20, '6': 19, '5': 18, '4': 17, '9': 22,
+ '8': 21}
+- !!map
+ id: id14
+ list: ['14', '15', '16', '17', '18', '19', '20', '21', '22', '23']
+ map: {'3': 17, '2': 16, '1': 15, '0': 14, '7': 21, '6': 20, '5': 19, '4': 18, '9': 23,
+ '8': 22}
+- !!map
+ id: id15
+ list: ['15', '16', '17', '18', '19', '20', '21', '22', '23', '24']
+ map: {'3': 18, '2': 17, '1': 16, '0': 15, '7': 22, '6': 21, '5': 20, '4': 19, '9': 24,
+ '8': 23}
+- !!map
+ id: id16
+ list: ['16', '17', '18', '19', '20', '21', '22', '23', '24', '25']
+ map: {'3': 19, '2': 18, '1': 17, '0': 16, '7': 23, '6': 22, '5': 21, '4': 20, '9': 25,
+ '8': 24}
+- !!map
+ id: id17
+ list: ['17', '18', '19', '20', '21', '22', '23', '24', '25', '26']
+ map: {'3': 20, '2': 19, '1': 18, '0': 17, '7': 24, '6': 23, '5': 22, '4': 21, '9': 26,
+ '8': 25}
+- !!map
+ id: id18
+ list: ['18', '19', '20', '21', '22', '23', '24', '25', '26', '27']
+ map: {'3': 21, '2': 20, '1': 19, '0': 18, '7': 25, '6': 24, '5': 23, '4': 22, '9': 27,
+ '8': 26}
+- !!map
+ id: id19
+ list: ['19', '20', '21', '22', '23', '24', '25', '26', '27', '28']
+ map: {'3': 22, '2': 21, '1': 20, '0': 19, '7': 26, '6': 25, '5': 24, '4': 23, '9': 28,
+ '8': 27}
+- !!map
+ id: id20
+ list: ['20', '21', '22', '23', '24', '25', '26', '27', '28', '29']
+ map: {'3': 23, '2': 22, '1': 21, '0': 20, '7': 27, '6': 26, '5': 25, '4': 24, '9': 29,
+ '8': 28}
+- !!map
+ id: id21
+ list: ['21', '22', '23', '24', '25', '26', '27', '28', '29', '30']
+ map: {'3': 24, '2': 23, '1': 22, '0': 21, '7': 28, '6': 27, '5': 26, '4': 25, '9': 30,
+ '8': 29}
+- !!map
+ id: id22
+ list: ['22', '23', '24', '25', '26', '27', '28', '29', '30', '31']
+ map: {'3': 25, '2': 24, '1': 23, '0': 22, '7': 29, '6': 28, '5': 27, '4': 26, '9': 31,
+ '8': 30}
+- !!map
+ id: id23
+ list: ['23', '24', '25', '26', '27', '28', '29', '30', '31', '32']
+ map: {'3': 26, '2': 25, '1': 24, '0': 23, '7': 30, '6': 29, '5': 28, '4': 27, '9': 32,
+ '8': 31}
+- !!map
+ id: id24
+ list: ['24', '25', '26', '27', '28', '29', '30', '31', '32', '33']
+ map: {'3': 27, '2': 26, '1': 25, '0': 24, '7': 31, '6': 30, '5': 29, '4': 28, '9': 33,
+ '8': 32}
+- !!map
+ id: id25
+ list: ['25', '26', '27', '28', '29', '30', '31', '32', '33', '34']
+ map: {'3': 28, '2': 27, '1': 26, '0': 25, '7': 32, '6': 31, '5': 30, '4': 29, '9': 34,
+ '8': 33}
+- !!map
+ id: id26
+ list: ['26', '27', '28', '29', '30', '31', '32', '33', '34', '35']
+ map: {'3': 29, '2': 28, '1': 27, '0': 26, '7': 33, '6': 32, '5': 31, '4': 30, '9': 35,
+ '8': 34}
+- !!map
+ id: id27
+ list: ['27', '28', '29', '30', '31', '32', '33', '34', '35', '36']
+ map: {'3': 30, '2': 29, '1': 28, '0': 27, '7': 34, '6': 33, '5': 32, '4': 31, '9': 36,
+ '8': 35}
+- !!map
+ id: id28
+ list: ['28', '29', '30', '31', '32', '33', '34', '35', '36', '37']
+ map: {'3': 31, '2': 30, '1': 29, '0': 28, '7': 35, '6': 34, '5': 33, '4': 32, '9': 37,
+ '8': 36}
+- !!map
+ id: id29
+ list: ['29', '30', '31', '32', '33', '34', '35', '36', '37', '38']
+ map: {'3': 32, '2': 31, '1': 30, '0': 29, '7': 36, '6': 35, '5': 34, '4': 33, '9': 38,
+ '8': 37}
+- !!map
+ id: id30
+ list: ['30', '31', '32', '33', '34', '35', '36', '37', '38', '39']
+ map: {'3': 33, '2': 32, '1': 31, '0': 30, '7': 37, '6': 36, '5': 35, '4': 34, '9': 39,
+ '8': 38}
+- !!map
+ id: id31
+ list: ['31', '32', '33', '34', '35', '36', '37', '38', '39', '40']
+ map: {'3': 34, '2': 33, '1': 32, '0': 31, '7': 38, '6': 37, '5': 36, '4': 35, '9': 40,
+ '8': 39}
+- !!map
+ id: id32
+ list: ['32', '33', '34', '35', '36', '37', '38', '39', '40', '41']
+ map: {'3': 35, '2': 34, '1': 33, '0': 32, '7': 39, '6': 38, '5': 37, '4': 36, '9': 41,
+ '8': 40}
+- !!map
+ id: id33
+ list: ['33', '34', '35', '36', '37', '38', '39', '40', '41', '42']
+ map: {'3': 36, '2': 35, '1': 34, '0': 33, '7': 40, '6': 39, '5': 38, '4': 37, '9': 42,
+ '8': 41}
+- !!map
+ id: id34
+ list: ['34', '35', '36', '37', '38', '39', '40', '41', '42', '43']
+ map: {'3': 37, '2': 36, '1': 35, '0': 34, '7': 41, '6': 40, '5': 39, '4': 38, '9': 43,
+ '8': 42}
+- !!map
+ id: id35
+ list: ['35', '36', '37', '38', '39', '40', '41', '42', '43', '44']
+ map: {'3': 38, '2': 37, '1': 36, '0': 35, '7': 42, '6': 41, '5': 40, '4': 39, '9': 44,
+ '8': 43}
+- !!map
+ id: id36
+ list: ['36', '37', '38', '39', '40', '41', '42', '43', '44', '45']
+ map: {'3': 39, '2': 38, '1': 37, '0': 36, '7': 43, '6': 42, '5': 41, '4': 40, '9': 45,
+ '8': 44}
diff --git a/src/test/resources/recursive/beanring-3.yaml b/src/test/resources/recursive/beanring-3.yaml
index f6b0fb3..eb97a4e 100644
--- a/src/test/resources/recursive/beanring-3.yaml
+++ b/src/test/resources/recursive/beanring-3.yaml
@@ -1,25 +1,25 @@
-&id001 !!org.yaml.snakeyaml.recursive.Human
-bankAccountOwner:
- bankAccountOwner:
- bankAccountOwner: *id001
- birthPlace: null
- birthday: null
- children: !!set {}
- father: null
- mother: null
- name: Man 3
- partner: null
- birthPlace: null
- birthday: null
- children: !!set {}
- father: null
- mother: null
- name: Man 2
- partner: null
-birthPlace: null
-birthday: null
-children: !!set {}
-father: null
-mother: null
-name: Man 1
+&id001 !!org.yaml.snakeyaml.recursive.Human
+bankAccountOwner:
+ bankAccountOwner:
+ bankAccountOwner: *id001
+ birthPlace: null
+ birthday: null
+ children: !!set {}
+ father: null
+ mother: null
+ name: Man 3
+ partner: null
+ birthPlace: null
+ birthday: null
+ children: !!set {}
+ father: null
+ mother: null
+ name: Man 2
+ partner: null
+birthPlace: null
+birthday: null
+children: !!set {}
+father: null
+mother: null
+name: Man 1
partner: null
\ No newline at end of file
diff --git a/src/test/resources/recursive/generics/beanring-3.yaml b/src/test/resources/recursive/generics/beanring-3.yaml
index 2e71b6a..56b9207 100644
--- a/src/test/resources/recursive/generics/beanring-3.yaml
+++ b/src/test/resources/recursive/generics/beanring-3.yaml
@@ -1,25 +1,25 @@
-&id001 !!org.yaml.snakeyaml.recursive.generics.HumanGen
-bankAccountOwner:
- bankAccountOwner:
- bankAccountOwner: *id001
- birthPlace: null
- birthday: null
- children: !!set {}
- father: null
- mother: null
- name: Man 3
- partner: null
- birthPlace: null
- birthday: null
- children: !!set {}
- father: null
- mother: null
- name: Man 2
- partner: null
-birthPlace: null
-birthday: null
-children: !!set {}
-father: null
-mother: null
-name: Man 1
+&id001 !!org.yaml.snakeyaml.recursive.generics.HumanGen
+bankAccountOwner:
+ bankAccountOwner:
+ bankAccountOwner: *id001
+ birthPlace: null
+ birthday: null
+ children: !!set {}
+ father: null
+ mother: null
+ name: Man 3
+ partner: null
+ birthPlace: null
+ birthday: null
+ children: !!set {}
+ father: null
+ mother: null
+ name: Man 2
+ partner: null
+birthPlace: null
+birthday: null
+children: !!set {}
+father: null
+mother: null
+name: Man 1
partner: null
\ No newline at end of file
diff --git a/src/test/resources/recursive/generics/no-children-1.yaml b/src/test/resources/recursive/generics/no-children-1.yaml
index 9e8e1de..cef7c7b 100644
--- a/src/test/resources/recursive/generics/no-children-1.yaml
+++ b/src/test/resources/recursive/generics/no-children-1.yaml
@@ -1,17 +1,17 @@
-&id001 !!org.yaml.snakeyaml.recursive.generics.HumanGen
-bankAccountOwner: *id001
-birthPlace: Leningrad
-birthday: 1970-01-12T13:46:40Z
-children: !!set {}
-father: null
-mother: null
-name: Father
-partner:
- bankAccountOwner: *id001
- birthPlace: Saint-Petersburg
- birthday: 1973-03-03T09:46:40Z
- children: !!set {}
- father: null
- mother: null
- name: Mother
+&id001 !!org.yaml.snakeyaml.recursive.generics.HumanGen
+bankAccountOwner: *id001
+birthPlace: Leningrad
+birthday: 1970-01-12T13:46:40Z
+children: !!set {}
+father: null
+mother: null
+name: Father
+partner:
+ bankAccountOwner: *id001
+ birthPlace: Saint-Petersburg
+ birthday: 1973-03-03T09:46:40Z
+ children: !!set {}
+ father: null
+ mother: null
+ name: Mother
partner: *id001
\ No newline at end of file
diff --git a/src/test/resources/recursive/generics/no-children-2.yaml b/src/test/resources/recursive/generics/no-children-2.yaml
index 43a625b..fd31206 100644
--- a/src/test/resources/recursive/generics/no-children-2.yaml
+++ b/src/test/resources/recursive/generics/no-children-2.yaml
@@ -1,17 +1,17 @@
-&id001
-bankAccountOwner: *id001
-birthPlace: Leningrad
-birthday: 1970-01-12T13:46:40Z
-children: !!set {}
-father: null
-mother: null
-name: Father
-partner:
- bankAccountOwner: *id001
- birthPlace: Saint-Petersburg
- birthday: 1973-03-03T09:46:40Z
- children: !!set {}
- father: null
- mother: null
- name: Mother
+&id001
+bankAccountOwner: *id001
+birthPlace: Leningrad
+birthday: 1970-01-12T13:46:40Z
+children: !!set {}
+father: null
+mother: null
+name: Father
+partner:
+ bankAccountOwner: *id001
+ birthPlace: Saint-Petersburg
+ birthday: 1973-03-03T09:46:40Z
+ children: !!set {}
+ father: null
+ mother: null
+ name: Mother
partner: *id001
\ No newline at end of file
diff --git a/src/test/resources/recursive/no-children-1-pretty.yaml b/src/test/resources/recursive/no-children-1-pretty.yaml
index 1dfac19..5a6e4c3 100644
--- a/src/test/resources/recursive/no-children-1-pretty.yaml
+++ b/src/test/resources/recursive/no-children-1-pretty.yaml
@@ -1,21 +1,21 @@
-&id001 !!org.yaml.snakeyaml.recursive.Human {
- bankAccountOwner: *id001,
- birthPlace: Leningrad,
- birthday: !!timestamp '1970-01-12T13:46:40Z',
- children: !!set {
- },
- father: null,
- mother: null,
- name: Father,
- partner: {
- bankAccountOwner: *id001,
- birthPlace: Saint-Petersburg,
- birthday: !!timestamp '1973-03-03T09:46:40Z',
- children: !!set {
- },
- father: null,
- mother: null,
- name: Mother,
- partner: *id001
- }
-}
+&id001 !!org.yaml.snakeyaml.recursive.Human {
+ bankAccountOwner: *id001,
+ birthPlace: Leningrad,
+ birthday: !!timestamp '1970-01-12T13:46:40Z',
+ children: !!set {
+ },
+ father: null,
+ mother: null,
+ name: Father,
+ partner: {
+ bankAccountOwner: *id001,
+ birthPlace: Saint-Petersburg,
+ birthday: !!timestamp '1973-03-03T09:46:40Z',
+ children: !!set {
+ },
+ father: null,
+ mother: null,
+ name: Mother,
+ partner: *id001
+ }
+}
diff --git a/src/test/resources/recursive/no-children-1.yaml b/src/test/resources/recursive/no-children-1.yaml
index df4b6d8..8f80490 100644
--- a/src/test/resources/recursive/no-children-1.yaml
+++ b/src/test/resources/recursive/no-children-1.yaml
@@ -1,17 +1,17 @@
-&id001 !!org.yaml.snakeyaml.recursive.Human
-bankAccountOwner: *id001
-birthPlace: Leningrad
-birthday: 1970-01-12T13:46:40Z
-children: !!set {}
-father: null
-mother: null
-name: Father
-partner:
- bankAccountOwner: *id001
- birthPlace: Saint-Petersburg
- birthday: 1973-03-03T09:46:40Z
- children: !!set {}
- father: null
- mother: null
- name: Mother
+&id001 !!org.yaml.snakeyaml.recursive.Human
+bankAccountOwner: *id001
+birthPlace: Leningrad
+birthday: 1970-01-12T13:46:40Z
+children: !!set {}
+father: null
+mother: null
+name: Father
+partner:
+ bankAccountOwner: *id001
+ birthPlace: Saint-Petersburg
+ birthday: 1973-03-03T09:46:40Z
+ children: !!set {}
+ father: null
+ mother: null
+ name: Mother
partner: *id001
\ No newline at end of file
diff --git a/src/test/resources/recursive/with-children-no-root-tag.yaml b/src/test/resources/recursive/with-children-no-root-tag.yaml
index fe73289..57aa0b3 100644
--- a/src/test/resources/recursive/with-children-no-root-tag.yaml
+++ b/src/test/resources/recursive/with-children-no-root-tag.yaml
@@ -1,35 +1,35 @@
-&id002
-bankAccountOwner: &id001
- bankAccountOwner: *id001
- birthPlace: Leningrad
- birthday: 1970-01-12T13:46:40Z
- children: &id003 !!set
- *id002: null
- ? bankAccountOwner: *id001
- birthPlace: New York
- birthday: 1983-04-24T02:40:00Z
- children: !!set {}
- father: *id001
- mother: &id004
- bankAccountOwner: *id001
- birthPlace: Saint-Petersburg
- birthday: 1973-03-03T09:46:40Z
- children: *id003
- father: null
- mother: null
- name: Mother
- partner: *id001
- name: Daughter
- partner: null
- : null
- father: null
- mother: null
- name: Father
- partner: *id004
-birthPlace: Munich
-birthday: 1979-10-28T23:06:40Z
-children: !!set {}
-father: *id001
-mother: *id004
-name: Son
+&id002
+bankAccountOwner: &id001
+ bankAccountOwner: *id001
+ birthPlace: Leningrad
+ birthday: 1970-01-12T13:46:40Z
+ children: &id003 !!set
+ *id002: null
+ ? bankAccountOwner: *id001
+ birthPlace: New York
+ birthday: 1983-04-24T02:40:00Z
+ children: !!set {}
+ father: *id001
+ mother: &id004
+ bankAccountOwner: *id001
+ birthPlace: Saint-Petersburg
+ birthday: 1973-03-03T09:46:40Z
+ children: *id003
+ father: null
+ mother: null
+ name: Mother
+ partner: *id001
+ name: Daughter
+ partner: null
+ : null
+ father: null
+ mother: null
+ name: Father
+ partner: *id004
+birthPlace: Munich
+birthday: 1979-10-28T23:06:40Z
+children: !!set {}
+father: *id001
+mother: *id004
+name: Son
partner: null
\ No newline at end of file
diff --git a/src/test/resources/recursive/with-childrenArray-no-root-tag.yaml b/src/test/resources/recursive/with-childrenArray-no-root-tag.yaml
index 7bd8342..c76437b 100644
--- a/src/test/resources/recursive/with-childrenArray-no-root-tag.yaml
+++ b/src/test/resources/recursive/with-childrenArray-no-root-tag.yaml
@@ -1,34 +1,34 @@
-&id002
-bankAccountOwner: &id001
- bankAccountOwner: *id001
- birthPlace: Leningrad
- birthday: 1970-01-12T13:46:40Z
- children: &id003
- - *id002
- - bankAccountOwner: *id001
- birthPlace: New York
- birthday: 1983-04-24T02:40:00Z
- children: []
- father: *id001
- mother: &id004
- bankAccountOwner: *id001
- birthPlace: Saint-Petersburg
- birthday: 1973-03-03T09:46:40Z
- children: *id003
- father: null
- mother: null
- name: Mother
- partner: *id001
- name: Daughter
- partner: null
- father: null
- mother: null
- name: Father
- partner: *id004
-birthPlace: Munich
-birthday: 1979-10-28T23:06:40Z
-children: []
-father: *id001
-mother: *id004
-name: Son
+&id002
+bankAccountOwner: &id001
+ bankAccountOwner: *id001
+ birthPlace: Leningrad
+ birthday: 1970-01-12T13:46:40Z
+ children: &id003
+ - *id002
+ - bankAccountOwner: *id001
+ birthPlace: New York
+ birthday: 1983-04-24T02:40:00Z
+ children: []
+ father: *id001
+ mother: &id004
+ bankAccountOwner: *id001
+ birthPlace: Saint-Petersburg
+ birthday: 1973-03-03T09:46:40Z
+ children: *id003
+ father: null
+ mother: null
+ name: Mother
+ partner: *id001
+ name: Daughter
+ partner: null
+ father: null
+ mother: null
+ name: Father
+ partner: *id004
+birthPlace: Munich
+birthday: 1979-10-28T23:06:40Z
+children: []
+father: *id001
+mother: *id004
+name: Son
partner: null
\ No newline at end of file
diff --git a/src/test/resources/recursive/with-childrenArray.yaml b/src/test/resources/recursive/with-childrenArray.yaml
index 5a72417..b174b7b 100644
--- a/src/test/resources/recursive/with-childrenArray.yaml
+++ b/src/test/resources/recursive/with-childrenArray.yaml
@@ -1,34 +1,34 @@
-&id002 !!org.yaml.snakeyaml.recursive.Human_WithArrayOfChildrenTest$Human_WithArrayOfChildren
-bankAccountOwner: &id001
- bankAccountOwner: *id001
- birthPlace: Leningrad
- birthday: 1970-01-12T13:46:40Z
- children: &id003
- - *id002
- - bankAccountOwner: *id001
- birthPlace: New York
- birthday: 1983-04-24T02:40:00Z
- children: []
- father: *id001
- mother: &id004
- bankAccountOwner: *id001
- birthPlace: Saint-Petersburg
- birthday: 1973-03-03T09:46:40Z
- children: *id003
- father: null
- mother: null
- name: Mother
- partner: *id001
- name: Daughter
- partner: null
- father: null
- mother: null
- name: Father
- partner: *id004
-birthPlace: Munich
-birthday: 1979-10-28T23:06:40Z
-children: []
-father: *id001
-mother: *id004
-name: Son
+&id002 !!org.yaml.snakeyaml.recursive.Human_WithArrayOfChildrenTest$Human_WithArrayOfChildren
+bankAccountOwner: &id001
+ bankAccountOwner: *id001
+ birthPlace: Leningrad
+ birthday: 1970-01-12T13:46:40Z
+ children: &id003
+ - *id002
+ - bankAccountOwner: *id001
+ birthPlace: New York
+ birthday: 1983-04-24T02:40:00Z
+ children: []
+ father: *id001
+ mother: &id004
+ bankAccountOwner: *id001
+ birthPlace: Saint-Petersburg
+ birthday: 1973-03-03T09:46:40Z
+ children: *id003
+ father: null
+ mother: null
+ name: Mother
+ partner: *id001
+ name: Daughter
+ partner: null
+ father: null
+ mother: null
+ name: Father
+ partner: *id004
+birthPlace: Munich
+birthday: 1979-10-28T23:06:40Z
+children: []
+father: *id001
+mother: *id004
+name: Son
partner: null
\ No newline at end of file
diff --git a/src/test/resources/representer/scalar-style1.yaml b/src/test/resources/representer/scalar-style1.yaml
index aece58d..a1c6842 100644
--- a/src/test/resources/representer/scalar-style1.yaml
+++ b/src/test/resources/representer/scalar-style1.yaml
@@ -1,6 +1,6 @@
-name: Steve Jobs
-address: |-
- Name
- Street Number
- Country
-description: 1111111111 2222222222 3333333333 4444444444 5555555555 6666666666 7777777777 8888888888 9999999999 0000000000
+name: Steve Jobs
+address: |-
+ Name
+ Street Number
+ Country
+description: 1111111111 2222222222 3333333333 4444444444 5555555555 6666666666 7777777777 8888888888 9999999999 0000000000
diff --git a/src/test/resources/representer/scalar-style2.yaml b/src/test/resources/representer/scalar-style2.yaml
index e4228d3..cbbc13d 100644
--- a/src/test/resources/representer/scalar-style2.yaml
+++ b/src/test/resources/representer/scalar-style2.yaml
@@ -1,10 +1,10 @@
-name: Steve Jobs
-address: |-
- Name
- Street Number
- Country
-description: >-
- 1111111111 2222222222 3333333333
- 4444444444 5555555555 6666666666
- 7777777777 8888888888 9999999999
- 0000000000
+name: Steve Jobs
+address: |-
+ Name
+ Street Number
+ Country
+description: >-
+ 1111111111 2222222222 3333333333
+ 4444444444 5555555555 6666666666
+ 7777777777 8888888888 9999999999
+ 0000000000
diff --git a/src/test/resources/ruby/ruby1.yaml b/src/test/resources/ruby/ruby1.yaml
index 9bc9a07..e1329ec 100644
--- a/src/test/resources/ruby/ruby1.yaml
+++ b/src/test/resources/ruby/ruby1.yaml
@@ -1,10 +1,10 @@
---- !ruby/object:Test::Module::Object
- sub1: !ruby/object:Test::Module::Sub1
- att1: []
- att2: 0
- att3: []
- sub2: !ruby/object:Test::Module::Sub2
- att1: MyString
- att2:
- - entry1
- att3: 12345
+--- !ruby/object:Test::Module::Object
+ sub1: !ruby/object:Test::Module::Sub1
+ att1: []
+ att2: 0
+ att3: []
+ sub2: !ruby/object:Test::Module::Sub2
+ att1: MyString
+ att2:
+ - entry1
+ att3: 12345
diff --git a/src/test/resources/specification/example2_1.yaml b/src/test/resources/specification/example2_1.yaml
index 3cb7d7a..d12e671 100644
--- a/src/test/resources/specification/example2_1.yaml
+++ b/src/test/resources/specification/example2_1.yaml
@@ -1,3 +1,3 @@
-- Mark McGwire
-- Sammy Sosa
-- Ken Griffey
+- Mark McGwire
+- Sammy Sosa
+- Ken Griffey
diff --git a/src/test/resources/specification/example2_10.yaml b/src/test/resources/specification/example2_10.yaml
index f9e23ba..61808f6 100644
--- a/src/test/resources/specification/example2_10.yaml
+++ b/src/test/resources/specification/example2_10.yaml
@@ -1,8 +1,8 @@
----
-hr:
- - Mark McGwire
- # Following node labeled SS
- - &SS Sammy Sosa
-rbi:
- - *SS # Subsequent occurrence
- - Ken Griffey
+---
+hr:
+ - Mark McGwire
+ # Following node labeled SS
+ - &SS Sammy Sosa
+rbi:
+ - *SS # Subsequent occurrence
+ - Ken Griffey
diff --git a/src/test/resources/specification/example2_11.yaml b/src/test/resources/specification/example2_11.yaml
index bc99177..9123ce2 100644
--- a/src/test/resources/specification/example2_11.yaml
+++ b/src/test/resources/specification/example2_11.yaml
@@ -1,9 +1,9 @@
-? - Detroit Tigers
- - Chicago cubs
-:
- - 2001-07-23
-
-? [ New York Yankees,
- Atlanta Braves ]
-: [ 2001-07-02, 2001-08-12,
- 2001-08-14 ]
+? - Detroit Tigers
+ - Chicago cubs
+:
+ - 2001-07-23
+
+? [ New York Yankees,
+ Atlanta Braves ]
+: [ 2001-07-02, 2001-08-12,
+ 2001-08-14 ]
diff --git a/src/test/resources/specification/example2_12.yaml b/src/test/resources/specification/example2_12.yaml
index 6c120ac..1fc33f9 100644
--- a/src/test/resources/specification/example2_12.yaml
+++ b/src/test/resources/specification/example2_12.yaml
@@ -1,8 +1,8 @@
----
-# products purchased
-- item : Super Hoop
- quantity: 1
-- item : Basketball
- quantity: 4
-- item : Big Shoes
- quantity: 1
+---
+# products purchased
+- item : Super Hoop
+ quantity: 1
+- item : Basketball
+ quantity: 4
+- item : Big Shoes
+ quantity: 1
diff --git a/src/test/resources/specification/example2_13.yaml b/src/test/resources/specification/example2_13.yaml
index e927638..13fb656 100644
--- a/src/test/resources/specification/example2_13.yaml
+++ b/src/test/resources/specification/example2_13.yaml
@@ -1,4 +1,4 @@
-# ASCII Art
---- |
- \//||\/||
- // || ||__
+# ASCII Art
+--- |
+ \//||\/||
+ // || ||__
diff --git a/src/test/resources/specification/example2_14.yaml b/src/test/resources/specification/example2_14.yaml
index f39eb53..59943de 100644
--- a/src/test/resources/specification/example2_14.yaml
+++ b/src/test/resources/specification/example2_14.yaml
@@ -1,4 +1,4 @@
----
- Mark McGwire's
- year was crippled
- by a knee injury.
+---
+ Mark McGwire's
+ year was crippled
+ by a knee injury.
diff --git a/src/test/resources/specification/example2_15.yaml b/src/test/resources/specification/example2_15.yaml
index fc92a53..80b89a6 100644
--- a/src/test/resources/specification/example2_15.yaml
+++ b/src/test/resources/specification/example2_15.yaml
@@ -1,8 +1,8 @@
->
- Sammy Sosa completed another
- fine season with great stats.
-
- 63 Home Runs
- 0.288 Batting Average
-
- What a year!
+>
+ Sammy Sosa completed another
+ fine season with great stats.
+
+ 63 Home Runs
+ 0.288 Batting Average
+
+ What a year!
diff --git a/src/test/resources/specification/example2_15_dumped.yaml b/src/test/resources/specification/example2_15_dumped.yaml
index b7516cc..cc2d963 100644
--- a/src/test/resources/specification/example2_15_dumped.yaml
+++ b/src/test/resources/specification/example2_15_dumped.yaml
@@ -1,7 +1,7 @@
->
- Sammy Sosa completed another fine season with great stats.
-
- 63 Home Runs
- 0.288 Batting Average
-
+>
+ Sammy Sosa completed another fine season with great stats.
+
+ 63 Home Runs
+ 0.288 Batting Average
+
What a year!
\ No newline at end of file
diff --git a/src/test/resources/specification/example2_16.yaml b/src/test/resources/specification/example2_16.yaml
index 2e7ea48..9f66d88 100644
--- a/src/test/resources/specification/example2_16.yaml
+++ b/src/test/resources/specification/example2_16.yaml
@@ -1,7 +1,7 @@
-name: Mark McGwire
-accomplishment: >
- Mark set a major league
- home run record in 1998.
-stats: |
- 65 Home Runs
- 0.278 Batting Average
+name: Mark McGwire
+accomplishment: >
+ Mark set a major league
+ home run record in 1998.
+stats: |
+ 65 Home Runs
+ 0.278 Batting Average
diff --git a/src/test/resources/specification/example2_17.yaml b/src/test/resources/specification/example2_17.yaml
index 592d4ae..3e899c0 100644
--- a/src/test/resources/specification/example2_17.yaml
+++ b/src/test/resources/specification/example2_17.yaml
@@ -1,7 +1,7 @@
-unicode: "Sosa did fine.\u263A"
-control: "\b1998\t1999\t2000\n"
-hexesc: "\x0D\x0A is \r\n"
-
-single: '"Howdy!" he cried.'
-quoted: ' # not a ''comment''.'
-tie-fighter: '|\-*-/|'
+unicode: "Sosa did fine.\u263A"
+control: "\b1998\t1999\t2000\n"
+hexesc: "\x0D\x0A is \r\n"
+
+single: '"Howdy!" he cried.'
+quoted: ' # not a ''comment''.'
+tie-fighter: '|\-*-/|'
diff --git a/src/test/resources/specification/example2_17_control.yaml b/src/test/resources/specification/example2_17_control.yaml
index b8447d9..59398a6 100644
--- a/src/test/resources/specification/example2_17_control.yaml
+++ b/src/test/resources/specification/example2_17_control.yaml
@@ -1,2 +1,2 @@
-control: "\b1998\t1999\t2000\n"
-
+control: "\b1998\t1999\t2000\n"
+
diff --git a/src/test/resources/specification/example2_17_hexesc.yaml b/src/test/resources/specification/example2_17_hexesc.yaml
index c323530..7ddff26 100644
--- a/src/test/resources/specification/example2_17_hexesc.yaml
+++ b/src/test/resources/specification/example2_17_hexesc.yaml
@@ -1,2 +1,2 @@
-hexesc: "\x0D\x0A is \r\n"
-
+hexesc: "\x0D\x0A is \r\n"
+
diff --git a/src/test/resources/specification/example2_17_quoted.yaml b/src/test/resources/specification/example2_17_quoted.yaml
index 8e7ca05..bedc4a5 100644
--- a/src/test/resources/specification/example2_17_quoted.yaml
+++ b/src/test/resources/specification/example2_17_quoted.yaml
@@ -1,2 +1,2 @@
-quoted: ' # not a ''comment''.'
-
+quoted: ' # not a ''comment''.'
+
diff --git a/src/test/resources/specification/example2_17_single.yaml b/src/test/resources/specification/example2_17_single.yaml
index 8f69b6c..c3fe6aa 100644
--- a/src/test/resources/specification/example2_17_single.yaml
+++ b/src/test/resources/specification/example2_17_single.yaml
@@ -1 +1 @@
-single: '"Howdy!" he cried.'
+single: '"Howdy!" he cried.'
diff --git a/src/test/resources/specification/example2_17_tie_fighter.yaml b/src/test/resources/specification/example2_17_tie_fighter.yaml
index 3d3928f..9d82173 100644
--- a/src/test/resources/specification/example2_17_tie_fighter.yaml
+++ b/src/test/resources/specification/example2_17_tie_fighter.yaml
@@ -1 +1 @@
-tie-fighter: '|\-*-/|'
+tie-fighter: '|\-*-/|'
diff --git a/src/test/resources/specification/example2_17_unicode.yaml b/src/test/resources/specification/example2_17_unicode.yaml
index 60ec808..2b378bd 100644
--- a/src/test/resources/specification/example2_17_unicode.yaml
+++ b/src/test/resources/specification/example2_17_unicode.yaml
@@ -1,2 +1,2 @@
-unicode: "Sosa did fine.\u263A"
-
+unicode: "Sosa did fine.\u263A"
+
diff --git a/src/test/resources/specification/example2_18.yaml b/src/test/resources/specification/example2_18.yaml
index 76fe0d2..e0a8bfa 100644
--- a/src/test/resources/specification/example2_18.yaml
+++ b/src/test/resources/specification/example2_18.yaml
@@ -1,6 +1,6 @@
-plain:
- This unquoted scalar
- spans many lines.
-
-quoted: "So does this
- quoted scalar.\n"
+plain:
+ This unquoted scalar
+ spans many lines.
+
+quoted: "So does this
+ quoted scalar.\n"
diff --git a/src/test/resources/specification/example2_19.yaml b/src/test/resources/specification/example2_19.yaml
index 4a1c070..8aeb1a4 100644
--- a/src/test/resources/specification/example2_19.yaml
+++ b/src/test/resources/specification/example2_19.yaml
@@ -1,5 +1,5 @@
-canonical: 12345
-decimal: +12_345
-sexagesimal: 3:25:45
-octal: 014
-hexadecimal: 0xC
+canonical: 12345
+decimal: +12_345
+sexagesimal: 3:25:45
+octal: 014
+hexadecimal: 0xC
diff --git a/src/test/resources/specification/example2_2.yaml b/src/test/resources/specification/example2_2.yaml
index efd138d..7b7ec94 100644
--- a/src/test/resources/specification/example2_2.yaml
+++ b/src/test/resources/specification/example2_2.yaml
@@ -1,3 +1,3 @@
-hr: 65 # Home runs
-avg: 0.278 # Batting average
-rbi: 147 # Runs Batted In
+hr: 65 # Home runs
+avg: 0.278 # Batting average
+rbi: 147 # Runs Batted In
diff --git a/src/test/resources/specification/example2_20.yaml b/src/test/resources/specification/example2_20.yaml
index ceb1fd0..60bfc06 100644
--- a/src/test/resources/specification/example2_20.yaml
+++ b/src/test/resources/specification/example2_20.yaml
@@ -1,6 +1,6 @@
-canonical: 1.23015e+3
-exponential: 12.3015e+02
-sexagesimal: 20:30.15
-fixed: 1_230.15
-negative infinity: -.inf
-not a number: .NaN
+canonical: 1.23015e+3
+exponential: 12.3015e+02
+sexagesimal: 20:30.15
+fixed: 1_230.15
+negative infinity: -.inf
+not a number: .NaN
diff --git a/src/test/resources/specification/example2_21.yaml b/src/test/resources/specification/example2_21.yaml
index d017aff..c065b2a 100644
--- a/src/test/resources/specification/example2_21.yaml
+++ b/src/test/resources/specification/example2_21.yaml
@@ -1,4 +1,4 @@
-null: ~
-true: yes
-false: no
-string: '12345'
+null: ~
+true: yes
+false: no
+string: '12345'
diff --git a/src/test/resources/specification/example2_22.yaml b/src/test/resources/specification/example2_22.yaml
index d4781f7..aaac185 100644
--- a/src/test/resources/specification/example2_22.yaml
+++ b/src/test/resources/specification/example2_22.yaml
@@ -1,4 +1,4 @@
-canonical: 2001-12-15T02:59:43.1Z
-iso8601: 2001-12-14t21:59:43.10-05:00
-spaced: 2001-12-14 21:59:43.10 -5
-date: 2002-12-14
+canonical: 2001-12-15T02:59:43.1Z
+iso8601: 2001-12-14t21:59:43.10-05:00
+spaced: 2001-12-14 21:59:43.10 -5
+date: 2002-12-14
diff --git a/src/test/resources/specification/example2_23.yaml b/src/test/resources/specification/example2_23.yaml
index 310d472..adbe4e6 100644
--- a/src/test/resources/specification/example2_23.yaml
+++ b/src/test/resources/specification/example2_23.yaml
@@ -1,14 +1,14 @@
----
-not-date: !!str 2002-04-28
-
-picture: !!binary "\
- R0lGODlhDAAMAIQAAP//9/X\
- 17unp5WZmZgAAAOfn515eXv\
- Pz7Y6OjuDg4J+fn5OTk6enp\
- 56enmleECcgggoBADs="
-
-application specific tag: !something |
- The semantics of the tag
- above may be different for
- different documents.
-
+---
+not-date: !!str 2002-04-28
+
+picture: !!binary "\
+ R0lGODlhDAAMAIQAAP//9/X\
+ 17unp5WZmZgAAAOfn515eXv\
+ Pz7Y6OjuDg4J+fn5OTk6enp\
+ 56enmleECcgggoBADs="
+
+application specific tag: !something |
+ The semantics of the tag
+ above may be different for
+ different documents.
+
diff --git a/src/test/resources/specification/example2_23_application.yaml b/src/test/resources/specification/example2_23_application.yaml
index a77e4ef..03cc760 100644
--- a/src/test/resources/specification/example2_23_application.yaml
+++ b/src/test/resources/specification/example2_23_application.yaml
@@ -1,5 +1,5 @@
----
-application specific tag: !something |
- The semantics of the tag
- above may be different for
- different documents.
+---
+application specific tag: !something |
+ The semantics of the tag
+ above may be different for
+ different documents.
diff --git a/src/test/resources/specification/example2_23_non_date.yaml b/src/test/resources/specification/example2_23_non_date.yaml
index 58a6a32..2e95415 100644
--- a/src/test/resources/specification/example2_23_non_date.yaml
+++ b/src/test/resources/specification/example2_23_non_date.yaml
@@ -1,3 +1,3 @@
----
-not-date: !!str 2002-04-28
-
+---
+not-date: !!str 2002-04-28
+
diff --git a/src/test/resources/specification/example2_23_picture.yaml b/src/test/resources/specification/example2_23_picture.yaml
index 1229d32..b87063e 100644
--- a/src/test/resources/specification/example2_23_picture.yaml
+++ b/src/test/resources/specification/example2_23_picture.yaml
@@ -1,9 +1,9 @@
----
-picture: !!binary "\
- R0lGODlhDAAMAIQAAP//9/X\
- 17unp5WZmZgAAAOfn515eXv\
- Pz7Y6OjuDg4J+fn5OTk6enp\
- 56enmleECcgggoBADs="
-
-
+---
+picture: !!binary "\
+ R0lGODlhDAAMAIQAAP//9/X\
+ 17unp5WZmZgAAAOfn515eXv\
+ Pz7Y6OjuDg4J+fn5OTk6enp\
+ 56enmleECcgggoBADs="
+
+
\ No newline at end of file
diff --git a/src/test/resources/specification/example2_24.yaml b/src/test/resources/specification/example2_24.yaml
index d97247f..1180757 100644
--- a/src/test/resources/specification/example2_24.yaml
+++ b/src/test/resources/specification/example2_24.yaml
@@ -1,14 +1,14 @@
-%TAG ! tag:clarkevans.com,2002:
---- !shape
- # Use the ! handle for presenting
- # tag:clarkevans.com,2002:circle
-- !circle
- center: &ORIGIN {x: 73, y: 129}
- radius: 7
-- !line
- start: *ORIGIN
- finish: { x: 89, y: 102 }
-- !label
- start: *ORIGIN
- color: 0xFFEEBB
- text: Pretty vector drawing.
+%TAG ! tag:clarkevans.com,2002:
+--- !shape
+ # Use the ! handle for presenting
+ # tag:clarkevans.com,2002:circle
+- !circle
+ center: &ORIGIN {x: 73, y: 129}
+ radius: 7
+- !line
+ start: *ORIGIN
+ finish: { x: 89, y: 102 }
+- !label
+ start: *ORIGIN
+ color: 0xFFEEBB
+ text: Pretty vector drawing.
diff --git a/src/test/resources/specification/example2_24_dumped.yaml b/src/test/resources/specification/example2_24_dumped.yaml
index f7e9766..1742cd2 100644
--- a/src/test/resources/specification/example2_24_dumped.yaml
+++ b/src/test/resources/specification/example2_24_dumped.yaml
@@ -1,11 +1,11 @@
-!shape
-- !circle
- center: &id001 {x: 73, y: 129}
- radius: 7
-- !line
- finish: {x: 89, y: 102}
- start: *id001
-- !label
- color: 0xFFEEBB
- start: *id001
+!shape
+- !circle
+ center: &id001 {x: 73, y: 129}
+ radius: 7
+- !line
+ finish: {x: 89, y: 102}
+ start: *id001
+- !label
+ color: 0xFFEEBB
+ start: *id001
text: Pretty vector drawing.
\ No newline at end of file
diff --git a/src/test/resources/specification/example2_25.yaml b/src/test/resources/specification/example2_25.yaml
index be58da2..769ac31 100644
--- a/src/test/resources/specification/example2_25.yaml
+++ b/src/test/resources/specification/example2_25.yaml
@@ -1,7 +1,7 @@
-# sets are represented as a
-# mapping where each key is
-# associated with the empty string
---- !!set
-? Mark McGwire
-? Sammy Sosa
-? Ken Griff
+# sets are represented as a
+# mapping where each key is
+# associated with the empty string
+--- !!set
+? Mark McGwire
+? Sammy Sosa
+? Ken Griff
diff --git a/src/test/resources/specification/example2_26.yaml b/src/test/resources/specification/example2_26.yaml
index 0a70a64..3143763 100644
--- a/src/test/resources/specification/example2_26.yaml
+++ b/src/test/resources/specification/example2_26.yaml
@@ -1,7 +1,7 @@
-# ordered maps are represented as
-# a sequence of mappings, with
-# each mapping having one key
---- !!omap
-- Mark McGwire: 65
-- Sammy Sosa: 63
-- Ken Griffy: 58
+# ordered maps are represented as
+# a sequence of mappings, with
+# each mapping having one key
+--- !!omap
+- Mark McGwire: 65
+- Sammy Sosa: 63
+- Ken Griffy: 58
diff --git a/src/test/resources/specification/example2_27.yaml b/src/test/resources/specification/example2_27.yaml
index 8eda5e0..395e79c 100644
--- a/src/test/resources/specification/example2_27.yaml
+++ b/src/test/resources/specification/example2_27.yaml
@@ -1,29 +1,29 @@
---- !<tag:clarkevans.com,2002:invoice>
-invoice: 34843
-date : 2001-01-23
-billTo: &id001
- given : Chris
- family : Dumars
- address:
- lines: |
- 458 Walkman Dr.
- Suite #292
- city : Royal Oak
- state : MI
- postal : 48046
-shipTo: *id001
-product:
- - sku : BL394D
- quantity : 4
- description : Basketball
- price : 450.00
- - sku : BL4438H
- quantity : 1
- description : Super Hoop
- price : 2392.00
-tax : 251.42
-total: 4443.52
-comments:
- Late afternoon is best.
- Backup contact is Nancy
- Billsmer @ 338-4338.
+--- !<tag:clarkevans.com,2002:invoice>
+invoice: 34843
+date : 2001-01-23
+billTo: &id001
+ given : Chris
+ family : Dumars
+ address:
+ lines: |
+ 458 Walkman Dr.
+ Suite #292
+ city : Royal Oak
+ state : MI
+ postal : 48046
+shipTo: *id001
+product:
+ - sku : BL394D
+ quantity : 4
+ description : Basketball
+ price : 450.00
+ - sku : BL4438H
+ quantity : 1
+ description : Super Hoop
+ price : 2392.00
+tax : 251.42
+total: 4443.52
+comments:
+ Late afternoon is best.
+ Backup contact is Nancy
+ Billsmer @ 338-4338.
diff --git a/src/test/resources/specification/example2_27_dumped.yaml b/src/test/resources/specification/example2_27_dumped.yaml
index 5a36138..51a89b8 100644
--- a/src/test/resources/specification/example2_27_dumped.yaml
+++ b/src/test/resources/specification/example2_27_dumped.yaml
@@ -1,20 +1,20 @@
-!!org.yaml.snakeyaml.Invoice
-billTo: &id001
- address:
- city: Royal Oak
- lines: |
- 458 Walkman Dr.
- Suite #292
- postal: '48046'
- state: MI
- family: Dumars
- given: Chris
-comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
-date: '2001-01-23'
-invoice: 34843
-product:
-- {description: Basketball, price: 450.0, quantity: 4, sku: BL394D}
-- {description: Super Hoop, price: 2392.0, quantity: 1, sku: BL4438H}
-shipTo: *id001
-tax: 251.42
+!!org.yaml.snakeyaml.Invoice
+billTo: &id001
+ address:
+ city: Royal Oak
+ lines: |
+ 458 Walkman Dr.
+ Suite #292
+ postal: '48046'
+ state: MI
+ family: Dumars
+ given: Chris
+comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.
+date: '2001-01-23'
+invoice: 34843
+product:
+- {description: Basketball, price: 450.0, quantity: 4, sku: BL394D}
+- {description: Super Hoop, price: 2392.0, quantity: 1, sku: BL4438H}
+shipTo: *id001
+tax: 251.42
total: 4443.52
\ No newline at end of file
diff --git a/src/test/resources/specification/example2_28.yaml b/src/test/resources/specification/example2_28.yaml
index 5880ac3..eb5fb8a 100644
--- a/src/test/resources/specification/example2_28.yaml
+++ b/src/test/resources/specification/example2_28.yaml
@@ -1,29 +1,29 @@
----
-Time: 2001-11-23 15:01:42 -5
-User: ed
-Warning:
- This is an error message
- for the log file
----
-Time: 2001-11-23 15:02:31 -5
-User: ed
-Warning:
- A slightly different error
- message.
----
-Date: 2001-11-23 15:03:17 -5
-User: ed
-Fatal:
- Unknown variable "bar"
-Stack:
- - file: TopClass.py
- line: 23
- code: |
- x = MoreObject("345\n")
- - file: MoreClass.py
- line: 58
- code: |-
- foo = bar
-
-
-
+---
+Time: 2001-11-23 15:01:42 -5
+User: ed
+Warning:
+ This is an error message
+ for the log file
+---
+Time: 2001-11-23 15:02:31 -5
+User: ed
+Warning:
+ A slightly different error
+ message.
+---
+Date: 2001-11-23 15:03:17 -5
+User: ed
+Fatal:
+ Unknown variable "bar"
+Stack:
+ - file: TopClass.py
+ line: 23
+ code: |
+ x = MoreObject("345\n")
+ - file: MoreClass.py
+ line: 58
+ code: |-
+ foo = bar
+
+
+
diff --git a/src/test/resources/specification/example2_3.yaml b/src/test/resources/specification/example2_3.yaml
index e0429fa..2c884b7 100644
--- a/src/test/resources/specification/example2_3.yaml
+++ b/src/test/resources/specification/example2_3.yaml
@@ -1,8 +1,8 @@
-american:
- - Boston Red Sox
- - Detroit Tigers
- - New York Yankees
-national:
- - New York Mets
- - Chicago Cubs
+american:
+ - Boston Red Sox
+ - Detroit Tigers
+ - New York Yankees
+national:
+ - New York Mets
+ - Chicago Cubs
- Atlanta Braves
\ No newline at end of file
diff --git a/src/test/resources/specification/example2_4.yaml b/src/test/resources/specification/example2_4.yaml
index 9bfb6cc..430f6b3 100644
--- a/src/test/resources/specification/example2_4.yaml
+++ b/src/test/resources/specification/example2_4.yaml
@@ -1,8 +1,8 @@
--
- name: Mark McGwire
- hr: 65
- avg: 0.278
--
- name: Sammy Sosa
- hr: 63
- avg: 0.288
+-
+ name: Mark McGwire
+ hr: 65
+ avg: 0.278
+-
+ name: Sammy Sosa
+ hr: 63
+ avg: 0.288
diff --git a/src/test/resources/specification/example2_5.yaml b/src/test/resources/specification/example2_5.yaml
index 260ce2d..cdd7770 100644
--- a/src/test/resources/specification/example2_5.yaml
+++ b/src/test/resources/specification/example2_5.yaml
@@ -1,3 +1,3 @@
-- [name , hr, avg ]
-- [Mark McGwire, 65, 0.278]
-- [Sammy Sosa , 63, 0.288]
+- [name , hr, avg ]
+- [Mark McGwire, 65, 0.278]
+- [Sammy Sosa , 63, 0.288]
diff --git a/src/test/resources/specification/example2_6.yaml b/src/test/resources/specification/example2_6.yaml
index f1a3c1e..7a957b2 100644
--- a/src/test/resources/specification/example2_6.yaml
+++ b/src/test/resources/specification/example2_6.yaml
@@ -1,5 +1,5 @@
-Mark McGwire: {hr: 65, avg: 0.278}
-Sammy Sosa: {
- hr: 63,
- avg: 0.288
- }
+Mark McGwire: {hr: 65, avg: 0.278}
+Sammy Sosa: {
+ hr: 63,
+ avg: 0.288
+ }
diff --git a/src/test/resources/specification/example2_7.yaml b/src/test/resources/specification/example2_7.yaml
index 1ea2148..bc711d5 100644
--- a/src/test/resources/specification/example2_7.yaml
+++ b/src/test/resources/specification/example2_7.yaml
@@ -1,10 +1,10 @@
-# Ranking of 1998 home runs
----
-- Mark McGwire
-- Sammy Sosa
-- Ken Griffey
-
-# Team ranking
----
-- Chicago Cubs
-- St Louis Cardinals
+# Ranking of 1998 home runs
+---
+- Mark McGwire
+- Sammy Sosa
+- Ken Griffey
+
+# Team ranking
+---
+- Chicago Cubs
+- St Louis Cardinals
diff --git a/src/test/resources/specification/example2_8.yaml b/src/test/resources/specification/example2_8.yaml
index 4c286c3..05e102d 100644
--- a/src/test/resources/specification/example2_8.yaml
+++ b/src/test/resources/specification/example2_8.yaml
@@ -1,10 +1,10 @@
----
-time: 20:03:20
-player: Sammy Sosa
-action: strike (miss)
-...
----
-time: 20:03:47
-player: Sammy Sosa
-action: grand slam
-...
+---
+time: 20:03:20
+player: Sammy Sosa
+action: strike (miss)
+...
+---
+time: 20:03:47
+player: Sammy Sosa
+action: grand slam
+...
diff --git a/src/test/resources/specification/example2_9.yaml b/src/test/resources/specification/example2_9.yaml
index 21c2704..e264180 100644
--- a/src/test/resources/specification/example2_9.yaml
+++ b/src/test/resources/specification/example2_9.yaml
@@ -1,8 +1,8 @@
----
-hr: # 1998 hr ranking
- - Mark McGwire
- - Sammy Sosa
-rbi:
- # 1998 rbi ranking
- - Sammy Sosa
- - Ken Griffey
+---
+hr: # 1998 hr ranking
+ - Mark McGwire
+ - Sammy Sosa
+rbi:
+ # 1998 rbi ranking
+ - Sammy Sosa
+ - Ken Griffey
diff --git a/src/test/resources/specification/types/map.yaml b/src/test/resources/specification/types/map.yaml
index 7e57a65..022446d 100644
--- a/src/test/resources/specification/types/map.yaml
+++ b/src/test/resources/specification/types/map.yaml
@@ -1,6 +1,6 @@
-# Unordered set of key: value pairs.
-Block style: !!map
- Clark : Evans
- Brian : Ingerson
- Oren : Ben-Kiki
-Flow style: !!map { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
+# Unordered set of key: value pairs.
+Block style: !!map
+ Clark : Evans
+ Brian : Ingerson
+ Oren : Ben-Kiki
+Flow style: !!map { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
diff --git a/src/test/resources/specification/types/map_mixed_tags.yaml b/src/test/resources/specification/types/map_mixed_tags.yaml
index ba1b5e0..a5d35b0 100644
--- a/src/test/resources/specification/types/map_mixed_tags.yaml
+++ b/src/test/resources/specification/types/map_mixed_tags.yaml
@@ -1,6 +1,6 @@
-# Unordered set of key: value pairs.
-Block style: !<tag:yaml.org,2002:map>
- Clark : Evans
- Brian : Ingerson
- Oren : Ben-Kiki
-Flow style: { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
+# Unordered set of key: value pairs.
+Block style: !<tag:yaml.org,2002:map>
+ Clark : Evans
+ Brian : Ingerson
+ Oren : Ben-Kiki
+Flow style: { Clark: Evans, Brian: Ingerson, Oren: Ben-Kiki }
diff --git a/src/test/resources/specification/types/merge.yaml b/src/test/resources/specification/types/merge.yaml
index 00f189a..ee4a48f 100644
--- a/src/test/resources/specification/types/merge.yaml
+++ b/src/test/resources/specification/types/merge.yaml
@@ -1,27 +1,27 @@
----
-- &CENTER { x: 1, y: 2 }
-- &LEFT { x: 0, y: 2 }
-- &BIG { r: 10 }
-- &SMALL { r: 1 }
-
-# All the following maps are equal:
-
-- # Explicit keys
- x: 1
- y: 2
- r: 10
- label: center/big
-
-- # Merge one map
- << : *CENTER
- r: 10
- label: center/big
-
-- # Merge multiple maps
- << : [ *CENTER, *BIG ]
- label: center/big
-
-- # Override
- << : [ *BIG, *LEFT, *SMALL ]
- x: 1
- label: center/big
+---
+- &CENTER { x: 1, y: 2 }
+- &LEFT { x: 0, y: 2 }
+- &BIG { r: 10 }
+- &SMALL { r: 1 }
+
+# All the following maps are equal:
+
+- # Explicit keys
+ x: 1
+ y: 2
+ r: 10
+ label: center/big
+
+- # Merge one map
+ << : *CENTER
+ r: 10
+ label: center/big
+
+- # Merge multiple maps
+ << : [ *CENTER, *BIG ]
+ label: center/big
+
+- # Override
+ << : [ *BIG, *LEFT, *SMALL ]
+ x: 1
+ label: center/big
diff --git a/src/test/resources/specification/types/omap.yaml b/src/test/resources/specification/types/omap.yaml
index 5e0a812..4fa0f45 100644
--- a/src/test/resources/specification/types/omap.yaml
+++ b/src/test/resources/specification/types/omap.yaml
@@ -1,8 +1,8 @@
-# Explicitly typed ordered map (dictionary).
-Bestiary: !!omap
- - aardvark: African pig-like ant eater. Ugly.
- - anteater: South-American ant eater. Two species.
- - anaconda: South-American constrictor snake. Scaly.
- # Etc.
-# Flow style
-Numbers: !!omap [ one: 1, two: 2, three : 3 ]
+# Explicitly typed ordered map (dictionary).
+Bestiary: !!omap
+ - aardvark: African pig-like ant eater. Ugly.
+ - anteater: South-American ant eater. Two species.
+ - anaconda: South-American constrictor snake. Scaly.
+ # Etc.
+# Flow style
+Numbers: !!omap [ one: 1, two: 2, three : 3 ]
diff --git a/src/test/resources/specification/types/pairs.yaml b/src/test/resources/specification/types/pairs.yaml
index 34acf77..05f55b9 100644
--- a/src/test/resources/specification/types/pairs.yaml
+++ b/src/test/resources/specification/types/pairs.yaml
@@ -1,7 +1,7 @@
-# Explicitly typed pairs.
-Block tasks: !!pairs
- - meeting: with team.
- - meeting: with boss.
- - break: lunch.
- - meeting: with client.
-Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
+# Explicitly typed pairs.
+Block tasks: !!pairs
+ - meeting: with team.
+ - meeting: with boss.
+ - break: lunch.
+ - meeting: with client.
+Flow tasks: !!pairs [ meeting: with team, meeting: with boss ]
diff --git a/src/test/resources/specification/types/seq.yaml b/src/test/resources/specification/types/seq.yaml
index dd690e2..5849115 100644
--- a/src/test/resources/specification/types/seq.yaml
+++ b/src/test/resources/specification/types/seq.yaml
@@ -1,14 +1,14 @@
-# Ordered sequence of nodes
-Block style: !!seq
-- Mercury # Rotates - no light/dark sides.
-- Venus # Deadliest. Aptly named.
-- Earth # Mostly dirt.
-- Mars # Seems empty.
-- Jupiter # The king.
-- Saturn # Pretty.
-- Uranus # Where the sun hardly shines.
-- Neptune # Boring. No rings.
-- Pluto # You call this a planet?
-Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks
- Jupiter, Saturn, Uranus, Neptune, # Gas
- Pluto ] # Overrated
+# Ordered sequence of nodes
+Block style: !!seq
+- Mercury # Rotates - no light/dark sides.
+- Venus # Deadliest. Aptly named.
+- Earth # Mostly dirt.
+- Mars # Seems empty.
+- Jupiter # The king.
+- Saturn # Pretty.
+- Uranus # Where the sun hardly shines.
+- Neptune # Boring. No rings.
+- Pluto # You call this a planet?
+Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks
+ Jupiter, Saturn, Uranus, Neptune, # Gas
+ Pluto ] # Overrated
diff --git a/src/test/resources/specification/types/set.yaml b/src/test/resources/specification/types/set.yaml
index 19406eb..e05dc88 100644
--- a/src/test/resources/specification/types/set.yaml
+++ b/src/test/resources/specification/types/set.yaml
@@ -1,7 +1,7 @@
-# Explicitly typed set.
-baseball players: !!set
- ? Mark McGwire
- ? Sammy Sosa
- ? Ken Griffey
-# Flow style
-baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees }
+# Explicitly typed set.
+baseball players: !!set
+ ? Mark McGwire
+ ? Sammy Sosa
+ ? Ken Griffey
+# Flow style
+baseball teams: !!set { Boston Red Sox, Detroit Tigers, New York Yankees }
diff --git a/src/test/resources/specification/types/v.yaml b/src/test/resources/specification/types/v.yaml
index 0fdc8fb..81c5d51 100644
--- a/src/test/resources/specification/types/v.yaml
+++ b/src/test/resources/specification/types/v.yaml
@@ -1,4 +1,4 @@
---- # New schema
-link with:
- - = : library1.dll
- version: 1.2
+--- # New schema
+link with:
+ - = : library1.dll
+ version: 1.2
diff --git a/src/test/resources/specification/types/value.yaml b/src/test/resources/specification/types/value.yaml
index 8f83a6e..3eb7919 100644
--- a/src/test/resources/specification/types/value.yaml
+++ b/src/test/resources/specification/types/value.yaml
@@ -1,10 +1,10 @@
---- # Old schema
-link with:
- - library1.dll
- - library2.dll
---- # New schema
-link with:
- - = : library1.dll
- version: 1.2
- - = : library2.dll
- version: 2.3
+--- # Old schema
+link with:
+ - library1.dll
+ - library2.dll
+--- # New schema
+link with:
+ - = : library1.dll
+ version: 1.2
+ - = : library2.dll
+ version: 2.3
diff --git a/src/test/resources/template/etalon1.yaml b/src/test/resources/template/etalon1.yaml
index b67b569..21e45a9 100644
--- a/src/test/resources/template/etalon1.yaml
+++ b/src/test/resources/template/etalon1.yaml
@@ -1,9 +1,9 @@
-empty: []
-id: id123
-list:
-- aaa
-- bbb
-- ccc
-point:
- x: 1.0
+empty: []
+id: id123
+list:
+- aaa
+- bbb
+- ccc
+point:
+ x: 1.0
y: 2.0
\ No newline at end of file
diff --git a/src/test/resources/template/etalon2-template.yaml b/src/test/resources/template/etalon2-template.yaml
index 450510b..979892f 100644
--- a/src/test/resources/template/etalon2-template.yaml
+++ b/src/test/resources/template/etalon2-template.yaml
@@ -1,9 +1,9 @@
-%YAML 1.1
----
-#Welcome to my Beans !!!
-id: id123 # the ID must be first
-point: [1.0, 2.0]
-#collection are at the end
-list: [aaa, bbb, ccc]
-
-#empty collection is not emitted
+%YAML 1.1
+---
+#Welcome to my Beans !!!
+id: id123 # the ID must be first
+point: [1.0, 2.0]
+#collection are at the end
+list: [aaa, bbb, ccc]
+
+#empty collection is not emitted