pax_global_header00006660000000000000000000000064145647305320014523gustar00rootroot0000000000000052 comment=86dc80d897cf85a0b8238c5d46ce723d9afa6535 java.data-1.2.107/000077500000000000000000000000001456473053200135245ustar00rootroot00000000000000java.data-1.2.107/.gitattributes000066400000000000000000000000401456473053200164110ustar00rootroot00000000000000epl.html linguist-vendored=true java.data-1.2.107/.github/000077500000000000000000000000001456473053200150645ustar00rootroot00000000000000java.data-1.2.107/.github/PULL_REQUEST_TEMPLATE000066400000000000000000000013011456473053200202610ustar00rootroot00000000000000Hi! Thanks for your interest in contributing to this project. Clojure contrib projects do not use GitHub issues or pull requests, and require a signed Contributor Agreement. If you would like to contribute, please read more about the CA and sign that first (this can be done online). Then go to this project's issue tracker in JIRA to create tickets, update tickets, or submit patches. For help in creating tickets and patches, please see: - Signing the CA: https://clojure.org/community/contributing - Creating Tickets: https://clojure.org/community/creating_tickets - Developing Patches: https://clojure.org/community/developing_patches - Contributing FAQ: https://clojure.org/community/contributing java.data-1.2.107/.github/workflows/000077500000000000000000000000001456473053200171215ustar00rootroot00000000000000java.data-1.2.107/.github/workflows/doc-build.yml000066400000000000000000000002761456473053200215130ustar00rootroot00000000000000name: Build API Docs on: workflow_dispatch: jobs: call-doc-build-workflow: uses: clojure/build.ci/.github/workflows/doc-build.yml@master with: project: clojure/java.data java.data-1.2.107/.github/workflows/release.yml000066400000000000000000000007601456473053200212670ustar00rootroot00000000000000name: Release on demand on: workflow_dispatch: inputs: releaseVersion: description: "Version to release" required: true snapshotVersion: description: "Snapshot version after release" required: true jobs: call-release: uses: clojure/build.ci/.github/workflows/release.yml@master with: releaseVersion: ${{ github.event.inputs.releaseVersion }} snapshotVersion: ${{ github.event.inputs.snapshotVersion }} secrets: inheritjava.data-1.2.107/.github/workflows/snapshot.yml000066400000000000000000000002401456473053200214770ustar00rootroot00000000000000name: Snapshot on demand on: [workflow_dispatch] jobs: call-snapshot: uses: clojure/build.ci/.github/workflows/snapshot.yml@master secrets: inherit java.data-1.2.107/.github/workflows/test.yml000066400000000000000000000001501456473053200206170ustar00rootroot00000000000000name: Test on: [push] jobs: call-test: uses: clojure/build.ci/.github/workflows/test.yml@master java.data-1.2.107/.gitignore000066400000000000000000000002111456473053200155060ustar00rootroot00000000000000.calva/output-window .classpath .clj-kondo/.cache .cpcache/ .lsp/.cache .nrepl-port .portal .project .settings .socket-repl-port /target java.data-1.2.107/CHANGELOG.md000066400000000000000000000046241456473053200153430ustar00rootroot00000000000000## Change Log * Release 1.1.103 on 2023-12-16 * IMPORTANT: `org.clojure/tools.logging` is no longer a dependency. If you currently bind `*to-java-object-missing-setter*` to `:log` and you do not otherwise have a dependency on `org.clojure/tools.logging` you will need to add that to your project's direct dependencies. * Release 1.0.95 on 2021-12-12 * Update `org.clojure/tools.logging` to `1.2.1`. * Release 1.0.92 on 2021-10-16 * Support `to-java` for `java.util.Properties` and a hash map JDATA-22. * Release 1.0.86 on 2020-07-17 * Add `from-java-deep` to guarantee deep conversion with same options as `from-java-shallow` [JDATA-21](https://clojure.atlassian.net/browse/JDATA-21). * Fixes bug in `from-java-shallow` for getters returning `Boolean` (the value was not canonicalized so `false` could be truthy). * Release 1.0.78 on 2020-05-31 * Make exception handling in shallow conversions configurable: an `:exceptions` option may be `:group`, `:omit`, `:quaify`, or `:return`. * Fix bug in shallow array handling. * Release 1.0.73 on 2020-05-31 * Add `from-java-shallow` to provide functionality similar to `clojure.core/bean` (a shallow conversion) but with options to control behavior (so "dangerous" methods that appear as getters can be omitted). * Bump `org.clojure/tools.logging` to `1.1.0`. * Move change log to a separate file. * Improve documentation around property naming and how it corresponds to setter function names. * Release 1.0.64 on 2020-02-18 * Switch to 1.0.x versioning. * Bump `org.clojure/tools.logging` to `0.6.0`. * Add basic tests for the builder [JDATA-20](https://clojure.atlassian.net/browse/JDATA-20). * Release 0.2.0 on 2020-01-02 * Add `clojure.java.data.builder/to-java` to construct Java objects from builders using hash maps of properties JDATA-18. * Release 0.1.5 on 2019-12-20 * Add `set-properties` to populate an existing object JDATA-15. * Add `:clojure.java.data/constructor` metadata support JDATA-16. * Release 0.1.4 on 2019-10-13 * Fix Clojure hash map conversion problems JDATA-14 (problems introduced in 0.1.3) * Release 0.1.3 on 2019-10-13 * Fix `java.util.Map`/Clojure hash map setter handling JDATA-6. * Fix `Boolean` conversion JDATA-10. * Fix `SQLException` handling JDATA-12. * Release 0.1.2 on 2019-10-12 * Fix reflection warnings JDATA-2 and JDATA-13. * Release 0.1.1 on 2012-04-29 * Initial release. * Clojure 1.2 compatibility. java.data-1.2.107/CONTRIBUTING.md000066400000000000000000000007371456473053200157640ustar00rootroot00000000000000This is a [Clojure contrib] project. Under the Clojure contrib [guidelines], this project cannot accept pull requests. All patches must be submitted via [JIRA]. See [Contributing] on the Clojure website for more information on how to contribute. [Clojure contrib]: https://clojure.org/community/contrib_libs [Contributing]: https://clojure.org/community/contributing [JIRA]: https://clojure.atlassian.net/browse/JDATA [guidelines]: https://clojure.org/community/contrib_howto java.data-1.2.107/LICENSE000066400000000000000000000263741456473053200145450ustar00rootroot00000000000000Eclipse Public License - v 1.0 THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 1. DEFINITIONS "Contribution" means: a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and b) in the case of each subsequent Contributor: i) changes to the Program, and ii) additions to the Program; where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. "Contributor" means any person or entity that distributes the Program. "Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. "Program" means the Contributions distributed in accordance with this Agreement. "Recipient" means anyone who receives the Program under this Agreement, including all Contributors. 2. GRANT OF RIGHTS a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. 3. REQUIREMENTS A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: a) it complies with the terms and conditions of this Agreement; and b) its license agreement: i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. When the Program is made available in source code form: a) it must be made available under this Agreement; and b) a copy of this Agreement must be included with each copy of the Program. Contributors may not remove or alter any copyright notices contained within the Program. Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. 4. COMMERCIAL DISTRIBUTION Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. 5. NO WARRANTY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. 6. DISCLAIMER OF LIABILITY EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 7. GENERAL If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. java.data-1.2.107/README.md000066400000000000000000000153431456473053200150110ustar00rootroot00000000000000# java.data Functions for recursively converting Java beans to Clojure and vice versa. Future home of Java beans and properties support from the old clojure-contrib ## Releases and Dependency Information This project follows the version scheme MAJOR.MINOR.COMMITS where MAJOR and MINOR provide some relative indication of the size of the change, but do not follow semantic versioning. In general, all changes endeavor to be non-breaking (by moving to new names rather than by breaking existing names). COMMITS is an ever-increasing counter of commits since the beginning of this repository. Latest stable release: 1.1.103 * [All Released Versions](https://search.maven.org/#search%7Cga%7C1%7Corg.clojure%20java.data) * [Development Snapshot Versions](https://repository.sonatype.org/index.html#nexus-search;gav~org.clojure~java.data~~~) ### [CLI/`deps.edn`](https://clojure.org/reference/deps_and_cli) dependency information: ```clojure org.clojure/java.data {:mvn/version "1.1.103"} ``` ### Leiningen ```clojure [org.clojure/java.data "1.1.103"] ``` ### Maven ```xml org.clojure java.data 1.1.103 ``` ## Example Usage ```clojure (require '[clojure.java.data :as j]) ;; construct YourJavaClass instance from Clojure data structure ;; (usually a Clojure hash map of properties to set on the instance): (j/to-java YourJavaClass clojure-property-map) ;; the 0-arity constructor is called to construct the instance ;; and then the properties are added by calling setters ;; note that keys in the property map must follow the :camelCase ;; naming of the Java fields to which they correspond, so that ;; the appropriate setter methods can be invoked, e.g., (j/to-java SomeJavaClass {:stuff 42 :moreStuff "13"}) ;; this is equivalent to: (let [obj (SomeJavaClass.)] (.setStuff obj 42) (.setMoreStuff obj "13")) ;; represent a javaValue instance in a Clojure data structure: (j/from-java javaValue) ;; populate javaValue instance from a Clojure property hash map ;; (calls a setter for each key/value pair in the hash map): (j/set-properties javaValue clojure-property-map) ;; provide constructor arguments via metadata: (j/to-java YourJavaClass (with-meta clojure-property-map {::j/constructor ["constructor" "arguments"]})) ;; constructor arguments must match the parameter types ;; so you may need type hints and coercions on them ``` Representing an instance of `YourJavaClass` in a Clojure data structure ```clojure (defmethod j/from-java YourJavaClass [instance] ; your custom logic for turning this instance into a clojure data structure ) ``` Constructing an instance of `YourJavaClass` from a Clojure data structure ```clojure (defmethod j/to-java [YourJavaClass clojure.lang.APersistentMap] [clazz props] ; your custom logic for constructing an instance from a property map ) ``` ### Usage with Builder Classes As of 0.2.0, `java.data` adds a new namespace and a new `to-java` function that supports the Builder Pattern. Instead of just creating an instance of the specified class and then setting properties on it, this variant works with an associated "builder" class (or instance), setting properties on it, and then producing an instance of the specified class from it. In Java, that typically looks like: ```java MyClass foo = new MyClass.Builder() .fooBar( 42 ) .quux( "stuff" ) .build(); ``` That becomes: ```clojure (require '[clojure.java.data.builder :as builder]) (def foo (builder/to-java MyClass {:fooBar 42 :quux "stuff"})) ``` By default, this assumes `MyClass` has a nested class called `Builder`, and the property methods could be `.fooBar`, `.setFooBar`, or `.withFooBar` (and `.quux`, `.setQuux`, or `.withQuux`), and then a `.build` method that produces the `MyClass` object. You can also specify an options hash map containing any of the following: * `:builder-class` -- the class that should be used for the builder process; by default it will assume an inner class of `clazz` called `Builder`, * `:builder-props` -- properties used to construct and initialize an instance of the builder class; defaults to an empty hash map; may have `:clojure.java.data/constructor` as metadata to provide constructor arguments for the builder instance, * `:build-fn` -- the name of the method in the `Builder` class to use to complete the builder process and return the desired class; by default it will try to deduce it, preferring `build` if we find multiple candidates, * `:ignore-setters?` -- a flag to indicate that methods on the builder class that begin with `set` should be ignored, which may be necessary to avoid ambiguous methods that look like builder properties; by default `setFooBar` and `withQuuxIt` will be treated as builder properties `fooBar` and `quuxIt` if they accept a single argument and return a builder instance. Additional arities allow you to specify a builder instance, for cases where the builder is not simply constructed from a (nested) class, and both a builder class and a builder instance for more complex cases: ```clojure ;; requires the options hash map, even if it is empty: (builder/to-java MyClass (MyClass/builder) {:bar 42 :quux "stuff"} {}) ;; for cases where the type of the builder instance differs from the actual ;; builder class that should be used for property method return types: (builder/to-java MyClass MyClassBuilder (MyClass/builder) {:bar 42 :quux "stuff"} {}) ``` ## Feature comparison to `clojure.core/bean` Clojure core provides a `bean` function which has some overlap with java.data. Below is a more detailed comparison: Dimension | `bean` | `java.data` -- | ------ | ----------- find fields | bean introspector | bean introspector - "class" depth | 1 | recursive without cycle detection field names | keyword | keyword extensibility | none | multimethod on class special casing | none | arrays, iterable, maps, enums, Instant, SQLException, XMLGregorianCalendar map keys | unhandled | untouched exception defense | none | none ## Developer Information * [GitHub project](https://github.com/clojure/java.data) * [Bug Tracker](https://clojure.atlassian.net/browse/JDATA) * [Continuous Integration](https://github.com/clojure/java.data/actions/workflows/test.yml) ## Copyright and License Copyright (c) Rich Hickey and contributors. All rights reserved. The use and distribution terms for this software are covered by the [Eclipse Public License 1.0](https://opensource.org/license/epl-1-0/) which can be found in the file epl.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software. java.data-1.2.107/deps.edn000066400000000000000000000000361456473053200151460ustar00rootroot00000000000000{:paths ["src/main/clojure"]} java.data-1.2.107/epl.html000066400000000000000000000305361456473053200152010ustar00rootroot00000000000000 Eclipse Public License - Version 1.0

Eclipse Public License - v 1.0

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

1. DEFINITIONS

"Contribution" means:

a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and

b) in the case of each subsequent Contributor:

i) changes to the Program, and

ii) additions to the Program;

where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program.

"Contributor" means any person or entity that distributes the Program.

"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program.

"Program" means the Contributions distributed in accordance with this Agreement.

"Recipient" means anyone who receives the Program under this Agreement, including all Contributors.

2. GRANT OF RIGHTS

a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form.

b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder.

c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program.

d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement.

3. REQUIREMENTS

A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that:

a) it complies with the terms and conditions of this Agreement; and

b) its license agreement:

i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose;

ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits;

iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and

iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange.

When the Program is made available in source code form:

a) it must be made available under this Agreement; and

b) a copy of this Agreement must be included with each copy of the Program.

Contributors may not remove or alter any copyright notices contained within the Program.

Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution.

4. COMMERCIAL DISTRIBUTION

Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense.

For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages.

5. NO WARRANTY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED 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. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations.

6. DISCLAIMER OF LIABILITY

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

7. GENERAL

If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.

If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed.

All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive.

Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved.

This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation.

java.data-1.2.107/pom.xml000066400000000000000000000024331456473053200150430ustar00rootroot00000000000000 4.0.0 java.data 1.2.107 java.data https://github.com/clojure/java.data/ Utilities for working with Java beans from Clojure org.clojure pom.contrib 1.2.0 Cosmin Stejerean Sean Corfield scm:git:git@github.com:clojure/java.data.git scm:git:git@github.com:clojure/java.data.git git@github.com:clojure/java.data.git v1.2.107 org.clojure tools.logging 1.3.0 test java.data-1.2.107/src/000077500000000000000000000000001456473053200143135ustar00rootroot00000000000000java.data-1.2.107/src/main/000077500000000000000000000000001456473053200152375ustar00rootroot00000000000000java.data-1.2.107/src/main/clojure/000077500000000000000000000000001456473053200167025ustar00rootroot00000000000000java.data-1.2.107/src/main/clojure/clojure/000077500000000000000000000000001456473053200203455ustar00rootroot00000000000000java.data-1.2.107/src/main/clojure/clojure/java/000077500000000000000000000000001456473053200212665ustar00rootroot00000000000000java.data-1.2.107/src/main/clojure/clojure/java/data.clj000066400000000000000000000533421456473053200227000ustar00rootroot00000000000000;; Copyright (c) Cosmin Stejerean, Sean Corfield. All rights reserved. ;; The use and distribution terms for this software are covered by the ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) ;; which can be found in the file epl-v10.html at the root of this ;; distribution. By using this software in any fashion, you are agreeing to ;; be bound by the terms of this license. You must not remove this notice, ;; or any other, from this software. (ns ^{:author "Cosmin Stejerean, Sean Corfield", :doc "Support for recursively converting Java beans to Clojure and vice versa."} clojure.java.data (:require [clojure.string :as str])) (set! *warn-on-reflection* true) (def ^:dynamic *to-java-object-missing-setter* "Specify the behavior of missing setters in to-java in the default object case, using one of :ignore, :log, :error The default (:ignore) is to ignore missing setters. * :log uses clojure.tools.logging/info to log a message. * :error throws a NoSuchFieldException. If you bind this to :log, you must have org.clojure/tools.logging as a dependency in your project. Otherwise, :log will behave like :error and throw a NoSuchFieldException." :ignore) (defmulti to-java "Convert Clojure data to an instance of the specified Java class. Several basic types have obvious conversions, but for a hash map reflection is used to set the properties. If the class is an interface, we can't create an instance of it, unless the Clojure map already implements it. When java.time.Instant is available (Java 8+), we can convert a hash map containing :nano and :epochSecond to Instant, as this is the reverse of Instant->map. A XMLGregorianCalendar object can be constructed from the following keys :year, :month, :day, :hour, :minute, :second, and :timezone." (fn [destination-type value] [destination-type (class value)])) (defmulti from-java "Convert a Java object to a Clojure map." class) (defmulti from-java-deep "Convert a Java object to a Clojure map (converting deeply). The second argument is a hash map that offers some control over the conversion: * :add-class -- if true, add :class with the actual class of the object being converted -- this mimics clojure.core/bean. * :exceptions -- controls how getter exceptions should be handled: * :group -- return an :exceptions hash map in the object that contains all the properties that failed, with their exceptions, * :omit -- ignore exceptions and omit the properties that caused them, * :qualify -- return the exception as :/exception and omit the property itself, * :return -- simply return the exception as the value of the property. * :omit -- a set of properties (keywords) to omit from the conversion so that unsafe methods are not called (this applies across the whole recursive/deep conversion)." (fn [obj _] (class obj))) (defmulti from-java-shallow "Convert a Java object to a Clojure map (but do not convert deeply). The second argument is a hash map that offers some control over the conversion: * :add-class -- if true, add :class with the actual class of the object being converted -- this mimics clojure.core/bean. * :exceptions -- controls how getter exceptions should be handled: * :group -- return an :exceptions hash map in the object that contains all the properties that failed, with their exceptions, * :omit -- ignore exceptions and omit the properties that caused them, * :qualify -- return the exception as :/exception and omit the property itself, * :return -- simply return the exception as the value of the property. * :omit -- a set of properties (keywords) to omit from the conversion so that unsafe methods are not called." (fn [obj _] (class obj))) (defn- get-property-descriptors [clazz] (.getPropertyDescriptors (java.beans.Introspector/getBeanInfo clazz))) (comment (mapv bean (.getPropertyDescriptors (java.beans.Introspector/getBeanInfo java.sql.Statement)))) ;; getters (defn- is-getter [^java.lang.reflect.Method method] (and method (= 0 (alength ^"[Ljava.lang.Class;" (.getParameterTypes method))))) (defn- make-getter-fn [^java.lang.reflect.Method method] (fn [instance] (from-java (.invoke method instance nil)))) (defn- make-deep-getter-fn [^java.lang.reflect.Method method opts] (fn [instance] (from-java-deep (.invoke method instance nil) opts))) (defn- make-shallow-getter-fn [^java.lang.reflect.Method method] (fn [instance] (let [r (.invoke method instance nil)] (if (instance? Boolean r) (boolean r) r)))) (defn- add-getter-fn [the-map ^java.beans.PropertyDescriptor prop-descriptor] (let [name (.getName prop-descriptor) method (.getReadMethod prop-descriptor)] (if (and (is-getter method) (not (= "class" name))) (assoc the-map (keyword name) (make-getter-fn method)) the-map))) (defn- add-deep-getter-fn [the-map ^java.beans.PropertyDescriptor prop-descriptor opts] (let [name (.getName prop-descriptor) method (.getReadMethod prop-descriptor)] (if (and (is-getter method) (not (= "class" name))) (assoc the-map (keyword name) (make-deep-getter-fn method opts)) the-map))) (defn- add-shallow-getter-fn [the-map ^java.beans.PropertyDescriptor prop-descriptor] (let [name (.getName prop-descriptor) method (.getReadMethod prop-descriptor)] (if (and (is-getter method) (not (= "class" name))) (assoc the-map (keyword name) (make-shallow-getter-fn method)) the-map))) ;; setters (defn- is-setter [^java.lang.reflect.Method method] (and method (= 1 (alength (. method (getParameterTypes)))))) (defn- get-setter-type [^java.lang.reflect.Method method] (get (.getParameterTypes method) 0)) (defn- make-setter-fn [^java.lang.reflect.Method method] (fn [instance value] (.invoke method instance (into-array [(to-java (get-setter-type method) value)])))) (defn- add-setter-fn [the-map ^java.beans.PropertyDescriptor prop-descriptor] (let [name (.getName prop-descriptor) method (.getWriteMethod prop-descriptor)] (if (is-setter method) (assoc the-map (keyword name) (make-setter-fn method)) the-map))) (defn- add-array-methods [^Class acls] (let [cls (.getComponentType acls) to (fn [_ sequence] (into-array cls (map (partial to-java cls) sequence))) from (fn [obj] (map from-java obj)) from-deep (fn [obj opts] (map #(from-java-deep % opts) obj)) from-shallow (fn [obj opts] (map #(from-java-shallow % opts) obj))] (.addMethod ^clojure.lang.MultiFn to-java [acls Iterable] to) (.addMethod ^clojure.lang.MultiFn from-java acls from) (.addMethod ^clojure.lang.MultiFn from-java-deep acls from-deep) (.addMethod ^clojure.lang.MultiFn from-java-shallow acls from-shallow) {:to to :from from :from-deep from-deep :from-shallow from-shallow})) ;; constructor support (defn- find-matching-constructors [^Class clazz args] (let [n (count args)] (filter (fn [^java.lang.reflect.Constructor ctr] (and (= n (.getParameterCount ctr)) (let [pts (map vector (.getParameterTypes ctr) args)] (every? (fn [[^Class pt arg]] ;; watch out for boxed types in Clojure ;; passed to primitive constructor parameters (cond (.isPrimitive pt) (and arg ; cannot pass nil to primitive (or (instance? Number arg) (instance? Boolean arg))) (nil? arg) true ; null is assignable to any non-primitive :else (.isAssignableFrom pt (class arg)))) pts)))) (.getConstructors clazz)))) (defn- find-constructor ^java.lang.reflect.Constructor [^Class clazz args] (let [candidates (find-matching-constructors clazz args)] (condp = (count candidates) 0 (throw (IllegalArgumentException. (str (.getName clazz) " has no matching constructor" " for the given argument list"))) 1 (first candidates) (throw (IllegalArgumentException. (str (.getName clazz) " constructor is ambiguous" " for the given argument list")))))) (comment (find-constructor String ["arg"]) (find-constructor String [(.getBytes "arg")]) (find-constructor String [(.getBytes "arg") (int 0) (int 3)]) (find-constructor String ["too" "many" "arguments"])) ;; common to-java definitions (defmethod to-java :default [^Class cls value] (if (.isArray cls) ;; no method for this array type yet ((:to (add-array-methods cls)) cls value) value)) (defmethod to-java [Enum String] [^Class enum value] (.invoke (.getDeclaredMethod enum "valueOf" (into-array [String])) nil (into-array [value]))) (declare log-or-throw) (defmacro defn-log-or-throw [] (try (require 'clojure.tools.logging) `(defn ~'log-or-throw [message#] (clojure.tools.logging/info message#)) (catch Throwable _ `(defn ~'log-or-throw [message#] (throw (new NoSuchFieldException message#)))))) (defn-log-or-throw) (defn- throw-log-or-ignore-missing-setter [key ^Class clazz] (let [message (str "Missing setter for " key " in " (.getCanonicalName clazz))] (cond (= *to-java-object-missing-setter* :error) (throw (new NoSuchFieldException message)) (= *to-java-object-missing-setter* :log) (log-or-throw message)))) (comment (binding [*to-java-object-missing-setter* :log] (throw-log-or-ignore-missing-setter :foo String)) ) ;; feature testing macro, based on suggestion from Chas Emerick: (defmacro ^{:private true} when-available [sym & body] (try (when (resolve sym) (list* 'do body)) (catch ClassNotFoundException _#))) (defmacro ^{:private true} when-not-available [sym & body] (try (when-not (resolve sym) (list* 'do body)) (catch ClassNotFoundException _#))) ;; Clojure hash map conversions (when-available java.time.Instant (defmethod to-java [java.time.Instant clojure.lang.APersistentMap] [_ props] (when-not (and (:nano props) (:epochSecond props)) (throw (IllegalArgumentException. "java.time.Instant requires :nano and :epochSecond"))) (java.time.Instant/ofEpochSecond (:epochSecond props) (:nano props)))) (defn- set-properties-on "Given an instance, its class, and a hash map of properties, call the appropriate setters and return the populated object. Used by to-java and set-properties below." [instance ^Class clazz props] (let [setter-map (reduce add-setter-fn {} (get-property-descriptors clazz))] (doseq [[key value] props] (let [setter (get setter-map (keyword key))] (if (nil? setter) (throw-log-or-ignore-missing-setter key clazz) (apply setter [instance value])))) instance)) (defmethod to-java [java.util.Properties clojure.lang.APersistentMap] [_ props] (reduce-kv (fn [^java.util.Properties p k v] (if (or (symbol? k) (keyword? k)) (.setProperty p (name k) (str v)) (.setProperty p (str k) (str v))) p) (java.util.Properties.) props)) (defmethod to-java [Object clojure.lang.APersistentMap] [^Class clazz props] (if (.isInterface clazz) (if (instance? clazz props) (condp = clazz ;; make a fresh (mutable) hash map from the Clojure map java.util.Map (java.util.HashMap. ^java.util.Map props) ;; Iterable, Serializable, Runnable, Callable ;; we should probably figure out actual objects to create... props) (throw (IllegalArgumentException. (str (.getName clazz) " is an interface " "and cannot be constructed from " (str/join ", " (map name (keys props))))))) (let [ctr-args (::constructor (meta props)) ctr (when ctr-args (find-constructor clazz ctr-args)) instance (try (if ctr (.newInstance ctr (object-array ctr-args)) (.newInstance clazz)) (catch Throwable t (throw (IllegalArgumentException. (str (.getName clazz) " cannot be constructed") t))))] (set-properties-on instance clazz props)))) (when-available biginteger (defmethod to-java [java.math.BigInteger Object] [_ value] (biginteger value))) (when-not-available biginteger (defmethod to-java [java.math.BigInteger Object] [_ value] (bigint value))) ;; set properties on existing objects (defn set-properties "Given an existing Java object and a Clojure map, use reflection to set the properties." [instance props] (set-properties-on instance (class instance) props)) ;; common from-java definitions (defmethod from-java :default [^Object instance] (let [clazz (.getClass instance)] (if (.isArray clazz) ((:from (add-array-methods clazz)) instance) (let [getter-map (reduce add-getter-fn {} (get-property-descriptors clazz))] (into {} (for [[key getter-fn] (seq getter-map)] [key (getter-fn instance)])))))) (defmethod from-java-deep :default [^Object instance opts] (let [clazz (.getClass instance)] (if (.isArray clazz) ((:from-deep (add-array-methods clazz)) instance opts) (let [getter-map (reduce #(add-deep-getter-fn %1 %2 opts) {} (get-property-descriptors clazz)) exs (atom []) pairs (for [[key getter-fn] (seq getter-map) :when (not (contains? (:omit opts) key)) :let [[k v] (if-let [exh (:exceptions opts)] (try [key (getter-fn instance)] (catch Throwable t (case exh :group (swap! exs conj [key t]) :omit nil :qualify [(keyword (name key) "exception") t] :return [key t]))) [key (getter-fn instance)])] :when k] [k v])] (cond-> {} (:add-class opts) (assoc :class (class instance)) (seq @exs) (assoc :exceptions (into {} @exs)) (seq pairs) (into pairs)))))) (defmethod from-java-shallow :default [^Object instance opts] (let [clazz (.getClass instance)] (if (.isArray clazz) ((:from-shallow (add-array-methods clazz)) instance opts) (let [getter-map (reduce add-shallow-getter-fn {} (get-property-descriptors clazz)) exs (atom []) pairs (for [[key getter-fn] (seq getter-map) :when (not (contains? (:omit opts) key)) :let [[k v] (if-let [exh (:exceptions opts)] (try [key (getter-fn instance)] (catch Throwable t (case exh :group (swap! exs conj [key t]) :omit nil :qualify [(keyword (name key) "exception") t] :return [key t]))) [key (getter-fn instance)])] :when k] [k v])] (cond-> {} (:add-class opts) (assoc :class (class instance)) (seq @exs) (assoc :exceptions (into {} @exs)) (seq pairs) (into pairs)))))) (doseq [clazz [String Character Byte Short Integer Long Float Double java.math.BigInteger java.math.BigDecimal]] (derive clazz ::do-not-convert)) (defmacro ^{:private true} defnumber [box prim prim-getter] `(let [conv# (fn [_# ^Number number#] (~(symbol (str box) "valueOf") (. number# ~prim-getter)))] (.addMethod ^clojure.lang.MultiFn to-java [~prim Number] conv#) (.addMethod ^clojure.lang.MultiFn to-java [~box Number] conv#))) (defmacro ^{:private true} defnumbers [& boxes] (cons `do (for [box boxes :let [^Class box-cls (resolve box) ^Class prim-cls (.get (.getField box-cls "TYPE") box-cls) ;; Clojure 1.3: (assert (class? box-cls) (str box ": no class found")) _ (assert (class? box-cls)) ;; Clojure 1.3: (assert (class? prim-cls) (str box " has no TYPE field")) _ (assert (class? prim-cls)) prim-getter (symbol (str (.getName prim-cls) "Value"))]] `(defnumber ~box ~(symbol (str box) "TYPE") ~prim-getter)))) (defnumbers Byte Short Integer Long Float Double) (defmethod from-java ::do-not-convert [value] value) (prefer-method from-java ::do-not-convert Object) (defmethod from-java-deep ::do-not-convert [value _] value) (prefer-method from-java-deep ::do-not-convert Object) (defmethod from-java-shallow ::do-not-convert [value _] value) (prefer-method from-java-shallow ::do-not-convert Object) (defmethod from-java Iterable [instance] (for [each (seq instance)] (from-java each))) (prefer-method from-java Iterable Object) (defmethod from-java-deep Iterable [instance opts] (for [each (seq instance)] (from-java-deep each opts))) (prefer-method from-java-deep Iterable Object) (defmethod from-java-shallow Iterable [instance opts] (for [each (seq instance)] (from-java-shallow each opts))) (prefer-method from-java-shallow Iterable Object) (defmethod from-java java.util.Map [instance] (into {} instance)) (prefer-method from-java java.util.Map Iterable) (defmethod from-java-deep java.util.Map [instance opts] (reduce (fn [m [k v]] (assoc m (from-java-deep k opts) (from-java-deep v opts))) {} instance)) (prefer-method from-java-deep java.util.Map Iterable) (defmethod from-java-shallow java.util.Map [instance _] (into {} instance)) (prefer-method from-java-shallow java.util.Map Iterable) (defmethod from-java nil [_] nil) (defmethod from-java java.sql.SQLException [^Object ex] ((get-method from-java :default) ex)) (defmethod from-java Boolean [value] (boolean value)) (defmethod from-java Enum [enum] (str enum)) (defmethod from-java-deep nil [_ _] nil) (defmethod from-java-deep java.sql.SQLException [^Object ex opts] ((get-method from-java-deep :default) ex opts)) (defmethod from-java-deep Boolean [value _] (boolean value)) (defmethod from-java-deep Enum [enum _] (str enum)) (defmethod from-java-shallow nil [_ _] nil) (defmethod from-java-shallow java.sql.SQLException [^Object ex opts] ((get-method from-java-shallow :default) ex opts)) (defmethod from-java-shallow Boolean [value _] (boolean value)) (defmethod from-java-shallow Enum [enum _] (str enum)) ;; definitions for interfacting with XMLGregorianCalendar (defmethod to-java [javax.xml.datatype.XMLGregorianCalendar clojure.lang.APersistentMap] [^Class clazz props] (let [^javax.xml.datatype.XMLGregorianCalendar instance (.newInstance clazz) undefined javax.xml.datatype.DatatypeConstants/FIELD_UNDEFINED getu #(get %1 %2 undefined) y (getu props :year)] ;; .setYear is unique in having an overload on int and BigInteger ;; whereas the other setters only have an int version so avoiding ;; reflection means special treatment for .setYear (if (instance? java.math.BigInteger y) (.setYear instance ^java.math.BigInteger y) (.setYear instance ^int y)) (doto instance (.setMonth (getu props :month)) (.setDay (getu props :day)) (.setHour (getu props :hour)) (.setMinute (getu props :minute)) (.setSecond (getu props :second)) (.setTimezone (getu props :timezone))))) (defn- from-xml-gregorian-calendar "Turn an XMLGregorianCalendar object into a clojure map of year, month, day, hour, minute, second and timezone " [^javax.xml.datatype.XMLGregorianCalendar obj] (let [date {:year (.getYear obj) :month (.getMonth obj) :day (.getDay obj)} time {:hour (.getHour obj) :minute (.getMinute obj) :second (.getSecond obj)} tz {:timezone (.getTimezone obj)} is-undefined? #(= javax.xml.datatype.DatatypeConstants/FIELD_UNDEFINED %1)] (conj {} (when-not (is-undefined? (:year date)) date) (when-not (is-undefined? (:hour time)) time) (when-not (is-undefined? (:timezone tz)) tz)))) (defmethod from-java javax.xml.datatype.XMLGregorianCalendar [obj] (from-xml-gregorian-calendar obj)) (defmethod from-java-deep javax.xml.datatype.XMLGregorianCalendar [obj {:keys [add-class]}] (cond-> (from-xml-gregorian-calendar obj) add-class (assoc :class (class obj)))) (defmethod from-java-shallow javax.xml.datatype.XMLGregorianCalendar [obj {:keys [add-class]}] (cond-> (from-xml-gregorian-calendar obj) add-class (assoc :class (class obj)))) java.data-1.2.107/src/main/clojure/clojure/java/data/000077500000000000000000000000001456473053200221775ustar00rootroot00000000000000java.data-1.2.107/src/main/clojure/clojure/java/data/builder.clj000066400000000000000000000206621456473053200243250ustar00rootroot00000000000000;; Copyright (c) Sean Corfield. All rights reserved. ;; The use and distribution terms for this software are covered by the ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) ;; which can be found in the file epl-v10.html at the root of this ;; distribution. By using this software in any fashion, you are agreeing to ;; be bound by the terms of this license. You must not remove this notice, ;; or any other, from this software. (ns ^{:author "Sean Corfield", :doc "A variant of clojure.java.data/to-java that uses a Builder class to build the requested class from a hash map of properties."} clojure.java.data.builder (:require [clojure.java.data :as j])) (set! *warn-on-reflection* true) (defn- get-builder-class [^Class clazz] (try (resolve (symbol (str (.getName clazz) "$Builder"))) (catch Throwable _))) (defn- get-builder ^java.lang.reflect.Method [^Class clazz methods opts] (let [build-name (:build-fn opts) candidates (filter (fn [^java.lang.reflect.Method m] (and (= 0 (alength ^"[Ljava.lang.Class;" (.getParameterTypes m))) (= clazz (.getReturnType m)) (or (nil? build-name) (= build-name (.getName m))))) methods)] (case (count candidates) 0 (throw (IllegalArgumentException. (str "Cannot find builder method that returns " (.getName clazz)))) 1 (first candidates) (let [builds (filter (fn [^java.lang.reflect.Method m] (= "build" (.getName m))) candidates)] (case (count builds) 0 (throw (IllegalArgumentException. (str "Cannot find 'build' method that returns " (.getName clazz)))) (first builds)))))) (defn- find-setters [^Class builder methods opts] (let [candidates (filter (fn [^java.lang.reflect.Method m] (and (= 1 (alength ^"[Ljava.lang.Class;" (.getParameterTypes m))) (= builder (.getReturnType m)) (or (not (re-find #"^set[A-Z]" (.getName m))) (not (:ignore-setters? opts))))) methods)] (reduce (fn [setter-map ^java.lang.reflect.Method m] (let [prop (keyword (cond (re-find #"^set[A-Z]" (.getName m)) (let [^String n (subs (.getName m) 3)] (str (Character/toLowerCase (.charAt n 0)) (subs n 1))) (re-find #"^with[A-Z]" (.getName m)) (let [^String n (subs (.getName m) 4)] (str (Character/toLowerCase (.charAt n 0)) (subs n 1))) :else (.getName m)))] (if (contains? setter-map prop) (throw (IllegalArgumentException. (str "Duplicate setter found for " prop " in " (.getName builder) " class"))) (assoc setter-map prop (#'j/make-setter-fn m))))) {} candidates))) (defn- build-on [instance setters ^Class clazz props] (reduce-kv (fn [builder k v] (if-let [setter (get setters (keyword k))] (apply setter [instance v]) (#'j/throw-log-or-ignore-missing-setter k clazz))) instance props)) (comment ;; given a class, see if it has a nested Builder class ;; otherwise we'll need to be told the builder class ;; and possibly how to create it (get-builder-class java.util.Locale) ;; from the builder class, look for arity-0 methods then return ;; the original class -- if there's only one, use it, if there ;; are multiple and one is called "build", use it, else error (get-builder java.util.Locale (.getMethods java.util.Locale$Builder) {}) ;; setters on a builder will have single arguments and will ;; return the builder class, and will either be: ;; * B propertyName( T ) ;; * B setPropertyName( T ) ;; treat both as setters; thrown exception if they clash ;; (maybe an option to ignore setXyz( T ) methods?) (find-setters java.util.Locale$Builder (.getMethods java.util.Locale$Builder) {}) ;; general pattern will be to: ;; * get the builder class somehow ;; * get its public methods ;; * identify its builder method (or be told it) ;; * identity its setters by name ;; * construct the builder (or be given an instance?) ;; * reduce over the input hash map, ;; * -- if setter matches key, ;; * -- then invoke, use result (use j/to-java to build value here?) ;; * -- else either log, ignore, or throw (per j/*to-java-object-missing-setter*) ;; * invoke builder on result, return that (let [clazz java.util.Locale props {:language "fr"} opts {} ^Class builder (get-builder-class clazz)] (.invoke (get-builder clazz (.getMethods builder) opts) (build-on (j/to-java builder ^clojure.lang.APersistentMap {}) (find-setters builder (.getMethods builder) opts) builder props) nil))) (defn to-java "Given a class and a hash map of properties, figure out the Builder class, figure out the setters for the Builder, construct an instance of it and produce an instance of the original class. A hash map of options may also be provided. Alternatively, given a class, a builder instance, a hash map of properties, and a hash map of options, figure out the setters for the builder class, and use the builder instance to produce an instance of the original class. Finally, given a class, a builder class, a builder instance (possibly of a different class), a hash map of properties, and a hash map of options, figure out the setters for the builder class, and use the builder instance to produce an instance of the original class. The following options may be provided: * :builder-class -- the class that should be used for the builder process; by default we'll assume an inner class of clazz called 'Builder', * :builder-props -- properties used to construct and initialize an instance of the builder class; defaults to an empty hash map; may have :clojure.java.data/constructor as metadata to provide constructor arguments for the builder instance, * :build-fn -- the name of the method in the Builder class to use to complete the builder process and return the desired class; by default we'll try to deduce it, preferring 'build' if we find multiple candidates, * :ignore-setters? -- a flag to indicate that methods on the builder class that begin with 'set' should be ignored, which may be necessary to avoid ambiguous methods that look like builder properties; by default 'setFooBar` will be treated as a builder property 'fooBar' if it accepts a single argument and returns a builder instance." ([clazz props] (to-java clazz props {})) ([^Class clazz props opts] (if-let [builder (or (:builder-class opts) (get-builder-class clazz))] (to-java clazz builder (j/to-java builder (get opts :builder-props {})) props opts) (throw (IllegalArgumentException. (str "Unable to deduce a builder class for " (.getName clazz)))))) ([clazz instance props opts] (let [builder (or (:builder-class opts) (class instance))] (to-java clazz builder instance props opts))) ([^Class clazz ^Class builder instance props opts] (.invoke (get-builder clazz (.getMethods builder) opts) (build-on instance (find-setters builder (.getMethods builder) opts) builder props) nil))) (comment (to-java java.util.Locale {:language "fr" :region "EG"} ;; these options are all defaults {:builder-class java.util.Locale$Builder :builder-props {} :build-fn "build"}) (to-java java.util.Locale (java.util.Locale$Builder.) {:language "fr" :region "EG"} ;; these options are all defaults {#_#_:builder-class java.util.Locale$Builder}) (to-java java.util.Locale (java.util.Locale$Builder.) {:language "fr" :region "EG"} ;; these options are all defaults {:builder-class java.util.Locale$Builder :builder-props {} :build-fn "build"})) java.data-1.2.107/src/test/000077500000000000000000000000001456473053200152725ustar00rootroot00000000000000java.data-1.2.107/src/test/clojure/000077500000000000000000000000001456473053200167355ustar00rootroot00000000000000java.data-1.2.107/src/test/clojure/.gitignore000066400000000000000000000000001456473053200207130ustar00rootroot00000000000000java.data-1.2.107/src/test/clojure/clojure/000077500000000000000000000000001456473053200204005ustar00rootroot00000000000000java.data-1.2.107/src/test/clojure/clojure/java/000077500000000000000000000000001456473053200213215ustar00rootroot00000000000000java.data-1.2.107/src/test/clojure/clojure/java/data/000077500000000000000000000000001456473053200222325ustar00rootroot00000000000000java.data-1.2.107/src/test/clojure/clojure/java/data/builder_test.clj000066400000000000000000000034221456473053200254120ustar00rootroot00000000000000;; Copyright (c) Sean Corfield. All rights reserved. ;; The use and distribution terms for this software are covered by the ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) ;; which can be found in the file epl-v10.html at the root of this ;; distribution. By using this software in any fashion, you are agreeing to ;; be bound by the terms of this license. You must not remove this notice, ;; or any other, from this software. (ns ^{:author "Sean Corfield", :doc "Tests for the builder aspects of java.data."} clojure.java.data.builder-test (:require [clojure.java.data.builder :as b] [clojure.test :refer [deftest is]])) (deftest locale-builder-tests (let [l (b/to-java java.util.Locale {:language "fr" :region "FR"})] (is (= "fr" (.getLanguage l))) (is (= "FR" (.getCountry l)))) (let [l (b/to-java java.util.Locale {:language "fr" :region "FR"} {:builder-class java.util.Locale$Builder :builder-props {} :build-fn "build"})] (is (= "fr" (.getLanguage l))) (is (= "FR" (.getCountry l)))) (let [l (b/to-java java.util.Locale (java.util.Locale$Builder.) {:language "fr" :region "FR"} {})] (is (= "fr" (.getLanguage l))) (is (= "FR" (.getCountry l)))) (let [l (b/to-java java.util.Locale (java.util.Locale$Builder.) {:language "fr" :region "FR"} {:builder-class java.util.Locale$Builder :builder-props {} :build-fn "build"})] (is (= "fr" (.getLanguage l))) (is (= "FR" (.getCountry l))))) java.data-1.2.107/src/test/clojure/clojure/java/test_data.clj000066400000000000000000000375371456473053200240020ustar00rootroot00000000000000;; Copyright (c) Cosmin Stejerean, Sean Corfield. All rights reserved. ;; The use and distribution terms for this software are covered by the ;; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) ;; which can be found in the file epl-v10.html at the root of this ;; distribution. By using this software in any fashion, you are agreeing to ;; be bound by the terms of this license. You must not remove this notice, ;; or any other, from this software. (ns clojure.java.test-data (:require [clojure.java.data :as j :refer [from-java from-java-deep from-java-shallow set-properties to-java *to-java-object-missing-setter*]] [clojure.string :as str] [clojure.tools.logging :refer [log* info]] [clojure.test :refer [deftest is testing]]) (:import (clojure.java.data.test Person Address State Primitive TestBean6 TestBean9))) (deftest clojure-to-java (let [person (to-java Person {:name "Bob" :age 30 :address {:line1 "123 Main St" :city "Dallas" :state "TX" :zip "75432"}})] (is (= "Bob" (.getName person))) (is (= 30 (.getAge person))) (is (= "123 Main St" (.. person getAddress getLine1))) (is (= "Dallas" (.. person getAddress getCity))) (is (= State/TX (.. person getAddress getState))) (is (= "75432" (.. person getAddress getZip))))) (deftest clojure-to-java-error-on-missing-setter (binding [*to-java-object-missing-setter* :error] (is (thrown-with-msg? NoSuchFieldException #"Missing setter for :foobar in clojure.java.data.test.Person" (to-java Person {:name "Bob" :foobar "Baz"}))))) (deftest clojure-to-java-ignore-on-missing-setter (binding [*to-java-object-missing-setter* :ignore] (let [person (to-java Person {:name "Bob" :foobar "Baz"})] (is (= "Bob" (.getName person)))))) (defmacro with-temporary-root [[var-name new-value] & body] `(let [current-var# ~var-name] (alter-var-root (var ~var-name) (fn [ignore#] ~new-value)) ~@body (alter-var-root (var ~var-name) (fn [ignore#] current-var#)))) (deftest clojure-to-java-log-on-missing-setter (binding [*to-java-object-missing-setter* :log] (with-temporary-root [log* (fn [log level throwable message] (throw (new Exception (str "invoked " level))))] (is (thrown-with-msg? Exception #"invoked :info" (to-java Person {:name "Bob" :foobar "Baz"})))))) ;; feature testing macro, based on suggestion from Chas Emerick: (defmacro ^{:private true} when-available [sym & body] (try (when (resolve sym) (list* 'do body)) (catch ClassNotFoundException _#))) (defmacro ^{:private true} when-not-available [sym & body] (try (when-not (resolve sym) (list* 'do body)) (catch ClassNotFoundException _#))) (when-available biginteger (defn- to-BigInteger [v] (biginteger v))) (when-not-available biginteger (defn- to-BigInteger [v] (bigint v))) (deftest java-to-clojure (testing "regular" (let [address (new Address "123 Main St" "Dallas" State/TX "75432") person (from-java (Person. "Bob" (to-BigInteger 30) address))] (is (= "Bob" (:name person))) (is (= 30 (:age person))) (is (= "123 Main St" (:line1 (:address person)))) (is (= "TX" (:state (:address person)))))) (testing "deep" (let [address (new Address "123 Main St" "Dallas" State/TX "75432") person (from-java-deep (Person. "Bob" (to-BigInteger 30) address) {})] (is (= "Bob" (:name person))) (is (= 30 (:age person))) (is (= "123 Main St" (:line1 (:address person)))) (is (= "TX" (:state (:address person)))))) (testing "shallow" (let [address (new Address "123 Main St" "Dallas" State/TX "75432") person (from-java-shallow (Person. "Bob" (to-BigInteger 30) address) {})] (is (= "Bob" (:name person))) (is (= 30 (:age person))) (is (instance? Address (:address person)))))) (deftest primitives (testing "regular" (let [datum {:boolMember true :boolArray [true false] :charMember \H :charArray (map identity "Hello World") :byteMember 127 :byteArray [1 2 3] :shortMember 15000 :shortArray [13000 14000 15000] :intMember 18000 :intArray [1 2 3] :longMember 60000000 :longArray [1 2 3] :floatMember 1.5 :floatArray [1.5 2.5 3.5] :doubleMember 1.5 :doubleArray [1.5 2.0 2.5] :nestedIntArray [[1 2] [3] [4 5 6] []] :stringArray ["Argument" "Vector"]}] (is (= datum (from-java (to-java Primitive datum)))))) (testing "deep" (let [datum {:boolMember true :boolArray [true false] :charMember \H :charArray (map identity "Hello World") :byteMember 127 :byteArray [1 2 3] :shortMember 15000 :shortArray [13000 14000 15000] :intMember 18000 :intArray [1 2 3] :longMember 60000000 :longArray [1 2 3] :floatMember 1.5 :floatArray [1.5 2.5 3.5] :doubleMember 1.5 :doubleArray [1.5 2.0 2.5] :nestedIntArray [[1 2] [3] [4 5 6] []] :stringArray ["Argument" "Vector"]}] (is (= datum (from-java-deep (to-java Primitive datum) {}))))) (testing "shallow" (let [datum {:boolMember true :boolArray [true false] :charMember \H :charArray (map identity "Hello World") :byteMember 127 :byteArray [1 2 3] :shortMember 15000 :shortArray [13000 14000 15000] :intMember 18000 :intArray [1 2 3] :longMember 60000000 :longArray [1 2 3] :floatMember 1.5 :floatArray [1.5 2.5 3.5] :doubleMember 1.5 :doubleArray [1.5 2.0 2.5] :nestedIntArray [[1 2] [3] [4 5 6] []] :stringArray ["Argument" "Vector"]}] (reduce-kv (fn [_ k v] (if (.endsWith ^String (name k) "Array") (if (= k :nestedIntArray) (is (= (get datum k) (map #(into [] %) v))) (is (= (get datum k) (seq v)))) (is (= (get datum k) v)))) nil (from-java-shallow (to-java Primitive datum) {}))))) (deftest java-map (let [datum {"a" "one" "b" 2 "c" (java.net.URI. "")}] (testing "regular" ; is actually shallow on hash maps (is (= datum (from-java (to-java java.util.Map datum))))) (testing "deep" (is (= (update datum "c" from-java) (from-java-deep (to-java java.util.Map datum) {})))) (testing "shallow" (is (= datum (from-java-shallow (to-java java.util.Map datum) {})))))) (deftest jdata-6 (testing "regular" (let [bean-instance (TestBean6.) _ (. bean-instance setFoo {"bar" "baz"}) bean-instance-as-map (from-java bean-instance) new-bean-instance (to-java TestBean6 bean-instance-as-map)] (is (= {"bar" "baz"} (:foo bean-instance-as-map))) (is (= {"bar" "baz"} (.getFoo new-bean-instance))))) (testing "deep" (let [bean-instance (TestBean6.) _ (. bean-instance setFoo {"bar" "baz"}) bean-instance-as-map (from-java-deep bean-instance {}) new-bean-instance (to-java TestBean6 bean-instance-as-map)] (is (= {"bar" "baz"} (:foo bean-instance-as-map))) (is (= {"bar" "baz"} (.getFoo new-bean-instance))))) (testing "shallow" (let [bean-instance (TestBean6.) _ (. bean-instance setFoo {"bar" "baz"}) bean-instance-as-map (from-java-shallow bean-instance {}) new-bean-instance (to-java TestBean6 bean-instance-as-map)] (is (= {"bar" "baz"} (:foo bean-instance-as-map))) (is (= {"bar" "baz"} (.getFoo new-bean-instance)))))) (deftest jdata-8-11-date (testing "regular" (let [d (java.util.Date.)] (is (= d (to-java java.util.Date (from-java d)))))) (testing "deep" (let [d (java.util.Date.)] (is (= d (to-java java.util.Date (from-java-deep d {})))))) (testing "shallow" (let [d (java.util.Date.)] (is (= d (to-java java.util.Date (from-java-shallow d {}))))))) (when-available java.time.Instant (deftest jdata-8-11-instant (testing "regular" (let [t (java.time.Instant/now)] (is (= t (to-java java.time.Instant (from-java t)))))) (testing "deep" (let [t (java.time.Instant/now)] (is (= t (to-java java.time.Instant (from-java-deep t {})))))) (testing "shallow" (let [t (java.time.Instant/now)] (is (= t (to-java java.time.Instant (from-java-shallow t {})))))))) (deftest jdata-9 (let [bean-instance (TestBean9.) _ (.setAString bean-instance "something") _ (.setABool bean-instance true) _ (.setABoolean bean-instance false)] (testing "regular" (is (= {:AString "something" :ABool true} ;; :ABoolean missing because 'is' Boolean is not a getter (from-java bean-instance)))) (testing "deep" (is (= {:AString "something" :ABool true} ;; :ABoolean missing because 'is' Boolean is not a getter (from-java-deep bean-instance {})))) (testing "shallow" (is (= {:AString "something" :ABool true} ;; :ABoolean missing because 'is' Boolean is not a getter (from-java-shallow bean-instance {})))))) (deftest jdata-10 (testing "regular" (is (if (:absolute (from-java (java.net.URI. ""))) false true)) (is (if (:opaque (from-java (java.net.URI. ""))) false true))) (testing "deep" (is (if (:absolute (from-java-deep (java.net.URI. "") {})) false true)) (is (if (:opaque (from-java-deep (java.net.URI. "") {})) false true))) (testing "shallow" (is (if (:absolute (from-java-shallow (java.net.URI. "") {})) false true)) (is (if (:opaque (from-java-shallow (java.net.URI. "") {})) false true)))) (deftest jdata-12 (let [eek1 (java.sql.SQLException. "SQL 1") eek2 (java.sql.SQLException. "SQL 2") eek3 (java.sql.SQLException. "SQL 3")] (.setNextException eek1 eek2) (.setNextException eek2 eek3) (testing "regular" (let [ex (from-java eek1)] (is (= "SQL 1" (get-in ex [:message]))) (is (= "SQL 2" (get-in ex [:nextException :message]))) (is (= "SQL 3" (get-in ex [:nextException :nextException :message]))) (is (nil? (get-in ex [:nextException :nextException :nextException]))))) (testing "deep" (let [ex (from-java-deep eek1 {})] (is (= "SQL 1" (get-in ex [:message]))) (is (= "SQL 2" (get-in ex [:nextException :message]))) (is (= "SQL 3" (get-in ex [:nextException :nextException :message]))) (is (nil? (get-in ex [:nextException :nextException :nextException]))))) (testing "shallow" (let [ex (from-java-shallow eek1 {})] (is (= "SQL 1" (get-in ex [:message]))) (is (instance? java.sql.SQLException (get ex :nextException))))))) ;; set-properties tests (deftest jdata-15 (testing "flat maps" (let [address (set-properties (new Address) {:line1 "123 Main St" :city "Dallas" :state "TX" :zip "75432"}) person (set-properties (new Person) {:name "Bob" :age 30 :address address})] (is (= "Bob" (.getName person))) (is (= 30 (.getAge person))) (is (= "123 Main St" (.. person getAddress getLine1))) (is (= "Dallas" (.. person getAddress getCity))) (is (= State/TX (.. person getAddress getState))) (is (= "75432" (.. person getAddress getZip))))) (testing "nested map" (let [person (set-properties (new Person) {:name "Bob" :age 30 :address {:line1 "123 Main St" :city "Dallas" :state "TX" :zip "75432"}})] (is (= "Bob" (.getName person))) (is (= 30 (.getAge person))) (is (= "123 Main St" (.. person getAddress getLine1))) (is (= "Dallas" (.. person getAddress getCity))) (is (= State/TX (.. person getAddress getState))) (is (= "75432" (.. person getAddress getZip)))))) ;; constructor tests (deftest jdata-16 (testing "just constructor arguments" (let [^Address address (to-java Address (with-meta {} {::j/constructor ["123 Main St" "Dallas" (to-java State "TX") "75432"]})) person (to-java Person (with-meta {} {::j/constructor ["Bob" (biginteger 30) address]}))] (is (= "Bob" (.getName person))) (is (= 30 (.getAge person))) (is (= "123 Main St" (.. person getAddress getLine1))) (is (= "Dallas" (.. person getAddress getCity))) (is (= State/TX (.. person getAddress getState))) (is (= "75432" (.. person getAddress getZip))))) (testing "mixed constructor arguments and properties" (let [person (to-java Person (with-meta {:address {:line1 "123 Main St" :city "Dallas" :state "TX" :zip "75432"}} {::j/constructor ["Bob" (biginteger 30) nil]}))] (is (= "Bob" (.getName person))) (is (= 30 (.getAge person))) (is (= "123 Main St" (.. person getAddress getLine1))) (is (= "Dallas" (.. person getAddress getCity))) (is (= State/TX (.. person getAddress getState))) (is (= "75432" (.. person getAddress getZip)))) (let [person (to-java Person (with-meta {:address {:line1 "123 Main St" :city "Dallas" :state "TX" :zip "75432"} :age 30} {::j/constructor ["Bob" nil nil]}))] (is (= "Bob" (.getName person))) (is (= 30 (.getAge person))) (is (= "123 Main St" (.. person getAddress getLine1))) (is (= "Dallas" (.. person getAddress getCity))) (is (= State/TX (.. person getAddress getState))) (is (= "75432" (.. person getAddress getZip)))))) (deftest jdata-22 (testing "Properties with String keys" (let [props (to-java java.util.Properties {"a" 1 "b" "two"})] (is (= #{"a" "b"} (.stringPropertyNames props))) (is (= "1" (.getProperty props "a"))) (is (= "two" (.getProperty props "b"))) (is (= "nope" (.getProperty props "c" "nope"))))) (testing "Properties with Keyword keys" (let [props (to-java java.util.Properties {:a 1 :b "two"})] (is (= #{"a" "b"} (.stringPropertyNames props))) (is (= "1" (.getProperty props "a"))) (is (= "two" (.getProperty props "b"))) (is (= "nope" (.getProperty props "c" "nope")))))) java.data-1.2.107/src/test/java/000077500000000000000000000000001456473053200162135ustar00rootroot00000000000000java.data-1.2.107/src/test/java/.gitignore000066400000000000000000000000001456473053200201710ustar00rootroot00000000000000java.data-1.2.107/src/test/java/clojure/000077500000000000000000000000001456473053200176565ustar00rootroot00000000000000java.data-1.2.107/src/test/java/clojure/java/000077500000000000000000000000001456473053200205775ustar00rootroot00000000000000java.data-1.2.107/src/test/java/clojure/java/data/000077500000000000000000000000001456473053200215105ustar00rootroot00000000000000java.data-1.2.107/src/test/java/clojure/java/data/test/000077500000000000000000000000001456473053200224675ustar00rootroot00000000000000java.data-1.2.107/src/test/java/clojure/java/data/test/Address.java000066400000000000000000000014311456473053200247160ustar00rootroot00000000000000package clojure.java.data.test; public class Address { private String line1; private String city; private State state; private String zip; public Address() { } public Address(String line1, String city, State state, String zip) { this.line1 = line1; this.city = city; this.state = state; this.zip = zip; } public String getLine1() { return line1; } public void setLine1(String line1) { this.line1 = line1; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public State getState() { return state; } public void setState(State state) { this.state = state; } public String getZip() { return zip; } public void setZip(String zip) { this.zip = zip; } } java.data-1.2.107/src/test/java/clojure/java/data/test/Person.java000066400000000000000000000013641456473053200246040ustar00rootroot00000000000000package clojure.java.data.test; import java.math.BigInteger; public class Person { private String name; private BigInteger age; private Address address; public Person() { } public Person(String name, BigInteger age, Address address) { this.name = name; this.age = age; this.address = address; } public String getName() { return name; } public void setName(String name) { this.name = name; } public BigInteger getAge() { return age; } public void setAge(BigInteger age) { this.age = age; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } } java.data-1.2.107/src/test/java/clojure/java/data/test/Primitive.java000066400000000000000000000070161456473053200253060ustar00rootroot00000000000000package clojure.java.data.test; public class Primitive { private boolean boolMember; private boolean[] boolArray; private char charMember; private char[] charArray; private byte byteMember; private byte[] byteArray; private short shortMember; private short[] shortArray; private int intMember; private int[] intArray; private long longMember; private long[] longArray; private float floatMember; private float[] floatArray; private double doubleMember; private double[] doubleArray; private int[][] nestedIntArray; private String[] stringArray; public boolean isBoolMember() { return boolMember; } public void setBoolMember(boolean boolMember) { this.boolMember = boolMember; } public boolean[] getBoolArray() { return boolArray; } public void setBoolArray(boolean[] boolArray) { this.boolArray = boolArray; } public char getCharMember() { return charMember; } public void setCharMember(char charMember) { this.charMember = charMember; } public char[] getCharArray() { return charArray; } public void setCharArray(char[] charArray) { this.charArray = charArray; } public byte getByteMember() { return byteMember; } public void setByteMember(byte byteMember) { this.byteMember = byteMember; } public byte[] getByteArray() { return byteArray; } public void setByteArray(byte[] byteArray) { this.byteArray = byteArray; } public short getShortMember() { return shortMember; } public void setShortMember(short shortMember) { this.shortMember = shortMember; } public short[] getShortArray() { return shortArray; } public void setShortArray(short[] shortArray) { this.shortArray = shortArray; } public int getIntMember() { return intMember; } public void setIntMember(int intMember) { this.intMember = intMember; } public int[] getIntArray() { return intArray; } public void setIntArray(int[] intArray) { this.intArray = intArray; } public long getLongMember() { return longMember; } public void setLongMember(long longMember) { this.longMember = longMember; } public long[] getLongArray() { return longArray; } public void setLongArray(long[] longArray) { this.longArray = longArray; } public float getFloatMember() { return floatMember; } public void setFloatMember(float floatMember) { this.floatMember = floatMember; } public float[] getFloatArray() { return floatArray; } public void setFloatArray(float[] floatArray) { this.floatArray = floatArray; } public double getDoubleMember() { return doubleMember; } public void setDoubleMember(double doubleMember) { this.doubleMember = doubleMember; } public double[] getDoubleArray() { return doubleArray; } public void setDoubleArray(double[] doubleArray) { this.doubleArray = doubleArray; } public int[][] getNestedIntArray() { return nestedIntArray; } public void setNestedIntArray(int[][] nestedIntArray) { this.nestedIntArray = nestedIntArray; } public String[] getStringArray() { return stringArray; } public void setStringArray(String[] stringArray) { this.stringArray = stringArray; } } java.data-1.2.107/src/test/java/clojure/java/data/test/State.java000066400000000000000000000004651456473053200244170ustar00rootroot00000000000000package clojure.java.data.test; public enum State { AL, AK, AZ, AR, CA, CO, CT, DE, DC, FL, GA, HI, ID, IL, IN, IA, KS, KY, LA, ME, MD, MA, MI, MN, MS, MO, MT, NE, NV, NH, NJ, NM, NY, NC, ND, OH, OK, OR, PA, RI, SC, SD, TN, TX, UT, VT, VA, WA, WV, WI, WY } java.data-1.2.107/src/test/java/clojure/java/data/test/TestBean6.java000066400000000000000000000003501456473053200251230ustar00rootroot00000000000000package clojure.java.data.test; import java.util.Map; public class TestBean6 { private java.util.Map foo; public void setFoo(Map foo) { this.foo = foo; } public Map getFoo() { return foo; } } java.data-1.2.107/src/test/java/clojure/java/data/test/TestBean9.java000066400000000000000000000012001456473053200251210ustar00rootroot00000000000000package clojure.java.data.test; import java.util.Map; public class TestBean9 { private boolean aBool; private Boolean aBoolean; private String aString; public void setABool(boolean b) { this.aBool = b; } public boolean isABool() { return aBool; } public void setABoolean(Boolean b) { this.aBoolean = b; } // not a getter because 'is' only works for primitive boolean public Boolean isABoolean() { return aBoolean; } public void setAString(String s) { this.aString = s; } public String getAString() { return aString; } }