├── .gitignore ├── .circleci └── config.yml ├── LICENSE ├── project.clj ├── README.md ├── src ├── java │ └── clj_yaml │ │ └── MarkedConstructor.java └── clojure │ └── clj_yaml │ └── core.clj ├── test └── clj_yaml │ └── core_test.clj └── epl-v10.html /.gitignore: -------------------------------------------------------------------------------- 1 | bin 2 | lib 3 | classes 4 | *.jar 5 | pom.xml* 6 | /target 7 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | jobs: 3 | test: 4 | docker: 5 | - image: circleci/clojure:lein-2.8.1 6 | steps: 7 | - checkout 8 | - run: 9 | name: Ensure No Reflection Warnings 10 | command: "! lein check 2>&1 | grep 'Reflection warning'" 11 | - run: lein test 12 | 13 | 14 | workflows: 15 | workflow: 16 | jobs: 17 | - test 18 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | (c) Lance Bradley - Licensed under the same terms as clojure itself. 2 | 3 | The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0) 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 terms of this license. You must not remove this notice, or any other, from this software. 4 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject circleci/clj-yaml "0.6.0" 2 | :description "YAML encoding and decoding for Clojure using SnakeYAML" 3 | :url "https://github.com/circleci/clj-yaml" 4 | :license {:name "Eclipse Public License - v 1.0" 5 | :url "http://www.eclipse.org/legal/epl-v10.html" 6 | :distribution :repo 7 | :comments "same as Clojure"} 8 | ;; Emit warnings on all reflection calls. 9 | :global-vars {*warn-on-reflection* true} 10 | :source-paths ["src/clojure"] 11 | :java-source-paths ["src/java"] 12 | :javac-options ["-target" "1.6" "-source" "1.6" "-Xlint:-options"] 13 | :dependencies 14 | [[org.clojure/clojure "1.7.0"] 15 | [org.yaml/snakeyaml "1.23"] 16 | [org.flatland/ordered "1.5.7"]]) 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This respository was originally a fork of [the original](https://github.com/lancepantz/clj-yaml) and is no longer being maintained. The [project is now a part of clj-commons](https://github.com/clj-commons/clj-yaml). 2 | 3 | `circleci/clj-yaml` provides [YAML](http://yaml.org) encoding and 4 | decoding for Clojure via the [snakeyaml][] Java library. 5 | 6 | [SnakeYAML]: https://bitbucket.org/asomov/snakeyaml/ 7 | 8 | [![Clojars Project](https://img.shields.io/clojars/v/circleci/clj-yaml.svg)](https://clojars.org/circleci/clj-yaml) [![cljdoc badge](https://cljdoc.org/badge/circleci/clj-yaml)](https://cljdoc.org/d/circleci/clj-yaml/CURRENT) 9 | [![CircleCI Status](https://circleci.com/gh/circleci/clj-yaml.svg?style=svg)](https://circleci.com/gh/circleci/clj-yaml) 10 | 11 | ## Usage 12 | 13 | (require '[clj-yaml.core :as yaml]) 14 | 15 | (yaml/generate-string 16 | [{:name "John Smith", :age 33} 17 | {:name "Mary Smith", :age 27}]) 18 | "- {name: John Smith, age: 33}\n- {name: Mary Smith, age: 27}\n" 19 | 20 | (yaml/parse-string " 21 | - {name: John Smith, age: 33} 22 | - name: Mary Smith 23 | age: 27 24 | ") 25 | => ({:name "John Smith", :age 33} 26 | {:name "Mary Smith", :age 27}) 27 | 28 | By default, keys are converted to clojure keywords. To prevent this, 29 | add `:keywords false` parameters to the `parse-string` function: 30 | 31 | (yaml/parse-string " 32 | - {name: John Smith} 33 | " :keywords false) 34 | 35 | ## Installation 36 | 37 | `circleci/clj-yaml` is available as a Maven artifact from [Clojars](http://clojars.org/circleci/clj-yaml). 38 | 39 | ### Leiningen/Boot 40 | 41 | ```clojure 42 | [circleci/clj-yaml "0.6.0"] 43 | ``` 44 | 45 | ### Clojure CLI/`deps.edn` 46 | 47 | ```clojure 48 | circleci/clj-yaml {:mvn/version "0.6.0"} 49 | ``` 50 | 51 | ## Development 52 | 53 | $ git clone git://github.com/circleci/clj-yaml.git 54 | $ lein deps 55 | $ lein test 56 | $ lein install 57 | -------------------------------------------------------------------------------- /src/java/clj_yaml/MarkedConstructor.java: -------------------------------------------------------------------------------- 1 | package clj_yaml; 2 | 3 | import org.yaml.snakeyaml.constructor.Construct; 4 | import org.yaml.snakeyaml.constructor.Constructor; 5 | import org.yaml.snakeyaml.constructor.SafeConstructor; 6 | import org.yaml.snakeyaml.constructor.AbstractConstruct; 7 | import org.yaml.snakeyaml.nodes.Node; 8 | import org.yaml.snakeyaml.nodes.Tag; 9 | import org.yaml.snakeyaml.error.Mark; 10 | 11 | /* A subclass of SafeConstructor that wraps all the type-specific 12 | constructors it defines with versions that mark the start and 13 | end positions. 14 | */ 15 | public class MarkedConstructor extends SafeConstructor { 16 | /* The types we want to wrap. */ 17 | public static Tag[] tags = {Tag.NULL, Tag.BOOL, Tag.INT, Tag.FLOAT, 18 | Tag.BINARY, Tag.TIMESTAMP, Tag.OMAP, 19 | Tag.PAIRS, Tag.SET, Tag.STR, Tag.SEQ, Tag.MAP}; 20 | 21 | public MarkedConstructor() { 22 | // Make sure SafeConstructor's constructor is called first, 23 | // so that we overwrite the keys that SafeConstructor sets. 24 | super(); 25 | // Wrap all the constructors with Marking constructors. 26 | for (Tag tag : tags) { 27 | Construct old = this.yamlConstructors.get(tag); 28 | this.yamlConstructors.put(tag, new Marking(old)); 29 | } 30 | } 31 | /* An intermediate representation of data marked with start and 32 | end positions before we turn it into the nice clojure thing. 33 | */ 34 | public static class Marked { 35 | /* An object paired with start and end Marks. */ 36 | public Mark start; 37 | public Mark end; 38 | public Object marked; 39 | public Marked(Mark start, Mark end, Object marked) { 40 | this.start = start; 41 | this.end = end; 42 | this.marked = marked; 43 | } 44 | } 45 | 46 | /* A wrapper around a Construct that marks source positions before calling 47 | the original. 48 | */ 49 | public class Marking extends AbstractConstruct { 50 | public Construct constructor; 51 | public Marking(Construct constructor) { 52 | this.constructor = constructor; 53 | } 54 | public Object construct(Node node) { 55 | return new Marked 56 | (node.getStartMark(), 57 | node.getEndMark(), 58 | constructor.construct(node)); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/clojure/clj_yaml/core.clj: -------------------------------------------------------------------------------- 1 | (ns clj-yaml.core 2 | (:require [flatland.ordered.map :refer (ordered-map)] 3 | [flatland.ordered.set :refer (ordered-set)]) 4 | (:import (org.yaml.snakeyaml Yaml DumperOptions DumperOptions$FlowStyle) 5 | (org.yaml.snakeyaml.constructor Constructor SafeConstructor BaseConstructor) 6 | (org.yaml.snakeyaml.representer Representer) 7 | (org.yaml.snakeyaml.error Mark) 8 | (clj_yaml MarkedConstructor) 9 | (java.util LinkedHashMap))) 10 | 11 | (def flow-styles 12 | {:auto DumperOptions$FlowStyle/AUTO 13 | :block DumperOptions$FlowStyle/BLOCK 14 | :flow DumperOptions$FlowStyle/FLOW}) 15 | 16 | (defn ^DumperOptions make-dumper-options 17 | [& {:keys [flow-style]}] 18 | (doto (DumperOptions.) 19 | (.setDefaultFlowStyle (flow-styles flow-style)))) 20 | 21 | (defn ^Yaml make-yaml 22 | "Make a yaml encoder/decoder with some given options." 23 | [& {:keys [dumper-options unsafe mark]}] 24 | (let [^BaseConstructor constructor 25 | (if unsafe (Constructor.) 26 | (if mark (MarkedConstructor.) (SafeConstructor.))) 27 | ;; TODO: unsafe marked constructor 28 | dumper (if dumper-options 29 | (make-dumper-options :flow-style (:flow-style dumper-options)) 30 | (DumperOptions.))] 31 | (Yaml. constructor (Representer.) dumper))) 32 | 33 | (defrecord Marked 34 | [start end unmark]) 35 | 36 | (defn mark 37 | "Mark some data with start and end positions." 38 | [start end marked] 39 | (Marked. start end marked)) 40 | 41 | (defn marked? 42 | "Let us know whether this piece of data is marked with source positions." 43 | [m] 44 | (instance? Marked m)) 45 | 46 | (defn unmark 47 | "Strip the source information from this piece of data, if it exists." 48 | [m] 49 | (if (marked? m) 50 | (:unmark m) 51 | m)) 52 | 53 | (defprotocol YAMLCodec 54 | "A protocol for things that can be coerced to and from the types 55 | that snakeyaml knows how to encode and decode." 56 | (encode [data]) 57 | (decode [data keywords])) 58 | 59 | (extend-protocol YAMLCodec 60 | clj_yaml.MarkedConstructor$Marked 61 | (decode [data keywords] 62 | (letfn [(from-Mark [^Mark mark] 63 | {:line (.getLine mark) 64 | :index (.getIndex mark) 65 | :column (.getColumn mark)})] 66 | ;; Decode the marked data and rewrap it with its source position. 67 | (mark (-> data .start from-Mark) 68 | (-> data .end from-Mark) 69 | (-> data .marked 70 | (decode keywords))))) 71 | 72 | clojure.lang.IPersistentMap 73 | (encode [data] 74 | (let [lhm (LinkedHashMap.)] 75 | (doseq [[k v] data] 76 | (.put lhm (encode k) (encode v))) 77 | lhm)) 78 | 79 | clojure.lang.IPersistentCollection 80 | (encode [data] 81 | (map encode data)) 82 | 83 | clojure.lang.Keyword 84 | (encode [data] 85 | (name data)) 86 | 87 | java.util.LinkedHashMap 88 | (decode [data keywords] 89 | (letfn [(decode-key [k] 90 | (if keywords 91 | ;; (keyword k) is nil for numbers etc 92 | (or (keyword k) k) 93 | k))] 94 | (into (ordered-map) 95 | (for [[k v] data] 96 | [(-> k (decode keywords) decode-key) (decode v keywords)])))) 97 | 98 | java.util.LinkedHashSet 99 | (decode [data keywords] 100 | (into (ordered-set) data)) 101 | 102 | java.util.ArrayList 103 | (decode [data keywords] 104 | (map #(decode % keywords) data)) 105 | 106 | Object 107 | (encode [data] data) 108 | (decode [data keywords] data) 109 | 110 | nil 111 | (encode [data] data) 112 | (decode [data keywords] data)) 113 | 114 | 115 | (defn generate-string [data & opts] 116 | (.dump ^Yaml (apply make-yaml opts) 117 | (encode data))) 118 | 119 | (defn parse-string 120 | [^String string & {:keys [unsafe mark keywords] :or {keywords true}}] 121 | (decode (.load (make-yaml :unsafe unsafe :mark mark) string) keywords)) 122 | -------------------------------------------------------------------------------- /test/clj_yaml/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns clj-yaml.core-test 2 | (:use clojure.test) 3 | (:use clj-yaml.core) 4 | (:import [java.util Date])) 5 | 6 | (def nested-hash-yaml 7 | "root:\n childa: a\n childb: \n grandchild: \n greatgrandchild: bar\n") 8 | 9 | (def list-yaml 10 | "--- # Favorite Movies\n- Casablanca\n- North by Northwest\n- The Man Who Wasn't There") 11 | 12 | (def hashes-lists-yaml " 13 | items: 14 | - part_no: A4786 15 | descrip: Water Bucket (Filled) 16 | price: 1.47 17 | quantity: 4 18 | 19 | - part_no: E1628 20 | descrip: High Heeled \"Ruby\" Slippers 21 | price: 100.27 22 | quantity: 1 23 | owners: 24 | - Dorthy 25 | - Wicked Witch of the East 26 | ") 27 | 28 | (def inline-list-yaml 29 | "--- # Shopping list 30 | [milk, pumpkin pie, eggs, juice] 31 | ") 32 | 33 | (def inline-hash-yaml 34 | "{name: John Smith, age: 33}") 35 | 36 | (def list-of-hashes-yaml " 37 | - {name: John Smith, age: 33} 38 | - name: Mary Smith 39 | age: 27 40 | ") 41 | 42 | (def hashes-of-lists-yaml " 43 | men: [John Smith, Bill Jones] 44 | women: 45 | - Mary Smith 46 | - Susan Williams 47 | ") 48 | 49 | (def typed-data-yaml " 50 | the-bin: !!binary 0101") 51 | 52 | (def io-file-typed-data-yaml " 53 | !!java.io.File") 54 | 55 | (def set-yaml " 56 | --- !!set 57 | ? Mark McGwire 58 | ? Sammy Sosa 59 | ? Ken Griff") 60 | 61 | (deftest parse-hash 62 | (let [parsed (parse-string "foo: bar")] 63 | (is (= "bar" (parsed :foo))))) 64 | 65 | (deftest parse-hash-with-numeric-key 66 | (let [parsed (parse-string "123: 456")] 67 | (is (= 456 (parsed 123))))) 68 | 69 | (deftest parse-hash-with-complex-key 70 | (let [parsed (parse-string "[1, 2]: 3")] 71 | (is (= 3 (parsed [1, 2]))))) 72 | 73 | (deftest parse-nested-hash 74 | (let [parsed (parse-string nested-hash-yaml)] 75 | (is (= "a" ((parsed :root) :childa))) 76 | (is (= "bar" ((((parsed :root) :childb) :grandchild) :greatgrandchild))))) 77 | 78 | (deftest parse-list 79 | (let [parsed (parse-string list-yaml)] 80 | (is (= "Casablanca" (first parsed))) 81 | (is (= "North by Northwest" (nth parsed 1))) 82 | (is (= "The Man Who Wasn't There" (nth parsed 2))))) 83 | 84 | (deftest parse-nested-hash-and-list 85 | (let [parsed (parse-string hashes-lists-yaml)] 86 | (is (= "A4786" ((first (parsed :items)) :part_no))) 87 | (is (= "Dorthy" (first ((nth (parsed :items) 1) :owners)))))) 88 | 89 | (deftest parse-inline-list 90 | (let [parsed (parse-string inline-list-yaml)] 91 | (is (= "milk" (first parsed))) 92 | (is (= "pumpkin pie" (nth parsed 1))) 93 | (is (= "eggs" (nth parsed 2))) 94 | (is (= "juice" (last parsed))))) 95 | 96 | (deftest parse-inline-hash 97 | (let [parsed (parse-string inline-hash-yaml)] 98 | (is (= "John Smith" (parsed :name))) 99 | (is (= 33 (parsed :age))))) 100 | 101 | (deftest parse-list-of-hashes 102 | (let [parsed (parse-string list-of-hashes-yaml)] 103 | (is (= "John Smith" ((first parsed) :name))) 104 | (is (= 33 ((first parsed) :age))) 105 | (is (= "Mary Smith" ((nth parsed 1) :name))) 106 | (is (= 27 ((nth parsed 1) :age))))) 107 | 108 | (deftest hashes-of-lists 109 | (let [parsed (parse-string hashes-of-lists-yaml)] 110 | (is (= "John Smith" (first (parsed :men)))) 111 | (is (= "Bill Jones" (last (parsed :men)))) 112 | (is (= "Mary Smith" (first (parsed :women)))) 113 | (is (= "Susan Williams" (last (parsed :women)))))) 114 | 115 | (deftest h-set 116 | (is (= #{"Mark McGwire" "Ken Griff" "Sammy Sosa"} 117 | (parse-string set-yaml)))) 118 | 119 | (deftest typed-data 120 | (let [parsed (parse-string typed-data-yaml)] 121 | (is (= (Class/forName "[B") (type (:the-bin parsed)))))) 122 | 123 | (deftest disallow-arbitrary-typed-data 124 | (is (thrown? org.yaml.snakeyaml.error.YAMLException 125 | (parse-string io-file-typed-data-yaml)))) 126 | 127 | (deftest keywordized 128 | (is (= "items" 129 | (-> hashes-lists-yaml 130 | (parse-string :keywords false) 131 | ffirst)))) 132 | 133 | (deftest not-keywordized-in-lists 134 | (is (every? string? 135 | (-> "[{b: c, c: d}]" 136 | (parse-string :keywords false) 137 | first 138 | keys)))) 139 | 140 | (deftest marking-source-position-works 141 | (let [parsed (parse-string inline-list-yaml :mark true)] 142 | ;; The list starts at the beginning of line 1. 143 | (is (= 1 (-> parsed :start :line))) 144 | (is (= 0 (-> parsed :start :column))) 145 | ;; The first item starts at the second character of line 1. 146 | (is (= 1 (-> parsed unmark first :start :line))) 147 | (is (= 1 (-> parsed unmark first :start :column))) 148 | ;; The first item ends at the fifth character of line 1. 149 | (is (= 1 (-> parsed unmark first :end :line))) 150 | (is (= 5 (-> parsed unmark first :end :column))))) 151 | 152 | (deftest dump-opts 153 | (let [data [{:age 33 :name "jon"} {:age 44 :name "boo"}]] 154 | (is (= "- age: 33\n name: jon\n- age: 44\n name: boo\n" 155 | (generate-string data :dumper-options {:flow-style :block}))) 156 | (is (= "[{age: 33, name: jon}, {age: 44, name: boo}]\n" 157 | (generate-string data :dumper-options {:flow-style :flow}))))) 158 | 159 | (deftest parse-time 160 | (testing "clj-time parses timestamps with more than millisecond precision correctly." 161 | (let [timestamp "2001-11-23 15:02:31.123456 -04:00" 162 | expected 1006542151123] 163 | (is (= (.getTime (parse-string timestamp)) expected))))) 164 | 165 | (deftest maps-are-ordered 166 | (let [parsed (parse-string hashes-lists-yaml) 167 | [first second] (parsed :items)] 168 | (= (keys first) '("part_no" "descrip" "price" "quantity")) 169 | (= (keys second)'("part_no" "descrip" "price" "quantity" "owners")))) 170 | 171 | 172 | (deftest nulls-are-fine 173 | (testing "nil does not blow up" 174 | (let [res (parse-string "- f:")] 175 | (is (= [{:f nil}] res)) 176 | (is (str res))))) 177 | -------------------------------------------------------------------------------- /epl-v10.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Eclipse Public License - Version 1.0 8 | 25 | 26 | 27 | 28 | 29 | 30 |

Eclipse Public License - v 1.0

31 | 32 |

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

36 | 37 |

1. DEFINITIONS

38 | 39 |

"Contribution" means:

40 | 41 |

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

43 |

b) in the case of each subsequent Contributor:

44 |

i) changes to the Program, and

45 |

ii) additions to the Program;

46 |

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

54 | 55 |

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

57 | 58 |

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

61 | 62 |

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

64 | 65 |

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

67 | 68 |

2. GRANT OF RIGHTS

69 | 70 |

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

76 | 77 |

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

88 | 89 |

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

101 | 102 |

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

105 | 106 |

3. REQUIREMENTS

107 | 108 |

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

110 | 111 |

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

113 | 114 |

b) its license agreement:

115 | 116 |

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

120 | 121 |

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

124 | 125 |

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

128 | 129 |

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

133 | 134 |

When the Program is made available in source code form:

135 | 136 |

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

137 | 138 |

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

140 | 141 |

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

143 | 144 |

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

147 | 148 |

4. COMMERCIAL DISTRIBUTION

149 | 150 |

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

172 | 173 |

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

183 | 184 |

5. NO WARRANTY

185 | 186 |

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS 187 | PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 188 | OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, 189 | ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY 190 | OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely 191 | responsible for determining the appropriateness of using and 192 | distributing the Program and assumes all risks associated with its 193 | exercise of rights under this Agreement , including but not limited to 194 | the risks and costs of program errors, compliance with applicable laws, 195 | damage to or loss of data, programs or equipment, and unavailability or 196 | interruption of operations.

197 | 198 |

6. DISCLAIMER OF LIABILITY

199 | 200 |

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

208 | 209 |

7. GENERAL

210 | 211 |

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

216 | 217 |

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

223 | 224 |

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

232 | 233 |

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

252 | 253 |

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

258 | 259 | 260 | 261 | 262 | --------------------------------------------------------------------------------