├── .gitignore ├── LICENSE ├── README.md ├── pom.xml └── src └── main ├── java ├── com │ └── github │ │ └── aruld │ │ └── oneliners │ │ ├── Item1.java │ │ ├── Item10.java │ │ ├── Item2.java │ │ ├── Item3.java │ │ ├── Item4.java │ │ ├── Item5.java │ │ ├── Item6.java │ │ ├── Item7.java │ │ ├── Item8.java │ │ └── Item9.java └── org │ ├── json │ ├── JSONArray.java │ ├── JSONException.java │ ├── JSONObject.java │ ├── JSONString.java │ └── JSONTokener.java │ └── w3 │ └── _2005 │ └── atom │ ├── CategoryType.java │ ├── ContentType.java │ ├── DateTimeType.java │ ├── EntryType.java │ ├── FeedType.java │ ├── GeneratorType.java │ ├── IconType.java │ ├── IdType.java │ ├── LinkType.java │ ├── LogoType.java │ ├── ObjectFactory.java │ ├── PersonType.java │ ├── SourceType.java │ ├── TextType.java │ ├── UriType.java │ └── package-info.java └── test ├── java └── com │ └── github │ └── aruld │ └── oneliners │ └── ItemTest.java └── resources └── data.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | *.ipr 4 | *.iws 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Java 8 - The Next Big JVM Language 2 | ================================== 3 | 4 | ## Introduction 5 | 6 | Java one liners effort is to show why Java 8 Lambda Edition is a cool-kid on the block, not just for Java developers. 7 | Here is my take of the one-liners using Java 8: https://github.com/aruld/java-oneliners/wiki 8 | 9 | ## Overview 10 | 11 | Download JDK 8 GA [here](https://jdk8.java.net/download.html) 12 | 13 | Browse the API documentation [here](http://docs.oracle.com/javase/8/docs/api/) 14 | 15 | Developed with [Intellj IDEA 13.1](http://www.jetbrains.com/idea/download/) 16 | 17 | ## References 18 | 19 | Must read documents on the new language features in Java SE 8 and motivation for Collections library enhancements 20 | 21 | - [State of the Lambda](http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-final.html) 22 | - [State of the Lambda: Libraries Edition](http://cr.openjdk.java.net/~briangoetz/lambda/lambda-libraries-final.html) 23 | - [Streams API Specification](http://download.java.net/jdk8/docs/api/java/util/stream/package-summary.html) -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 20 | 4.0.0 21 | com.github.aruld 22 | oneliners 23 | 1.0.0 24 | jar 25 | Java 8 One Liners 26 | http://jdk8.java.net/ 27 | 28 | 29 | 30 | The Apache Software License, Version 2.0 31 | http://www.apache.org/licenses/LICENSE-2.0.txt 32 | repo 33 | 34 | 35 | 36 | 37 | scm:git:git@github.com:aruld/java-oneliners.git 38 | scm:git:git@github.com:aruld/java-oneliners.git 39 | git@github.com:aruld/java-oneliners.git 40 | 41 | 42 | 43 | 44 | aruld 45 | Arul Dhesiaseelan 46 | aruld@acm.org 47 | 48 | 49 | 50 | 51 | 52 | junit 53 | junit 54 | 4.11 55 | test 56 | 57 | 58 | 59 | 60 | UTF-8 61 | 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-compiler-plugin 68 | 3.0 69 | 70 | 1.8 71 | 1.8 72 | 73 | 74 | 75 | org.apache.maven.plugins 76 | maven-surefire-plugin 77 | 2.13 78 | 79 | 80 | com.aruld.oneliners.ItemTest.java 81 | 82 | 83 | 84 | 85 | org.apache.maven.plugins 86 | maven-resources-plugin 87 | 2.4.3 88 | 89 | 90 | 91 | 92 | 93 | src/main/test/resources 94 | 95 | data.txt 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item1.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.util.List; 4 | 5 | import static java.util.stream.Collectors.toList; 6 | import static java.util.stream.IntStream.range; 7 | 8 | /** 9 | * Multiple Each Item in a List by 2. 10 | */ 11 | public class Item1 { 12 | 13 | public static void main(String[] args) { 14 | // Range is half-open (exclusive) in Java, unlike Scala. 15 | int[] ia = range(1, 10).map(i -> i * 2).toArray(); 16 | List result = range(1, 10).map(i -> i * 2).boxed().collect(toList()); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item10.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.util.*; 4 | 5 | import static java.util.Comparator.comparing; 6 | import static java.util.stream.Collectors.groupingBy; 7 | import static java.util.stream.Collectors.toList; 8 | 9 | /** 10 | * Find the names of albums that have at least one track rated four or higher, sorted by name. 11 | *

12 | * Reference: http://cr.openjdk.java.net/~briangoetz/lambda/lambda-libraries-final.html 13 | */ 14 | public class Item10 { 15 | 16 | public static class Album implements Comparable { 17 | 18 | public final String name; 19 | public final String artist; 20 | 21 | public Album(String name, String artist) { 22 | this.name = name; 23 | this.artist = artist; 24 | } 25 | 26 | @Override 27 | public int compareTo(Album album) { 28 | return this.name.compareTo(album.name); 29 | } 30 | 31 | public List tracks = new ArrayList<>(); 32 | 33 | } 34 | 35 | public static class Track implements Comparable { 36 | public final String name; 37 | public final int rating; 38 | 39 | public Track(String name, int rating) { 40 | this.name = name; 41 | this.rating = rating; 42 | } 43 | 44 | @Override 45 | public int compareTo(Track track) { 46 | return this.name.compareTo(track.name); 47 | } 48 | 49 | public int getRating() { 50 | return rating; 51 | } 52 | } 53 | 54 | public static void main(String[] args) { 55 | Album tailgates = new Album("Tailgates & Tanlines", "Luke Bryan"); 56 | tailgates.tracks.add(new Track("Country Girl (Shake It for Me)", 5)); 57 | tailgates.tracks.add(new Track("Kiss Tomorrow Goodbye", 5)); 58 | tailgates.tracks.add(new Track("Drunk On You", 4)); 59 | tailgates.tracks.add(new Track("Too Damn Young", 4)); 60 | tailgates.tracks.add(new Track("I Don't Want This Night to End", 4)); 61 | tailgates.tracks.add(new Track("You Don't Know Jack", 4)); 62 | tailgates.tracks.add(new Track("Harvest Time", 3)); 63 | tailgates.tracks.add(new Track("I Know You're Gonna Be There", 3)); 64 | tailgates.tracks.add(new Track("Muckalee Creek Water", 3)); 65 | tailgates.tracks.add(new Track("Tailgate Blues", 3)); 66 | tailgates.tracks.add(new Track("Been There, Done That", 3)); 67 | tailgates.tracks.add(new Track("Faded Away", 3)); 68 | tailgates.tracks.add(new Track("I Knew You That Way", 3)); 69 | 70 | Album unapologetic = new Album("Unapologetic", "Rihanna"); 71 | unapologetic.tracks.add(new Track("Phresh Out the Runway", 5)); 72 | unapologetic.tracks.add(new Track("Diamonds", 3)); 73 | unapologetic.tracks.add(new Track("Numb", 3)); 74 | unapologetic.tracks.add(new Track("Pour It Up", 3)); 75 | unapologetic.tracks.add(new Track("Loveeeeeee Song", 4)); 76 | unapologetic.tracks.add(new Track("Jump", 4)); 77 | unapologetic.tracks.add(new Track("Right Now", 4)); 78 | unapologetic.tracks.add(new Track("What Now", 4)); 79 | unapologetic.tracks.add(new Track("Stay", 4)); 80 | unapologetic.tracks.add(new Track("Nobody's Business", 5)); 81 | unapologetic.tracks.add(new Track("Love Without Tragedy", 5)); 82 | unapologetic.tracks.add(new Track("Get It Over With", 5)); 83 | unapologetic.tracks.add(new Track("No Love Allowed", 3)); 84 | unapologetic.tracks.add(new Track("Lost In Paradise", 5)); 85 | 86 | Album red = new Album("Red", "Taylor Swift"); 87 | red.tracks.add(new Track("State of Grace", 4)); 88 | red.tracks.add(new Track("Red", 4)); 89 | red.tracks.add(new Track("Treacherous", 4)); 90 | red.tracks.add(new Track("I Knew You Were Trouble", 5)); 91 | red.tracks.add(new Track("All Too Well", 3)); 92 | red.tracks.add(new Track("22", 3)); 93 | red.tracks.add(new Track("I Almost Do", 3)); 94 | red.tracks.add(new Track("We Are Never Ever Getting Back", 3)); 95 | red.tracks.add(new Track("Stay Stay Stay", 5)); 96 | red.tracks.add(new Track("The Last Time", 5)); 97 | red.tracks.add(new Track("Holy Ground", 3)); 98 | red.tracks.add(new Track("Sad Beautiful Tragic", 3)); 99 | red.tracks.add(new Track("The Lucky One", 4)); 100 | red.tracks.add(new Track("Everything Has Changed", 3)); 101 | red.tracks.add(new Track("Starlight", 4)); 102 | red.tracks.add(new Track("Begin Again", 3)); 103 | 104 | List albums = Arrays.asList(unapologetic, tailgates, red); 105 | 106 | // Print the names of albums that have at least one track rated four or higher, sorted by name. 107 | albums.stream() 108 | .filter(a -> a.tracks.stream().anyMatch(t -> (t.rating >= 4))) 109 | .sorted(comparing(album -> album.name)) 110 | .forEach(album -> System.out.println(album.name)); 111 | 112 | // Merge tracks from all albums 113 | List allTracks = albums.stream() 114 | .flatMap(album -> album.tracks.stream()) 115 | .collect(toList()); 116 | 117 | // Group album tracks by rating 118 | Map> tracksByRating = allTracks.stream() 119 | .collect(groupingBy(Track::getRating)); 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item2.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.util.stream.IntStream; 4 | import java.util.stream.Stream; 5 | 6 | import static java.util.stream.IntStream.range; 7 | 8 | /** 9 | * Sum a List of Numbers. 10 | */ 11 | public class Item2 { 12 | 13 | public static void main(String[] args) { 14 | // Range is half-open (exclusive) as in Python, unlike Scala. 15 | range(1, 1000).sum(); 16 | range(1, 1000).reduce(0, Integer::sum); 17 | Stream.iterate(0, i -> i + 1).limit(1000).reduce(0, Integer::sum); 18 | IntStream.iterate(0, i -> i + 1).limit(1000).reduce(0, Integer::sum); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item3.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | /** 7 | * Verify if Exists in a String 8 | */ 9 | public class Item3 { 10 | 11 | public static void main(String[] args) { 12 | 13 | final List keywords = Arrays.asList("brown", "fox", "dog", "pangram"); 14 | final String tweet = "The quick brown fox jumps over a lazy dog. #pangram http://www.rinkworks.com/words/pangrams.shtml"; 15 | 16 | keywords.stream().anyMatch(tweet::contains); 17 | keywords.stream().reduce(false, (b, keyword) -> b || tweet.contains(keyword), (l, r) -> l || r); 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item4.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.nio.charset.Charset; 7 | import java.nio.file.Files; 8 | import java.util.LinkedList; 9 | import java.util.List; 10 | import java.util.stream.Stream; 11 | 12 | import static java.util.stream.Collectors.toCollection; 13 | 14 | /** 15 | * Read in a File 16 | */ 17 | public class Item4 { 18 | 19 | public static void main(String[] args) throws Exception { 20 | try (BufferedReader reader = new BufferedReader(new FileReader("data.txt"))) { 21 | String fileText = reader.lines().reduce("", String::concat); 22 | } 23 | 24 | try (BufferedReader reader = new BufferedReader(new FileReader("data.txt"))) { 25 | List fileLines = reader.lines().collect(toCollection(LinkedList::new)); 26 | } 27 | 28 | try (Stream lines = Files.lines(new File("data.txt").toPath(), Charset.defaultCharset())) { 29 | List fileLines = lines.collect(toCollection(LinkedList::new)); 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item5.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import static java.lang.System.out; 4 | import static java.util.stream.IntStream.range; 5 | 6 | /** 7 | * Happy Birthday to You! 8 | */ 9 | public class Item5 { 10 | 11 | public static void main(String[] args) { 12 | // Range is half-open (exclusive) in Java, unlike Scala. 13 | range(1, 5).boxed().map(i -> { out.print("Happy Birthday "); if (i == 3) return "dear NAME"; else return "to You"; }).forEach(out::println); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item6.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | import java.util.Objects; 6 | import java.util.function.Function; 7 | import java.util.function.Predicate; 8 | import java.util.stream.Stream; 9 | 10 | import static java.util.stream.Collectors.groupingBy; 11 | 12 | /** 13 | * Filter list of numbers 14 | */ 15 | public class Item6 { 16 | 17 | public static void main(String[] args) { 18 | Map> result = Stream.of(49, 58, 76, 82, 88, 90).collect(groupingBy(forPredicate(i -> i > 60, "passed", "failed"))); 19 | } 20 | 21 | /** 22 | * Map according to the provided predicate. Two output values are provided 23 | * {@code forTrue} is returned if the predicate returns {@code true} 24 | * otherwise the {@code forFalse} value is returned. 25 | * 26 | * @param input type to mapping function 27 | * @param output type from mapping function 28 | * @param predicate decides which value {@code apply} method should return 29 | * @param forTrue value to be returned for {@code true} predicate results 30 | * @param forFalse value to be returned for {@code false} predicate results 31 | * @return a Function whose {@code apply} method provides results according to 32 | * the provided predicate. 33 | * @throws NullPointerException if predicate is null 34 | */ 35 | public static Function forPredicate(Predicate predicate, R forTrue, R forFalse) { 36 | Objects.requireNonNull(predicate); 37 | return t -> predicate.test(t) ? forTrue : forFalse; 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item7.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import org.w3._2005.atom.FeedType; 4 | 5 | import javax.xml.bind.JAXB; 6 | import java.net.URL; 7 | 8 | /** 9 | * Fetch and Parse an XML web service 10 | */ 11 | public class Item7 { 12 | 13 | public static void main(String[] args) throws Exception { 14 | FeedType feed = JAXB.unmarshal(new URL("http://search.twitter.com/search.atom?&q=java8"), FeedType.class); 15 | JAXB.marshal(feed, System.out); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item8.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.util.stream.Stream; 4 | 5 | /** 6 | * Find minimum (or maximum) in a List 7 | */ 8 | public class Item8 { 9 | 10 | public static void main(String[] args) { 11 | int min = Stream.of(14, 35, -7, 46, 98).reduce(Integer::min).get(); 12 | min = Stream.of(14, 35, -7, 46, 98).min(Integer::compare).get(); 13 | 14 | int max = Stream.of(14, 35, -7, 46, 98).reduce(Integer::max).get(); 15 | max = Stream.of(14, 35, -7, 46, 98).max(Integer::compare).get(); 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/github/aruld/oneliners/Item9.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Parallel Processing 8 | */ 9 | public class Item9 { 10 | 11 | public static class LineItem { 12 | private final String someData; 13 | 14 | public LineItem(String someData) { 15 | this.someData = someData; 16 | } 17 | } 18 | 19 | public static int processItem(LineItem item) { 20 | //perform cpu intensive task 21 | return 1; 22 | } 23 | 24 | public static void main(String[] args) { 25 | 26 | List dataList = new ArrayList() { 27 | { 28 | add(new LineItem("HPQ 100 BUY $10.75 LIMIT")); 29 | } 30 | 31 | { 32 | add(new LineItem("MSFT 500 BUY $15.50 LIMIT")); 33 | } 34 | 35 | { 36 | add(new LineItem("FB 500 BUY")); 37 | } 38 | 39 | { 40 | add(new LineItem("M 2000 SELL")); 41 | } 42 | }; 43 | 44 | long result = dataList.parallelStream().mapToInt(line -> processItem(line)).sum(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/org/json/JSONArray.java: -------------------------------------------------------------------------------- 1 | package org.json; 2 | 3 | /* 4 | Copyright (c) 2002 JSON.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | The Software shall be used for Good, not Evil. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | import java.io.IOException; 28 | import java.io.StringWriter; 29 | import java.io.Writer; 30 | import java.lang.reflect.Array; 31 | import java.util.ArrayList; 32 | import java.util.Collection; 33 | import java.util.Iterator; 34 | import java.util.Map; 35 | 36 | /** 37 | * A JSONArray is an ordered sequence of values. Its external text form is a 38 | * string wrapped in square brackets with commas separating the values. The 39 | * internal form is an object having get and opt 40 | * methods for accessing the values by index, and put methods for 41 | * adding or replacing values. The values can be any of these types: 42 | * Boolean, JSONArray, JSONObject, 43 | * Number, String, or the 44 | * JSONObject.NULL object. 45 | *

46 | * The constructor can convert a JSON text into a Java object. The 47 | * toString method converts to JSON text. 48 | *

49 | * A get method returns a value if one can be found, and throws an 50 | * exception if one cannot be found. An opt method returns a 51 | * default value instead of throwing an exception, and so is useful for 52 | * obtaining optional values. 53 | *

54 | * The generic get() and opt() methods return an 55 | * object which you can cast or query for type. There are also typed 56 | * get and opt methods that do type checking and type 57 | * coercion for you. 58 | *

59 | * The texts produced by the toString methods strictly conform to 60 | * JSON syntax rules. The constructors are more forgiving in the texts they will 61 | * accept: 62 | *

78 | * 79 | * @author JSON.org 80 | * @version 2012-04-20 81 | */ 82 | public class JSONArray { 83 | 84 | 85 | /** 86 | * The arrayList where the JSONArray's properties are kept. 87 | */ 88 | private final ArrayList myArrayList; 89 | 90 | 91 | /** 92 | * Construct an empty JSONArray. 93 | */ 94 | public JSONArray() { 95 | this.myArrayList = new ArrayList(); 96 | } 97 | 98 | /** 99 | * Construct a JSONArray from a JSONTokener. 100 | * @param x A JSONTokener 101 | * @throws JSONException If there is a syntax error. 102 | */ 103 | public JSONArray(JSONTokener x) throws JSONException { 104 | this(); 105 | if (x.nextClean() != '[') { 106 | throw x.syntaxError("A JSONArray text must start with '['"); 107 | } 108 | if (x.nextClean() != ']') { 109 | x.back(); 110 | for (;;) { 111 | if (x.nextClean() == ',') { 112 | x.back(); 113 | this.myArrayList.add(JSONObject.NULL); 114 | } else { 115 | x.back(); 116 | this.myArrayList.add(x.nextValue()); 117 | } 118 | switch (x.nextClean()) { 119 | case ';': 120 | case ',': 121 | if (x.nextClean() == ']') { 122 | return; 123 | } 124 | x.back(); 125 | break; 126 | case ']': 127 | return; 128 | default: 129 | throw x.syntaxError("Expected a ',' or ']'"); 130 | } 131 | } 132 | } 133 | } 134 | 135 | 136 | /** 137 | * Construct a JSONArray from a source JSON text. 138 | * @param source A string that begins with 139 | * [ (left bracket) 140 | * and ends with ] (right bracket). 141 | * @throws JSONException If there is a syntax error. 142 | */ 143 | public JSONArray(String source) throws JSONException { 144 | this(new JSONTokener(source)); 145 | } 146 | 147 | 148 | /** 149 | * Construct a JSONArray from a Collection. 150 | * @param collection A Collection. 151 | */ 152 | public JSONArray(Collection collection) { 153 | this.myArrayList = new ArrayList(); 154 | if (collection != null) { 155 | Iterator iter = collection.iterator(); 156 | while (iter.hasNext()) { 157 | this.myArrayList.add(JSONObject.wrap(iter.next())); 158 | } 159 | } 160 | } 161 | 162 | 163 | /** 164 | * Construct a JSONArray from an array 165 | * @throws JSONException If not an array. 166 | */ 167 | public JSONArray(Object array) throws JSONException { 168 | this(); 169 | if (array.getClass().isArray()) { 170 | int length = Array.getLength(array); 171 | for (int i = 0; i < length; i += 1) { 172 | this.put(JSONObject.wrap(Array.get(array, i))); 173 | } 174 | } else { 175 | throw new JSONException( 176 | "JSONArray initial value should be a string or collection or array."); 177 | } 178 | } 179 | 180 | 181 | /** 182 | * Get the object value associated with an index. 183 | * @param index 184 | * The index must be between 0 and length() - 1. 185 | * @return An object value. 186 | * @throws JSONException If there is no value for the index. 187 | */ 188 | public Object get(int index) throws JSONException { 189 | Object object = this.opt(index); 190 | if (object == null) { 191 | throw new JSONException("JSONArray[" + index + "] not found."); 192 | } 193 | return object; 194 | } 195 | 196 | 197 | /** 198 | * Get the boolean value associated with an index. 199 | * The string values "true" and "false" are converted to boolean. 200 | * 201 | * @param index The index must be between 0 and length() - 1. 202 | * @return The truth. 203 | * @throws JSONException If there is no value for the index or if the 204 | * value is not convertible to boolean. 205 | */ 206 | public boolean getBoolean(int index) throws JSONException { 207 | Object object = this.get(index); 208 | if (object.equals(Boolean.FALSE) || 209 | (object instanceof String && 210 | ((String)object).equalsIgnoreCase("false"))) { 211 | return false; 212 | } else if (object.equals(Boolean.TRUE) || 213 | (object instanceof String && 214 | ((String)object).equalsIgnoreCase("true"))) { 215 | return true; 216 | } 217 | throw new JSONException("JSONArray[" + index + "] is not a boolean."); 218 | } 219 | 220 | 221 | /** 222 | * Get the double value associated with an index. 223 | * 224 | * @param index The index must be between 0 and length() - 1. 225 | * @return The value. 226 | * @throws JSONException If the key is not found or if the value cannot 227 | * be converted to a number. 228 | */ 229 | public double getDouble(int index) throws JSONException { 230 | Object object = this.get(index); 231 | try { 232 | return object instanceof Number 233 | ? ((Number)object).doubleValue() 234 | : Double.parseDouble((String)object); 235 | } catch (Exception e) { 236 | throw new JSONException("JSONArray[" + index + 237 | "] is not a number."); 238 | } 239 | } 240 | 241 | 242 | /** 243 | * Get the int value associated with an index. 244 | * 245 | * @param index The index must be between 0 and length() - 1. 246 | * @return The value. 247 | * @throws JSONException If the key is not found or if the value is not a number. 248 | */ 249 | public int getInt(int index) throws JSONException { 250 | Object object = this.get(index); 251 | try { 252 | return object instanceof Number 253 | ? ((Number)object).intValue() 254 | : Integer.parseInt((String)object); 255 | } catch (Exception e) { 256 | throw new JSONException("JSONArray[" + index + 257 | "] is not a number."); 258 | } 259 | } 260 | 261 | 262 | /** 263 | * Get the JSONArray associated with an index. 264 | * @param index The index must be between 0 and length() - 1. 265 | * @return A JSONArray value. 266 | * @throws JSONException If there is no value for the index. or if the 267 | * value is not a JSONArray 268 | */ 269 | public JSONArray getJSONArray(int index) throws JSONException { 270 | Object object = this.get(index); 271 | if (object instanceof JSONArray) { 272 | return (JSONArray)object; 273 | } 274 | throw new JSONException("JSONArray[" + index + 275 | "] is not a JSONArray."); 276 | } 277 | 278 | 279 | /** 280 | * Get the JSONObject associated with an index. 281 | * @param index subscript 282 | * @return A JSONObject value. 283 | * @throws JSONException If there is no value for the index or if the 284 | * value is not a JSONObject 285 | */ 286 | public JSONObject getJSONObject(int index) throws JSONException { 287 | Object object = this.get(index); 288 | if (object instanceof JSONObject) { 289 | return (JSONObject)object; 290 | } 291 | throw new JSONException("JSONArray[" + index + 292 | "] is not a JSONObject."); 293 | } 294 | 295 | 296 | /** 297 | * Get the long value associated with an index. 298 | * 299 | * @param index The index must be between 0 and length() - 1. 300 | * @return The value. 301 | * @throws JSONException If the key is not found or if the value cannot 302 | * be converted to a number. 303 | */ 304 | public long getLong(int index) throws JSONException { 305 | Object object = this.get(index); 306 | try { 307 | return object instanceof Number 308 | ? ((Number)object).longValue() 309 | : Long.parseLong((String)object); 310 | } catch (Exception e) { 311 | throw new JSONException("JSONArray[" + index + 312 | "] is not a number."); 313 | } 314 | } 315 | 316 | 317 | /** 318 | * Get the string associated with an index. 319 | * @param index The index must be between 0 and length() - 1. 320 | * @return A string value. 321 | * @throws JSONException If there is no string value for the index. 322 | */ 323 | public String getString(int index) throws JSONException { 324 | Object object = this.get(index); 325 | if (object instanceof String) { 326 | return (String)object; 327 | } 328 | throw new JSONException("JSONArray[" + index + "] not a string."); 329 | } 330 | 331 | 332 | /** 333 | * Determine if the value is null. 334 | * @param index The index must be between 0 and length() - 1. 335 | * @return true if the value at the index is null, or if there is no value. 336 | */ 337 | public boolean isNull(int index) { 338 | return JSONObject.NULL.equals(this.opt(index)); 339 | } 340 | 341 | 342 | /** 343 | * Make a string from the contents of this JSONArray. The 344 | * separator string is inserted between each element. 345 | * Warning: This method assumes that the data structure is acyclical. 346 | * @param separator A string that will be inserted between the elements. 347 | * @return a string. 348 | * @throws JSONException If the array contains an invalid number. 349 | */ 350 | public String join(String separator) throws JSONException { 351 | int len = this.length(); 352 | StringBuffer sb = new StringBuffer(); 353 | 354 | for (int i = 0; i < len; i += 1) { 355 | if (i > 0) { 356 | sb.append(separator); 357 | } 358 | sb.append(JSONObject.valueToString(this.myArrayList.get(i))); 359 | } 360 | return sb.toString(); 361 | } 362 | 363 | 364 | /** 365 | * Get the number of elements in the JSONArray, included nulls. 366 | * 367 | * @return The length (or size). 368 | */ 369 | public int length() { 370 | return this.myArrayList.size(); 371 | } 372 | 373 | 374 | /** 375 | * Get the optional object value associated with an index. 376 | * @param index The index must be between 0 and length() - 1. 377 | * @return An object value, or null if there is no 378 | * object at that index. 379 | */ 380 | public Object opt(int index) { 381 | return (index < 0 || index >= this.length()) 382 | ? null 383 | : this.myArrayList.get(index); 384 | } 385 | 386 | 387 | /** 388 | * Get the optional boolean value associated with an index. 389 | * It returns false if there is no value at that index, 390 | * or if the value is not Boolean.TRUE or the String "true". 391 | * 392 | * @param index The index must be between 0 and length() - 1. 393 | * @return The truth. 394 | */ 395 | public boolean optBoolean(int index) { 396 | return this.optBoolean(index, false); 397 | } 398 | 399 | 400 | /** 401 | * Get the optional boolean value associated with an index. 402 | * It returns the defaultValue if there is no value at that index or if 403 | * it is not a Boolean or the String "true" or "false" (case insensitive). 404 | * 405 | * @param index The index must be between 0 and length() - 1. 406 | * @param defaultValue A boolean default. 407 | * @return The truth. 408 | */ 409 | public boolean optBoolean(int index, boolean defaultValue) { 410 | try { 411 | return this.getBoolean(index); 412 | } catch (Exception e) { 413 | return defaultValue; 414 | } 415 | } 416 | 417 | 418 | /** 419 | * Get the optional double value associated with an index. 420 | * NaN is returned if there is no value for the index, 421 | * or if the value is not a number and cannot be converted to a number. 422 | * 423 | * @param index The index must be between 0 and length() - 1. 424 | * @return The value. 425 | */ 426 | public double optDouble(int index) { 427 | return this.optDouble(index, Double.NaN); 428 | } 429 | 430 | 431 | /** 432 | * Get the optional double value associated with an index. 433 | * The defaultValue is returned if there is no value for the index, 434 | * or if the value is not a number and cannot be converted to a number. 435 | * 436 | * @param index subscript 437 | * @param defaultValue The default value. 438 | * @return The value. 439 | */ 440 | public double optDouble(int index, double defaultValue) { 441 | try { 442 | return this.getDouble(index); 443 | } catch (Exception e) { 444 | return defaultValue; 445 | } 446 | } 447 | 448 | 449 | /** 450 | * Get the optional int value associated with an index. 451 | * Zero is returned if there is no value for the index, 452 | * or if the value is not a number and cannot be converted to a number. 453 | * 454 | * @param index The index must be between 0 and length() - 1. 455 | * @return The value. 456 | */ 457 | public int optInt(int index) { 458 | return this.optInt(index, 0); 459 | } 460 | 461 | 462 | /** 463 | * Get the optional int value associated with an index. 464 | * The defaultValue is returned if there is no value for the index, 465 | * or if the value is not a number and cannot be converted to a number. 466 | * @param index The index must be between 0 and length() - 1. 467 | * @param defaultValue The default value. 468 | * @return The value. 469 | */ 470 | public int optInt(int index, int defaultValue) { 471 | try { 472 | return this.getInt(index); 473 | } catch (Exception e) { 474 | return defaultValue; 475 | } 476 | } 477 | 478 | 479 | /** 480 | * Get the optional JSONArray associated with an index. 481 | * @param index subscript 482 | * @return A JSONArray value, or null if the index has no value, 483 | * or if the value is not a JSONArray. 484 | */ 485 | public JSONArray optJSONArray(int index) { 486 | Object o = this.opt(index); 487 | return o instanceof JSONArray ? (JSONArray)o : null; 488 | } 489 | 490 | 491 | /** 492 | * Get the optional JSONObject associated with an index. 493 | * Null is returned if the key is not found, or null if the index has 494 | * no value, or if the value is not a JSONObject. 495 | * 496 | * @param index The index must be between 0 and length() - 1. 497 | * @return A JSONObject value. 498 | */ 499 | public JSONObject optJSONObject(int index) { 500 | Object o = this.opt(index); 501 | return o instanceof JSONObject ? (JSONObject)o : null; 502 | } 503 | 504 | 505 | /** 506 | * Get the optional long value associated with an index. 507 | * Zero is returned if there is no value for the index, 508 | * or if the value is not a number and cannot be converted to a number. 509 | * 510 | * @param index The index must be between 0 and length() - 1. 511 | * @return The value. 512 | */ 513 | public long optLong(int index) { 514 | return this.optLong(index, 0); 515 | } 516 | 517 | 518 | /** 519 | * Get the optional long value associated with an index. 520 | * The defaultValue is returned if there is no value for the index, 521 | * or if the value is not a number and cannot be converted to a number. 522 | * @param index The index must be between 0 and length() - 1. 523 | * @param defaultValue The default value. 524 | * @return The value. 525 | */ 526 | public long optLong(int index, long defaultValue) { 527 | try { 528 | return this.getLong(index); 529 | } catch (Exception e) { 530 | return defaultValue; 531 | } 532 | } 533 | 534 | 535 | /** 536 | * Get the optional string value associated with an index. It returns an 537 | * empty string if there is no value at that index. If the value 538 | * is not a string and is not null, then it is coverted to a string. 539 | * 540 | * @param index The index must be between 0 and length() - 1. 541 | * @return A String value. 542 | */ 543 | public String optString(int index) { 544 | return this.optString(index, ""); 545 | } 546 | 547 | 548 | /** 549 | * Get the optional string associated with an index. 550 | * The defaultValue is returned if the key is not found. 551 | * 552 | * @param index The index must be between 0 and length() - 1. 553 | * @param defaultValue The default value. 554 | * @return A String value. 555 | */ 556 | public String optString(int index, String defaultValue) { 557 | Object object = this.opt(index); 558 | return JSONObject.NULL.equals(object) 559 | ? defaultValue : object 560 | .toString(); 561 | } 562 | 563 | 564 | /** 565 | * Append a boolean value. This increases the array's length by one. 566 | * 567 | * @param value A boolean value. 568 | * @return this. 569 | */ 570 | public JSONArray put(boolean value) { 571 | this.put(value ? Boolean.TRUE : Boolean.FALSE); 572 | return this; 573 | } 574 | 575 | 576 | /** 577 | * Put a value in the JSONArray, where the value will be a 578 | * JSONArray which is produced from a Collection. 579 | * @param value A Collection value. 580 | * @return this. 581 | */ 582 | public JSONArray put(Collection value) { 583 | this.put(new JSONArray(value)); 584 | return this; 585 | } 586 | 587 | 588 | /** 589 | * Append a double value. This increases the array's length by one. 590 | * 591 | * @param value A double value. 592 | * @throws JSONException if the value is not finite. 593 | * @return this. 594 | */ 595 | public JSONArray put(double value) throws JSONException { 596 | Double d = new Double(value); 597 | JSONObject.testValidity(d); 598 | this.put(d); 599 | return this; 600 | } 601 | 602 | 603 | /** 604 | * Append an int value. This increases the array's length by one. 605 | * 606 | * @param value An int value. 607 | * @return this. 608 | */ 609 | public JSONArray put(int value) { 610 | this.put(new Integer(value)); 611 | return this; 612 | } 613 | 614 | 615 | /** 616 | * Append an long value. This increases the array's length by one. 617 | * 618 | * @param value A long value. 619 | * @return this. 620 | */ 621 | public JSONArray put(long value) { 622 | this.put(new Long(value)); 623 | return this; 624 | } 625 | 626 | 627 | /** 628 | * Put a value in the JSONArray, where the value will be a 629 | * JSONObject which is produced from a Map. 630 | * @param value A Map value. 631 | * @return this. 632 | */ 633 | public JSONArray put(Map value) { 634 | this.put(new JSONObject(value)); 635 | return this; 636 | } 637 | 638 | 639 | /** 640 | * Append an object value. This increases the array's length by one. 641 | * @param value An object value. The value should be a 642 | * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the 643 | * JSONObject.NULL object. 644 | * @return this. 645 | */ 646 | public JSONArray put(Object value) { 647 | this.myArrayList.add(value); 648 | return this; 649 | } 650 | 651 | 652 | /** 653 | * Put or replace a boolean value in the JSONArray. If the index is greater 654 | * than the length of the JSONArray, then null elements will be added as 655 | * necessary to pad it out. 656 | * @param index The subscript. 657 | * @param value A boolean value. 658 | * @return this. 659 | * @throws JSONException If the index is negative. 660 | */ 661 | public JSONArray put(int index, boolean value) throws JSONException { 662 | this.put(index, value ? Boolean.TRUE : Boolean.FALSE); 663 | return this; 664 | } 665 | 666 | 667 | /** 668 | * Put a value in the JSONArray, where the value will be a 669 | * JSONArray which is produced from a Collection. 670 | * @param index The subscript. 671 | * @param value A Collection value. 672 | * @return this. 673 | * @throws JSONException If the index is negative or if the value is 674 | * not finite. 675 | */ 676 | public JSONArray put(int index, Collection value) throws JSONException { 677 | this.put(index, new JSONArray(value)); 678 | return this; 679 | } 680 | 681 | 682 | /** 683 | * Put or replace a double value. If the index is greater than the length of 684 | * the JSONArray, then null elements will be added as necessary to pad 685 | * it out. 686 | * @param index The subscript. 687 | * @param value A double value. 688 | * @return this. 689 | * @throws JSONException If the index is negative or if the value is 690 | * not finite. 691 | */ 692 | public JSONArray put(int index, double value) throws JSONException { 693 | this.put(index, new Double(value)); 694 | return this; 695 | } 696 | 697 | 698 | /** 699 | * Put or replace an int value. If the index is greater than the length of 700 | * the JSONArray, then null elements will be added as necessary to pad 701 | * it out. 702 | * @param index The subscript. 703 | * @param value An int value. 704 | * @return this. 705 | * @throws JSONException If the index is negative. 706 | */ 707 | public JSONArray put(int index, int value) throws JSONException { 708 | this.put(index, new Integer(value)); 709 | return this; 710 | } 711 | 712 | 713 | /** 714 | * Put or replace a long value. If the index is greater than the length of 715 | * the JSONArray, then null elements will be added as necessary to pad 716 | * it out. 717 | * @param index The subscript. 718 | * @param value A long value. 719 | * @return this. 720 | * @throws JSONException If the index is negative. 721 | */ 722 | public JSONArray put(int index, long value) throws JSONException { 723 | this.put(index, new Long(value)); 724 | return this; 725 | } 726 | 727 | 728 | /** 729 | * Put a value in the JSONArray, where the value will be a 730 | * JSONObject that is produced from a Map. 731 | * @param index The subscript. 732 | * @param value The Map value. 733 | * @return this. 734 | * @throws JSONException If the index is negative or if the the value is 735 | * an invalid number. 736 | */ 737 | public JSONArray put(int index, Map value) throws JSONException { 738 | this.put(index, new JSONObject(value)); 739 | return this; 740 | } 741 | 742 | 743 | /** 744 | * Put or replace an object value in the JSONArray. If the index is greater 745 | * than the length of the JSONArray, then null elements will be added as 746 | * necessary to pad it out. 747 | * @param index The subscript. 748 | * @param value The value to put into the array. The value should be a 749 | * Boolean, Double, Integer, JSONArray, JSONObject, Long, or String, or the 750 | * JSONObject.NULL object. 751 | * @return this. 752 | * @throws JSONException If the index is negative or if the the value is 753 | * an invalid number. 754 | */ 755 | public JSONArray put(int index, Object value) throws JSONException { 756 | JSONObject.testValidity(value); 757 | if (index < 0) { 758 | throw new JSONException("JSONArray[" + index + "] not found."); 759 | } 760 | if (index < this.length()) { 761 | this.myArrayList.set(index, value); 762 | } else { 763 | while (index != this.length()) { 764 | this.put(JSONObject.NULL); 765 | } 766 | this.put(value); 767 | } 768 | return this; 769 | } 770 | 771 | 772 | /** 773 | * Remove an index and close the hole. 774 | * @param index The index of the element to be removed. 775 | * @return The value that was associated with the index, 776 | * or null if there was no value. 777 | */ 778 | public Object remove(int index) { 779 | Object o = this.opt(index); 780 | this.myArrayList.remove(index); 781 | return o; 782 | } 783 | 784 | 785 | /** 786 | * Produce a JSONObject by combining a JSONArray of names with the values 787 | * of this JSONArray. 788 | * @param names A JSONArray containing a list of key strings. These will be 789 | * paired with the values. 790 | * @return A JSONObject, or null if there are no names or if this JSONArray 791 | * has no values. 792 | * @throws JSONException If any of the names are null. 793 | */ 794 | public JSONObject toJSONObject(JSONArray names) throws JSONException { 795 | if (names == null || names.length() == 0 || this.length() == 0) { 796 | return null; 797 | } 798 | JSONObject jo = new JSONObject(); 799 | for (int i = 0; i < names.length(); i += 1) { 800 | jo.put(names.getString(i), this.opt(i)); 801 | } 802 | return jo; 803 | } 804 | 805 | 806 | /** 807 | * Make a JSON text of this JSONArray. For compactness, no 808 | * unnecessary whitespace is added. If it is not possible to produce a 809 | * syntactically correct JSON text then null will be returned instead. This 810 | * could occur if the array contains an invalid number. 811 | *

812 | * Warning: This method assumes that the data structure is acyclical. 813 | * 814 | * @return a printable, displayable, transmittable 815 | * representation of the array. 816 | */ 817 | public String toString() { 818 | try { 819 | return '[' + this.join(",") + ']'; 820 | } catch (Exception e) { 821 | return null; 822 | } 823 | } 824 | 825 | 826 | /** 827 | * Make a prettyprinted JSON text of this JSONArray. 828 | * Warning: This method assumes that the data structure is acyclical. 829 | * @param indentFactor The number of spaces to add to each level of 830 | * indentation. 831 | * @return a printable, displayable, transmittable 832 | * representation of the object, beginning 833 | * with [ (left bracket) and ending 834 | * with ] (right bracket). 835 | * @throws JSONException 836 | */ 837 | public String toString(int indentFactor) throws JSONException { 838 | StringWriter sw = new StringWriter(); 839 | synchronized (sw.getBuffer()) { 840 | return this.write(sw, indentFactor, 0).toString(); 841 | } 842 | } 843 | 844 | /** 845 | * Write the contents of the JSONArray as JSON text to a writer. For 846 | * compactness, no whitespace is added. 847 | *

848 | * Warning: This method assumes that the data structure is acyclical. 849 | * 850 | * @return The writer. 851 | * @throws JSONException 852 | */ 853 | public Writer write(Writer writer) throws JSONException { 854 | return this.write(writer, 0, 0); 855 | } 856 | 857 | /** 858 | * Write the contents of the JSONArray as JSON text to a writer. For 859 | * compactness, no whitespace is added. 860 | *

861 | * Warning: This method assumes that the data structure is acyclical. 862 | * 863 | * @param indentFactor 864 | * The number of spaces to add to each level of indentation. 865 | * @param indent 866 | * The indention of the top level. 867 | * @return The writer. 868 | * @throws JSONException 869 | */ 870 | Writer write(Writer writer, int indentFactor, int indent) 871 | throws JSONException { 872 | try { 873 | boolean commanate = false; 874 | int length = this.length(); 875 | writer.write('['); 876 | 877 | if (length == 1) { 878 | JSONObject.writeValue(writer, this.myArrayList.get(0), 879 | indentFactor, indent); 880 | } else if (length != 0) { 881 | final int newindent = indent + indentFactor; 882 | 883 | for (int i = 0; i < length; i += 1) { 884 | if (commanate) { 885 | writer.write(','); 886 | } 887 | if (indentFactor > 0) { 888 | writer.write('\n'); 889 | } 890 | JSONObject.indent(writer, newindent); 891 | JSONObject.writeValue(writer, this.myArrayList.get(i), 892 | indentFactor, newindent); 893 | commanate = true; 894 | } 895 | if (indentFactor > 0) { 896 | writer.write('\n'); 897 | } 898 | JSONObject.indent(writer, indent); 899 | } 900 | writer.write(']'); 901 | return writer; 902 | } catch (IOException e) { 903 | throw new JSONException(e); 904 | } 905 | } 906 | } 907 | -------------------------------------------------------------------------------- /src/main/java/org/json/JSONException.java: -------------------------------------------------------------------------------- 1 | package org.json; 2 | 3 | /** 4 | * The JSONException is thrown by the JSON.org classes when things are amiss. 5 | * @author JSON.org 6 | * @version 2010-12-24 7 | */ 8 | public class JSONException extends Exception { 9 | private static final long serialVersionUID = 0; 10 | private Throwable cause; 11 | 12 | /** 13 | * Constructs a JSONException with an explanatory message. 14 | * @param message Detail about the reason for the exception. 15 | */ 16 | public JSONException(String message) { 17 | super(message); 18 | } 19 | 20 | public JSONException(Throwable cause) { 21 | super(cause.getMessage()); 22 | this.cause = cause; 23 | } 24 | 25 | public Throwable getCause() { 26 | return this.cause; 27 | } 28 | } -------------------------------------------------------------------------------- /src/main/java/org/json/JSONString.java: -------------------------------------------------------------------------------- 1 | package org.json; 2 | /** 3 | * The JSONString interface allows a toJSONString() 4 | * method so that a class can change the behavior of 5 | * JSONObject.toString(), JSONArray.toString(), 6 | * and JSONWriter.value(Object). The 7 | * toJSONString method will be used instead of the default behavior 8 | * of using the Object's toString() method and quoting the result. 9 | */ 10 | public interface JSONString { 11 | /** 12 | * The toJSONString method allows a class to produce its own JSON 13 | * serialization. 14 | * 15 | * @return A strictly syntactically correct JSON text. 16 | */ 17 | public String toJSONString(); 18 | } -------------------------------------------------------------------------------- /src/main/java/org/json/JSONTokener.java: -------------------------------------------------------------------------------- 1 | package org.json; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.IOException; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.io.Reader; 8 | import java.io.StringReader; 9 | 10 | /* 11 | Copyright (c) 2002 JSON.org 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all 21 | copies or substantial portions of the Software. 22 | 23 | The Software shall be used for Good, not Evil. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | */ 33 | 34 | /** 35 | * A JSONTokener takes a source string and extracts characters and tokens from 36 | * it. It is used by the JSONObject and JSONArray constructors to parse 37 | * JSON source strings. 38 | * @author JSON.org 39 | * @version 2012-02-16 40 | */ 41 | public class JSONTokener { 42 | 43 | private long character; 44 | private boolean eof; 45 | private long index; 46 | private long line; 47 | private char previous; 48 | private Reader reader; 49 | private boolean usePrevious; 50 | 51 | 52 | /** 53 | * Construct a JSONTokener from a Reader. 54 | * 55 | * @param reader A reader. 56 | */ 57 | public JSONTokener(Reader reader) { 58 | this.reader = reader.markSupported() 59 | ? reader 60 | : new BufferedReader(reader); 61 | this.eof = false; 62 | this.usePrevious = false; 63 | this.previous = 0; 64 | this.index = 0; 65 | this.character = 1; 66 | this.line = 1; 67 | } 68 | 69 | 70 | /** 71 | * Construct a JSONTokener from an InputStream. 72 | */ 73 | public JSONTokener(InputStream inputStream) throws JSONException { 74 | this(new InputStreamReader(inputStream)); 75 | } 76 | 77 | 78 | /** 79 | * Construct a JSONTokener from a string. 80 | * 81 | * @param s A source string. 82 | */ 83 | public JSONTokener(String s) { 84 | this(new StringReader(s)); 85 | } 86 | 87 | 88 | /** 89 | * Back up one character. This provides a sort of lookahead capability, 90 | * so that you can test for a digit or letter before attempting to parse 91 | * the next number or identifier. 92 | */ 93 | public void back() throws JSONException { 94 | if (this.usePrevious || this.index <= 0) { 95 | throw new JSONException("Stepping back two steps is not supported"); 96 | } 97 | this.index -= 1; 98 | this.character -= 1; 99 | this.usePrevious = true; 100 | this.eof = false; 101 | } 102 | 103 | 104 | /** 105 | * Get the hex value of a character (base16). 106 | * @param c A character between '0' and '9' or between 'A' and 'F' or 107 | * between 'a' and 'f'. 108 | * @return An int between 0 and 15, or -1 if c was not a hex digit. 109 | */ 110 | public static int dehexchar(char c) { 111 | if (c >= '0' && c <= '9') { 112 | return c - '0'; 113 | } 114 | if (c >= 'A' && c <= 'F') { 115 | return c - ('A' - 10); 116 | } 117 | if (c >= 'a' && c <= 'f') { 118 | return c - ('a' - 10); 119 | } 120 | return -1; 121 | } 122 | 123 | public boolean end() { 124 | return this.eof && !this.usePrevious; 125 | } 126 | 127 | 128 | /** 129 | * Determine if the source string still contains characters that next() 130 | * can consume. 131 | * @return true if not yet at the end of the source. 132 | */ 133 | public boolean more() throws JSONException { 134 | this.next(); 135 | if (this.end()) { 136 | return false; 137 | } 138 | this.back(); 139 | return true; 140 | } 141 | 142 | 143 | /** 144 | * Get the next character in the source string. 145 | * 146 | * @return The next character, or 0 if past the end of the source string. 147 | */ 148 | public char next() throws JSONException { 149 | int c; 150 | if (this.usePrevious) { 151 | this.usePrevious = false; 152 | c = this.previous; 153 | } else { 154 | try { 155 | c = this.reader.read(); 156 | } catch (IOException exception) { 157 | throw new JSONException(exception); 158 | } 159 | 160 | if (c <= 0) { // End of stream 161 | this.eof = true; 162 | c = 0; 163 | } 164 | } 165 | this.index += 1; 166 | if (this.previous == '\r') { 167 | this.line += 1; 168 | this.character = c == '\n' ? 0 : 1; 169 | } else if (c == '\n') { 170 | this.line += 1; 171 | this.character = 0; 172 | } else { 173 | this.character += 1; 174 | } 175 | this.previous = (char) c; 176 | return this.previous; 177 | } 178 | 179 | 180 | /** 181 | * Consume the next character, and check that it matches a specified 182 | * character. 183 | * @param c The character to match. 184 | * @return The character. 185 | * @throws JSONException if the character does not match. 186 | */ 187 | public char next(char c) throws JSONException { 188 | char n = this.next(); 189 | if (n != c) { 190 | throw this.syntaxError("Expected '" + c + "' and instead saw '" + 191 | n + "'"); 192 | } 193 | return n; 194 | } 195 | 196 | 197 | /** 198 | * Get the next n characters. 199 | * 200 | * @param n The number of characters to take. 201 | * @return A string of n characters. 202 | * @throws JSONException 203 | * Substring bounds error if there are not 204 | * n characters remaining in the source string. 205 | */ 206 | public String next(int n) throws JSONException { 207 | if (n == 0) { 208 | return ""; 209 | } 210 | 211 | char[] chars = new char[n]; 212 | int pos = 0; 213 | 214 | while (pos < n) { 215 | chars[pos] = this.next(); 216 | if (this.end()) { 217 | throw this.syntaxError("Substring bounds error"); 218 | } 219 | pos += 1; 220 | } 221 | return new String(chars); 222 | } 223 | 224 | 225 | /** 226 | * Get the next char in the string, skipping whitespace. 227 | * @throws JSONException 228 | * @return A character, or 0 if there are no more characters. 229 | */ 230 | public char nextClean() throws JSONException { 231 | for (;;) { 232 | char c = this.next(); 233 | if (c == 0 || c > ' ') { 234 | return c; 235 | } 236 | } 237 | } 238 | 239 | 240 | /** 241 | * Return the characters up to the next close quote character. 242 | * Backslash processing is done. The formal JSON format does not 243 | * allow strings in single quotes, but an implementation is allowed to 244 | * accept them. 245 | * @param quote The quoting character, either 246 | * " (double quote) or 247 | * ' (single quote). 248 | * @return A String. 249 | * @throws JSONException Unterminated string. 250 | */ 251 | public String nextString(char quote) throws JSONException { 252 | char c; 253 | StringBuffer sb = new StringBuffer(); 254 | for (;;) { 255 | c = this.next(); 256 | switch (c) { 257 | case 0: 258 | case '\n': 259 | case '\r': 260 | throw this.syntaxError("Unterminated string"); 261 | case '\\': 262 | c = this.next(); 263 | switch (c) { 264 | case 'b': 265 | sb.append('\b'); 266 | break; 267 | case 't': 268 | sb.append('\t'); 269 | break; 270 | case 'n': 271 | sb.append('\n'); 272 | break; 273 | case 'f': 274 | sb.append('\f'); 275 | break; 276 | case 'r': 277 | sb.append('\r'); 278 | break; 279 | case 'u': 280 | sb.append((char)Integer.parseInt(this.next(4), 16)); 281 | break; 282 | case '"': 283 | case '\'': 284 | case '\\': 285 | case '/': 286 | sb.append(c); 287 | break; 288 | default: 289 | throw this.syntaxError("Illegal escape."); 290 | } 291 | break; 292 | default: 293 | if (c == quote) { 294 | return sb.toString(); 295 | } 296 | sb.append(c); 297 | } 298 | } 299 | } 300 | 301 | 302 | /** 303 | * Get the text up but not including the specified character or the 304 | * end of line, whichever comes first. 305 | * @param delimiter A delimiter character. 306 | * @return A string. 307 | */ 308 | public String nextTo(char delimiter) throws JSONException { 309 | StringBuffer sb = new StringBuffer(); 310 | for (;;) { 311 | char c = this.next(); 312 | if (c == delimiter || c == 0 || c == '\n' || c == '\r') { 313 | if (c != 0) { 314 | this.back(); 315 | } 316 | return sb.toString().trim(); 317 | } 318 | sb.append(c); 319 | } 320 | } 321 | 322 | 323 | /** 324 | * Get the text up but not including one of the specified delimiter 325 | * characters or the end of line, whichever comes first. 326 | * @param delimiters A set of delimiter characters. 327 | * @return A string, trimmed. 328 | */ 329 | public String nextTo(String delimiters) throws JSONException { 330 | char c; 331 | StringBuffer sb = new StringBuffer(); 332 | for (;;) { 333 | c = this.next(); 334 | if (delimiters.indexOf(c) >= 0 || c == 0 || 335 | c == '\n' || c == '\r') { 336 | if (c != 0) { 337 | this.back(); 338 | } 339 | return sb.toString().trim(); 340 | } 341 | sb.append(c); 342 | } 343 | } 344 | 345 | 346 | /** 347 | * Get the next value. The value can be a Boolean, Double, Integer, 348 | * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object. 349 | * @throws JSONException If syntax error. 350 | * 351 | * @return An object. 352 | */ 353 | public Object nextValue() throws JSONException { 354 | char c = this.nextClean(); 355 | String string; 356 | 357 | switch (c) { 358 | case '"': 359 | case '\'': 360 | return this.nextString(c); 361 | case '{': 362 | this.back(); 363 | return new JSONObject(this); 364 | case '[': 365 | this.back(); 366 | return new JSONArray(this); 367 | } 368 | 369 | /* 370 | * Handle unquoted text. This could be the values true, false, or 371 | * null, or it can be a number. An implementation (such as this one) 372 | * is allowed to also accept non-standard forms. 373 | * 374 | * Accumulate characters until we reach the end of the text or a 375 | * formatting character. 376 | */ 377 | 378 | StringBuffer sb = new StringBuffer(); 379 | while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) { 380 | sb.append(c); 381 | c = this.next(); 382 | } 383 | this.back(); 384 | 385 | string = sb.toString().trim(); 386 | if ("".equals(string)) { 387 | throw this.syntaxError("Missing value"); 388 | } 389 | return JSONObject.stringToValue(string); 390 | } 391 | 392 | 393 | /** 394 | * Skip characters until the next character is the requested character. 395 | * If the requested character is not found, no characters are skipped. 396 | * @param to A character to skip to. 397 | * @return The requested character, or zero if the requested character 398 | * is not found. 399 | */ 400 | public char skipTo(char to) throws JSONException { 401 | char c; 402 | try { 403 | long startIndex = this.index; 404 | long startCharacter = this.character; 405 | long startLine = this.line; 406 | this.reader.mark(1000000); 407 | do { 408 | c = this.next(); 409 | if (c == 0) { 410 | this.reader.reset(); 411 | this.index = startIndex; 412 | this.character = startCharacter; 413 | this.line = startLine; 414 | return c; 415 | } 416 | } while (c != to); 417 | } catch (IOException exc) { 418 | throw new JSONException(exc); 419 | } 420 | 421 | this.back(); 422 | return c; 423 | } 424 | 425 | 426 | /** 427 | * Make a JSONException to signal a syntax error. 428 | * 429 | * @param message The error message. 430 | * @return A JSONException object, suitable for throwing 431 | */ 432 | public JSONException syntaxError(String message) { 433 | return new JSONException(message + this.toString()); 434 | } 435 | 436 | 437 | /** 438 | * Make a printable string of this JSONTokener. 439 | * 440 | * @return " at {index} [character {character} line {line}]" 441 | */ 442 | public String toString() { 443 | return " at " + this.index + " [character " + this.character + " line " + 444 | this.line + "]"; 445 | } 446 | } 447 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/CategoryType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlAnyAttribute; 16 | import javax.xml.bind.annotation.XmlAttribute; 17 | import javax.xml.bind.annotation.XmlSchemaType; 18 | import javax.xml.bind.annotation.XmlType; 19 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 20 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 21 | import javax.xml.namespace.QName; 22 | 23 | 24 | /** 25 | * 26 | * The Atom cagegory construct is defined in section 4.2.2 of the format spec. 27 | * 28 | * 29 | *

Java class for categoryType complex type. 30 | * 31 | *

The following schema fragment specifies the expected content contained within this class. 32 | * 33 | *

 34 |  * <complexType name="categoryType">
 35 |  *   <complexContent>
 36 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 37 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 38 |  *       <attribute name="term" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
 39 |  *       <attribute name="scheme" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 40 |  *       <attribute name="label" type="{http://www.w3.org/2001/XMLSchema}string" />
 41 |  *       <anyAttribute namespace='##other'/>
 42 |  *     </restriction>
 43 |  *   </complexContent>
 44 |  * </complexType>
 45 |  * 
46 | * 47 | * 48 | */ 49 | @XmlAccessorType(XmlAccessType.FIELD) 50 | @XmlType(name = "categoryType") 51 | public class CategoryType { 52 | 53 | @XmlAttribute(name = "term", required = true) 54 | protected String term; 55 | @XmlAttribute(name = "scheme") 56 | @XmlSchemaType(name = "anyURI") 57 | protected String scheme; 58 | @XmlAttribute(name = "label") 59 | protected String label; 60 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 61 | @XmlSchemaType(name = "anyURI") 62 | protected String base; 63 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 64 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 65 | @XmlSchemaType(name = "language") 66 | protected String lang; 67 | @XmlAnyAttribute 68 | private Map otherAttributes = new HashMap(); 69 | 70 | /** 71 | * Gets the value of the term property. 72 | * 73 | * @return 74 | * possible object is 75 | * {@link String } 76 | * 77 | */ 78 | public String getTerm() { 79 | return term; 80 | } 81 | 82 | /** 83 | * Sets the value of the term property. 84 | * 85 | * @param value 86 | * allowed object is 87 | * {@link String } 88 | * 89 | */ 90 | public void setTerm(String value) { 91 | this.term = value; 92 | } 93 | 94 | /** 95 | * Gets the value of the scheme property. 96 | * 97 | * @return 98 | * possible object is 99 | * {@link String } 100 | * 101 | */ 102 | public String getScheme() { 103 | return scheme; 104 | } 105 | 106 | /** 107 | * Sets the value of the scheme property. 108 | * 109 | * @param value 110 | * allowed object is 111 | * {@link String } 112 | * 113 | */ 114 | public void setScheme(String value) { 115 | this.scheme = value; 116 | } 117 | 118 | /** 119 | * Gets the value of the label property. 120 | * 121 | * @return 122 | * possible object is 123 | * {@link String } 124 | * 125 | */ 126 | public String getLabel() { 127 | return label; 128 | } 129 | 130 | /** 131 | * Sets the value of the label property. 132 | * 133 | * @param value 134 | * allowed object is 135 | * {@link String } 136 | * 137 | */ 138 | public void setLabel(String value) { 139 | this.label = value; 140 | } 141 | 142 | /** 143 | * Gets the value of the base property. 144 | * 145 | * @return 146 | * possible object is 147 | * {@link String } 148 | * 149 | */ 150 | public String getBase() { 151 | return base; 152 | } 153 | 154 | /** 155 | * Sets the value of the base property. 156 | * 157 | * @param value 158 | * allowed object is 159 | * {@link String } 160 | * 161 | */ 162 | public void setBase(String value) { 163 | this.base = value; 164 | } 165 | 166 | /** 167 | * Gets the value of the lang property. 168 | * 169 | * @return 170 | * possible object is 171 | * {@link String } 172 | * 173 | */ 174 | public String getLang() { 175 | return lang; 176 | } 177 | 178 | /** 179 | * Sets the value of the lang property. 180 | * 181 | * @param value 182 | * allowed object is 183 | * {@link String } 184 | * 185 | */ 186 | public void setLang(String value) { 187 | this.lang = value; 188 | } 189 | 190 | /** 191 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 192 | * 193 | *

194 | * the map is keyed by the name of the attribute and 195 | * the value is the string value of the attribute. 196 | * 197 | * the map returned by this method is live, and you can add new attribute 198 | * by updating the map directly. Because of this design, there's no setter. 199 | * 200 | * 201 | * @return 202 | * always non-null 203 | */ 204 | public Map getOtherAttributes() { 205 | return otherAttributes; 206 | } 207 | 208 | } 209 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/ContentType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | import javax.xml.bind.annotation.XmlAccessType; 16 | import javax.xml.bind.annotation.XmlAccessorType; 17 | import javax.xml.bind.annotation.XmlAnyAttribute; 18 | import javax.xml.bind.annotation.XmlAnyElement; 19 | import javax.xml.bind.annotation.XmlAttribute; 20 | import javax.xml.bind.annotation.XmlMixed; 21 | import javax.xml.bind.annotation.XmlSchemaType; 22 | import javax.xml.bind.annotation.XmlType; 23 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 24 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 25 | import javax.xml.namespace.QName; 26 | 27 | 28 | /** 29 | * 30 | * The Atom content construct is defined in section 4.1.3 of the format spec. 31 | * 32 | * 33 | *

Java class for contentType complex type. 34 | * 35 | *

The following schema fragment specifies the expected content contained within this class. 36 | * 37 | *

 38 |  * <complexType name="contentType">
 39 |  *   <complexContent>
 40 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 41 |  *       <sequence>
 42 |  *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
 43 |  *       </sequence>
 44 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 45 |  *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
 46 |  *       <attribute name="src" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 47 |  *       <anyAttribute namespace='##other'/>
 48 |  *     </restriction>
 49 |  *   </complexContent>
 50 |  * </complexType>
 51 |  * 
52 | * 53 | * 54 | */ 55 | @XmlAccessorType(XmlAccessType.FIELD) 56 | @XmlType(name = "contentType", propOrder = { 57 | "content" 58 | }) 59 | public class ContentType { 60 | 61 | @XmlMixed 62 | @XmlAnyElement(lax = true) 63 | protected List content; 64 | @XmlAttribute(name = "type") 65 | protected String type; 66 | @XmlAttribute(name = "src") 67 | @XmlSchemaType(name = "anyURI") 68 | protected String src; 69 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 70 | @XmlSchemaType(name = "anyURI") 71 | protected String base; 72 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 73 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 74 | @XmlSchemaType(name = "language") 75 | protected String lang; 76 | @XmlAnyAttribute 77 | private Map otherAttributes = new HashMap(); 78 | 79 | /** 80 | * 81 | * The Atom content construct is defined in section 4.1.3 of the format spec. 82 | * Gets the value of the content property. 83 | * 84 | *

85 | * This accessor method returns a reference to the live list, 86 | * not a snapshot. Therefore any modification you make to the 87 | * returned list will be present inside the JAXB object. 88 | * This is why there is not a set method for the content property. 89 | * 90 | *

91 | * For example, to add a new item, do as follows: 92 | *

 93 |      *    getContent().add(newItem);
 94 |      * 
95 | * 96 | * 97 | *

98 | * Objects of the following type(s) are allowed in the list 99 | * {@link String } 100 | * {@link Object } 101 | * 102 | * 103 | */ 104 | public List getContent() { 105 | if (content == null) { 106 | content = new ArrayList(); 107 | } 108 | return this.content; 109 | } 110 | 111 | /** 112 | * Gets the value of the type property. 113 | * 114 | * @return 115 | * possible object is 116 | * {@link String } 117 | * 118 | */ 119 | public String getType() { 120 | return type; 121 | } 122 | 123 | /** 124 | * Sets the value of the type property. 125 | * 126 | * @param value 127 | * allowed object is 128 | * {@link String } 129 | * 130 | */ 131 | public void setType(String value) { 132 | this.type = value; 133 | } 134 | 135 | /** 136 | * Gets the value of the src property. 137 | * 138 | * @return 139 | * possible object is 140 | * {@link String } 141 | * 142 | */ 143 | public String getSrc() { 144 | return src; 145 | } 146 | 147 | /** 148 | * Sets the value of the src property. 149 | * 150 | * @param value 151 | * allowed object is 152 | * {@link String } 153 | * 154 | */ 155 | public void setSrc(String value) { 156 | this.src = value; 157 | } 158 | 159 | /** 160 | * Gets the value of the base property. 161 | * 162 | * @return 163 | * possible object is 164 | * {@link String } 165 | * 166 | */ 167 | public String getBase() { 168 | return base; 169 | } 170 | 171 | /** 172 | * Sets the value of the base property. 173 | * 174 | * @param value 175 | * allowed object is 176 | * {@link String } 177 | * 178 | */ 179 | public void setBase(String value) { 180 | this.base = value; 181 | } 182 | 183 | /** 184 | * Gets the value of the lang property. 185 | * 186 | * @return 187 | * possible object is 188 | * {@link String } 189 | * 190 | */ 191 | public String getLang() { 192 | return lang; 193 | } 194 | 195 | /** 196 | * Sets the value of the lang property. 197 | * 198 | * @param value 199 | * allowed object is 200 | * {@link String } 201 | * 202 | */ 203 | public void setLang(String value) { 204 | this.lang = value; 205 | } 206 | 207 | /** 208 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 209 | * 210 | *

211 | * the map is keyed by the name of the attribute and 212 | * the value is the string value of the attribute. 213 | * 214 | * the map returned by this method is live, and you can add new attribute 215 | * by updating the map directly. Because of this design, there's no setter. 216 | * 217 | * 218 | * @return 219 | * always non-null 220 | */ 221 | public Map getOtherAttributes() { 222 | return otherAttributes; 223 | } 224 | 225 | } 226 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/DateTimeType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlAnyAttribute; 16 | import javax.xml.bind.annotation.XmlAttribute; 17 | import javax.xml.bind.annotation.XmlSchemaType; 18 | import javax.xml.bind.annotation.XmlType; 19 | import javax.xml.bind.annotation.XmlValue; 20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 22 | import javax.xml.datatype.XMLGregorianCalendar; 23 | import javax.xml.namespace.QName; 24 | 25 | 26 | /** 27 | *

Java class for dateTimeType complex type. 28 | * 29 | *

The following schema fragment specifies the expected content contained within this class. 30 | * 31 | *

 32 |  * <complexType name="dateTimeType">
 33 |  *   <simpleContent>
 34 |  *     <extension base="<http://www.w3.org/2001/XMLSchema>dateTime">
 35 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 36 |  *       <anyAttribute namespace='##other'/>
 37 |  *     </extension>
 38 |  *   </simpleContent>
 39 |  * </complexType>
 40 |  * 
41 | * 42 | * 43 | */ 44 | @XmlAccessorType(XmlAccessType.FIELD) 45 | @XmlType(name = "dateTimeType", propOrder = { 46 | "value" 47 | }) 48 | public class DateTimeType { 49 | 50 | @XmlValue 51 | @XmlSchemaType(name = "dateTime") 52 | protected XMLGregorianCalendar value; 53 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 54 | @XmlSchemaType(name = "anyURI") 55 | protected String base; 56 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 57 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 58 | @XmlSchemaType(name = "language") 59 | protected String lang; 60 | @XmlAnyAttribute 61 | private Map otherAttributes = new HashMap(); 62 | 63 | /** 64 | * Gets the value of the value property. 65 | * 66 | * @return 67 | * possible object is 68 | * {@link XMLGregorianCalendar } 69 | * 70 | */ 71 | public XMLGregorianCalendar getValue() { 72 | return value; 73 | } 74 | 75 | /** 76 | * Sets the value of the value property. 77 | * 78 | * @param value 79 | * allowed object is 80 | * {@link XMLGregorianCalendar } 81 | * 82 | */ 83 | public void setValue(XMLGregorianCalendar value) { 84 | this.value = value; 85 | } 86 | 87 | /** 88 | * Gets the value of the base property. 89 | * 90 | * @return 91 | * possible object is 92 | * {@link String } 93 | * 94 | */ 95 | public String getBase() { 96 | return base; 97 | } 98 | 99 | /** 100 | * Sets the value of the base property. 101 | * 102 | * @param value 103 | * allowed object is 104 | * {@link String } 105 | * 106 | */ 107 | public void setBase(String value) { 108 | this.base = value; 109 | } 110 | 111 | /** 112 | * Gets the value of the lang property. 113 | * 114 | * @return 115 | * possible object is 116 | * {@link String } 117 | * 118 | */ 119 | public String getLang() { 120 | return lang; 121 | } 122 | 123 | /** 124 | * Sets the value of the lang property. 125 | * 126 | * @param value 127 | * allowed object is 128 | * {@link String } 129 | * 130 | */ 131 | public void setLang(String value) { 132 | this.lang = value; 133 | } 134 | 135 | /** 136 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 137 | * 138 | *

139 | * the map is keyed by the name of the attribute and 140 | * the value is the string value of the attribute. 141 | * 142 | * the map returned by this method is live, and you can add new attribute 143 | * by updating the map directly. Because of this design, there's no setter. 144 | * 145 | * 146 | * @return 147 | * always non-null 148 | */ 149 | public Map getOtherAttributes() { 150 | return otherAttributes; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/EntryType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | import javax.xml.bind.JAXBElement; 16 | import javax.xml.bind.annotation.XmlAccessType; 17 | import javax.xml.bind.annotation.XmlAccessorType; 18 | import javax.xml.bind.annotation.XmlAnyAttribute; 19 | import javax.xml.bind.annotation.XmlAnyElement; 20 | import javax.xml.bind.annotation.XmlAttribute; 21 | import javax.xml.bind.annotation.XmlElementRef; 22 | import javax.xml.bind.annotation.XmlElementRefs; 23 | import javax.xml.bind.annotation.XmlSchemaType; 24 | import javax.xml.bind.annotation.XmlType; 25 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 26 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 27 | import javax.xml.namespace.QName; 28 | 29 | 30 | /** 31 | * 32 | * The Atom entry construct is defined in section 4.1.2 of the format spec. 33 | * 34 | * 35 | *

Java class for entryType complex type. 36 | * 37 | *

The following schema fragment specifies the expected content contained within this class. 38 | * 39 | *

 40 |  * <complexType name="entryType">
 41 |  *   <complexContent>
 42 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 43 |  *       <choice maxOccurs="unbounded">
 44 |  *         <element name="author" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
 45 |  *         <element name="category" type="{http://www.w3.org/2005/Atom}categoryType" maxOccurs="unbounded" minOccurs="0"/>
 46 |  *         <element name="content" type="{http://www.w3.org/2005/Atom}contentType" minOccurs="0"/>
 47 |  *         <element name="contributor" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
 48 |  *         <element name="id" type="{http://www.w3.org/2005/Atom}idType"/>
 49 |  *         <element name="link" type="{http://www.w3.org/2005/Atom}linkType" maxOccurs="unbounded" minOccurs="0"/>
 50 |  *         <element name="published" type="{http://www.w3.org/2005/Atom}dateTimeType" minOccurs="0"/>
 51 |  *         <element name="rights" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 52 |  *         <element name="source" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 53 |  *         <element name="summary" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 54 |  *         <element name="title" type="{http://www.w3.org/2005/Atom}textType"/>
 55 |  *         <element name="updated" type="{http://www.w3.org/2005/Atom}dateTimeType"/>
 56 |  *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
 57 |  *       </choice>
 58 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 59 |  *       <anyAttribute namespace='##other'/>
 60 |  *     </restriction>
 61 |  *   </complexContent>
 62 |  * </complexType>
 63 |  * 
64 | * 65 | * 66 | */ 67 | @XmlAccessorType(XmlAccessType.FIELD) 68 | @XmlType(name = "entryType", propOrder = { 69 | "authorOrCategoryOrContent" 70 | }) 71 | public class EntryType { 72 | 73 | @XmlElementRefs({ 74 | @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 75 | @XmlElementRef(name = "source", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 76 | @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 77 | @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 78 | @XmlElementRef(name = "summary", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 79 | @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 80 | @XmlElementRef(name = "content", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 81 | @XmlElementRef(name = "published", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 82 | @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 83 | @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 84 | @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 85 | @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false) 86 | }) 87 | @XmlAnyElement(lax = true) 88 | protected List authorOrCategoryOrContent; 89 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 90 | @XmlSchemaType(name = "anyURI") 91 | protected String base; 92 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 93 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 94 | @XmlSchemaType(name = "language") 95 | protected String lang; 96 | @XmlAnyAttribute 97 | private Map otherAttributes = new HashMap(); 98 | 99 | /** 100 | * Gets the value of the authorOrCategoryOrContent property. 101 | * 102 | *

103 | * This accessor method returns a reference to the live list, 104 | * not a snapshot. Therefore any modification you make to the 105 | * returned list will be present inside the JAXB object. 106 | * This is why there is not a set method for the authorOrCategoryOrContent property. 107 | * 108 | *

109 | * For example, to add a new item, do as follows: 110 | *

111 |      *    getAuthorOrCategoryOrContent().add(newItem);
112 |      * 
113 | * 114 | * 115 | *

116 | * Objects of the following type(s) are allowed in the list 117 | * {@link JAXBElement }{@code <}{@link PersonType }{@code >} 118 | * {@link JAXBElement }{@code <}{@link PersonType }{@code >} 119 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 120 | * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} 121 | * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} 122 | * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} 123 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 124 | * {@link Object } 125 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 126 | * {@link JAXBElement }{@code <}{@link LinkType }{@code >} 127 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 128 | * {@link JAXBElement }{@code <}{@link ContentType }{@code >} 129 | * {@link JAXBElement }{@code <}{@link IdType }{@code >} 130 | * 131 | * 132 | */ 133 | public List getAuthorOrCategoryOrContent() { 134 | if (authorOrCategoryOrContent == null) { 135 | authorOrCategoryOrContent = new ArrayList(); 136 | } 137 | return this.authorOrCategoryOrContent; 138 | } 139 | 140 | /** 141 | * Gets the value of the base property. 142 | * 143 | * @return 144 | * possible object is 145 | * {@link String } 146 | * 147 | */ 148 | public String getBase() { 149 | return base; 150 | } 151 | 152 | /** 153 | * Sets the value of the base property. 154 | * 155 | * @param value 156 | * allowed object is 157 | * {@link String } 158 | * 159 | */ 160 | public void setBase(String value) { 161 | this.base = value; 162 | } 163 | 164 | /** 165 | * Gets the value of the lang property. 166 | * 167 | * @return 168 | * possible object is 169 | * {@link String } 170 | * 171 | */ 172 | public String getLang() { 173 | return lang; 174 | } 175 | 176 | /** 177 | * Sets the value of the lang property. 178 | * 179 | * @param value 180 | * allowed object is 181 | * {@link String } 182 | * 183 | */ 184 | public void setLang(String value) { 185 | this.lang = value; 186 | } 187 | 188 | /** 189 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 190 | * 191 | *

192 | * the map is keyed by the name of the attribute and 193 | * the value is the string value of the attribute. 194 | * 195 | * the map returned by this method is live, and you can add new attribute 196 | * by updating the map directly. Because of this design, there's no setter. 197 | * 198 | * 199 | * @return 200 | * always non-null 201 | */ 202 | public Map getOtherAttributes() { 203 | return otherAttributes; 204 | } 205 | 206 | } 207 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/FeedType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | import javax.xml.bind.JAXBElement; 16 | import javax.xml.bind.annotation.XmlAccessType; 17 | import javax.xml.bind.annotation.XmlAccessorType; 18 | import javax.xml.bind.annotation.XmlAnyAttribute; 19 | import javax.xml.bind.annotation.XmlAnyElement; 20 | import javax.xml.bind.annotation.XmlAttribute; 21 | import javax.xml.bind.annotation.XmlElementRef; 22 | import javax.xml.bind.annotation.XmlElementRefs; 23 | import javax.xml.bind.annotation.XmlSchemaType; 24 | import javax.xml.bind.annotation.XmlType; 25 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 26 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 27 | import javax.xml.namespace.QName; 28 | 29 | 30 | /** 31 | * 32 | * The Atom feed construct is defined in section 4.1.1 of the format spec. 33 | * 34 | * 35 | *

Java class for feedType complex type. 36 | * 37 | *

The following schema fragment specifies the expected content contained within this class. 38 | * 39 | *

 40 |  * <complexType name="feedType">
 41 |  *   <complexContent>
 42 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 43 |  *       <choice maxOccurs="unbounded" minOccurs="3">
 44 |  *         <element name="author" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
 45 |  *         <element name="category" type="{http://www.w3.org/2005/Atom}categoryType" maxOccurs="unbounded" minOccurs="0"/>
 46 |  *         <element name="contributor" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
 47 |  *         <element name="generator" type="{http://www.w3.org/2005/Atom}generatorType" minOccurs="0"/>
 48 |  *         <element name="icon" type="{http://www.w3.org/2005/Atom}iconType" minOccurs="0"/>
 49 |  *         <element name="id" type="{http://www.w3.org/2005/Atom}idType"/>
 50 |  *         <element name="link" type="{http://www.w3.org/2005/Atom}linkType" maxOccurs="unbounded" minOccurs="0"/>
 51 |  *         <element name="logo" type="{http://www.w3.org/2005/Atom}logoType" minOccurs="0"/>
 52 |  *         <element name="rights" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 53 |  *         <element name="subtitle" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 54 |  *         <element name="title" type="{http://www.w3.org/2005/Atom}textType"/>
 55 |  *         <element name="updated" type="{http://www.w3.org/2005/Atom}dateTimeType"/>
 56 |  *         <element name="entry" type="{http://www.w3.org/2005/Atom}entryType" maxOccurs="unbounded" minOccurs="0"/>
 57 |  *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
 58 |  *       </choice>
 59 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 60 |  *       <anyAttribute namespace='##other'/>
 61 |  *     </restriction>
 62 |  *   </complexContent>
 63 |  * </complexType>
 64 |  * 
65 | * 66 | * 67 | */ 68 | @XmlAccessorType(XmlAccessType.FIELD) 69 | @XmlType(name = "feedType", propOrder = { 70 | "authorOrCategoryOrContributor" 71 | }) 72 | public class FeedType { 73 | 74 | @XmlElementRefs({ 75 | @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 76 | @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 77 | @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 78 | @XmlElementRef(name = "entry", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 79 | @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 80 | @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 81 | @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 82 | @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 83 | @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 84 | @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 85 | @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 86 | @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 87 | @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false) 88 | }) 89 | @XmlAnyElement(lax = true) 90 | protected List authorOrCategoryOrContributor; 91 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 92 | @XmlSchemaType(name = "anyURI") 93 | protected String base; 94 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 95 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 96 | @XmlSchemaType(name = "language") 97 | protected String lang; 98 | @XmlAnyAttribute 99 | private Map otherAttributes = new HashMap(); 100 | 101 | /** 102 | * Gets the value of the authorOrCategoryOrContributor property. 103 | * 104 | *

105 | * This accessor method returns a reference to the live list, 106 | * not a snapshot. Therefore any modification you make to the 107 | * returned list will be present inside the JAXB object. 108 | * This is why there is not a set method for the authorOrCategoryOrContributor property. 109 | * 110 | *

111 | * For example, to add a new item, do as follows: 112 | *

113 |      *    getAuthorOrCategoryOrContributor().add(newItem);
114 |      * 
115 | * 116 | * 117 | *

118 | * Objects of the following type(s) are allowed in the list 119 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 120 | * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} 121 | * {@link JAXBElement }{@code <}{@link PersonType }{@code >} 122 | * {@link JAXBElement }{@code <}{@link EntryType }{@code >} 123 | * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} 124 | * {@link JAXBElement }{@code <}{@link LogoType }{@code >} 125 | * {@link JAXBElement }{@code <}{@link IdType }{@code >} 126 | * {@link JAXBElement }{@code <}{@link LinkType }{@code >} 127 | * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} 128 | * {@link JAXBElement }{@code <}{@link IconType }{@code >} 129 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 130 | * {@link Object } 131 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 132 | * {@link JAXBElement }{@code <}{@link PersonType }{@code >} 133 | * 134 | * 135 | */ 136 | public List getAuthorOrCategoryOrContributor() { 137 | if (authorOrCategoryOrContributor == null) { 138 | authorOrCategoryOrContributor = new ArrayList(); 139 | } 140 | return this.authorOrCategoryOrContributor; 141 | } 142 | 143 | /** 144 | * Gets the value of the base property. 145 | * 146 | * @return 147 | * possible object is 148 | * {@link String } 149 | * 150 | */ 151 | public String getBase() { 152 | return base; 153 | } 154 | 155 | /** 156 | * Sets the value of the base property. 157 | * 158 | * @param value 159 | * allowed object is 160 | * {@link String } 161 | * 162 | */ 163 | public void setBase(String value) { 164 | this.base = value; 165 | } 166 | 167 | /** 168 | * Gets the value of the lang property. 169 | * 170 | * @return 171 | * possible object is 172 | * {@link String } 173 | * 174 | */ 175 | public String getLang() { 176 | return lang; 177 | } 178 | 179 | /** 180 | * Sets the value of the lang property. 181 | * 182 | * @param value 183 | * allowed object is 184 | * {@link String } 185 | * 186 | */ 187 | public void setLang(String value) { 188 | this.lang = value; 189 | } 190 | 191 | /** 192 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 193 | * 194 | *

195 | * the map is keyed by the name of the attribute and 196 | * the value is the string value of the attribute. 197 | * 198 | * the map returned by this method is live, and you can add new attribute 199 | * by updating the map directly. Because of this design, there's no setter. 200 | * 201 | * 202 | * @return 203 | * always non-null 204 | */ 205 | public Map getOtherAttributes() { 206 | return otherAttributes; 207 | } 208 | 209 | } 210 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/GeneratorType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlAnyAttribute; 16 | import javax.xml.bind.annotation.XmlAttribute; 17 | import javax.xml.bind.annotation.XmlSchemaType; 18 | import javax.xml.bind.annotation.XmlType; 19 | import javax.xml.bind.annotation.XmlValue; 20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 22 | import javax.xml.namespace.QName; 23 | 24 | 25 | /** 26 | * 27 | * The Atom generator element is defined in section 4.2.4 of the format spec. 28 | * 29 | * 30 | *

Java class for generatorType complex type. 31 | * 32 | *

The following schema fragment specifies the expected content contained within this class. 33 | * 34 | *

 35 |  * <complexType name="generatorType">
 36 |  *   <simpleContent>
 37 |  *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
 38 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 39 |  *       <attribute name="uri" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 40 |  *       <attribute name="version" type="{http://www.w3.org/2001/XMLSchema}string" />
 41 |  *       <anyAttribute namespace='##other'/>
 42 |  *     </extension>
 43 |  *   </simpleContent>
 44 |  * </complexType>
 45 |  * 
46 | * 47 | * 48 | */ 49 | @XmlAccessorType(XmlAccessType.FIELD) 50 | @XmlType(name = "generatorType", propOrder = { 51 | "value" 52 | }) 53 | public class GeneratorType { 54 | 55 | @XmlValue 56 | protected String value; 57 | @XmlAttribute(name = "uri") 58 | @XmlSchemaType(name = "anyURI") 59 | protected String uri; 60 | @XmlAttribute(name = "version") 61 | protected String version; 62 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 63 | @XmlSchemaType(name = "anyURI") 64 | protected String base; 65 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 66 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 67 | @XmlSchemaType(name = "language") 68 | protected String lang; 69 | @XmlAnyAttribute 70 | private Map otherAttributes = new HashMap(); 71 | 72 | /** 73 | * Gets the value of the value property. 74 | * 75 | * @return 76 | * possible object is 77 | * {@link String } 78 | * 79 | */ 80 | public String getValue() { 81 | return value; 82 | } 83 | 84 | /** 85 | * Sets the value of the value property. 86 | * 87 | * @param value 88 | * allowed object is 89 | * {@link String } 90 | * 91 | */ 92 | public void setValue(String value) { 93 | this.value = value; 94 | } 95 | 96 | /** 97 | * Gets the value of the uri property. 98 | * 99 | * @return 100 | * possible object is 101 | * {@link String } 102 | * 103 | */ 104 | public String getUri() { 105 | return uri; 106 | } 107 | 108 | /** 109 | * Sets the value of the uri property. 110 | * 111 | * @param value 112 | * allowed object is 113 | * {@link String } 114 | * 115 | */ 116 | public void setUri(String value) { 117 | this.uri = value; 118 | } 119 | 120 | /** 121 | * Gets the value of the version property. 122 | * 123 | * @return 124 | * possible object is 125 | * {@link String } 126 | * 127 | */ 128 | public String getVersion() { 129 | return version; 130 | } 131 | 132 | /** 133 | * Sets the value of the version property. 134 | * 135 | * @param value 136 | * allowed object is 137 | * {@link String } 138 | * 139 | */ 140 | public void setVersion(String value) { 141 | this.version = value; 142 | } 143 | 144 | /** 145 | * Gets the value of the base property. 146 | * 147 | * @return 148 | * possible object is 149 | * {@link String } 150 | * 151 | */ 152 | public String getBase() { 153 | return base; 154 | } 155 | 156 | /** 157 | * Sets the value of the base property. 158 | * 159 | * @param value 160 | * allowed object is 161 | * {@link String } 162 | * 163 | */ 164 | public void setBase(String value) { 165 | this.base = value; 166 | } 167 | 168 | /** 169 | * Gets the value of the lang property. 170 | * 171 | * @return 172 | * possible object is 173 | * {@link String } 174 | * 175 | */ 176 | public String getLang() { 177 | return lang; 178 | } 179 | 180 | /** 181 | * Sets the value of the lang property. 182 | * 183 | * @param value 184 | * allowed object is 185 | * {@link String } 186 | * 187 | */ 188 | public void setLang(String value) { 189 | this.lang = value; 190 | } 191 | 192 | /** 193 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 194 | * 195 | *

196 | * the map is keyed by the name of the attribute and 197 | * the value is the string value of the attribute. 198 | * 199 | * the map returned by this method is live, and you can add new attribute 200 | * by updating the map directly. Because of this design, there's no setter. 201 | * 202 | * 203 | * @return 204 | * always non-null 205 | */ 206 | public Map getOtherAttributes() { 207 | return otherAttributes; 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/IconType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlAnyAttribute; 16 | import javax.xml.bind.annotation.XmlAttribute; 17 | import javax.xml.bind.annotation.XmlSchemaType; 18 | import javax.xml.bind.annotation.XmlType; 19 | import javax.xml.bind.annotation.XmlValue; 20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 22 | import javax.xml.namespace.QName; 23 | 24 | 25 | /** 26 | * 27 | * The Atom icon construct is defined in section 4.2.5 of the format spec. 28 | * 29 | * 30 | *

Java class for iconType complex type. 31 | * 32 | *

The following schema fragment specifies the expected content contained within this class. 33 | * 34 | *

 35 |  * <complexType name="iconType">
 36 |  *   <simpleContent>
 37 |  *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
 38 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 39 |  *       <anyAttribute namespace='##other'/>
 40 |  *     </extension>
 41 |  *   </simpleContent>
 42 |  * </complexType>
 43 |  * 
44 | * 45 | * 46 | */ 47 | @XmlAccessorType(XmlAccessType.FIELD) 48 | @XmlType(name = "iconType", propOrder = { 49 | "value" 50 | }) 51 | public class IconType { 52 | 53 | @XmlValue 54 | @XmlSchemaType(name = "anyURI") 55 | protected String value; 56 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 57 | @XmlSchemaType(name = "anyURI") 58 | protected String base; 59 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 60 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 61 | @XmlSchemaType(name = "language") 62 | protected String lang; 63 | @XmlAnyAttribute 64 | private Map otherAttributes = new HashMap(); 65 | 66 | /** 67 | * Gets the value of the value property. 68 | * 69 | * @return 70 | * possible object is 71 | * {@link String } 72 | * 73 | */ 74 | public String getValue() { 75 | return value; 76 | } 77 | 78 | /** 79 | * Sets the value of the value property. 80 | * 81 | * @param value 82 | * allowed object is 83 | * {@link String } 84 | * 85 | */ 86 | public void setValue(String value) { 87 | this.value = value; 88 | } 89 | 90 | /** 91 | * Gets the value of the base property. 92 | * 93 | * @return 94 | * possible object is 95 | * {@link String } 96 | * 97 | */ 98 | public String getBase() { 99 | return base; 100 | } 101 | 102 | /** 103 | * Sets the value of the base property. 104 | * 105 | * @param value 106 | * allowed object is 107 | * {@link String } 108 | * 109 | */ 110 | public void setBase(String value) { 111 | this.base = value; 112 | } 113 | 114 | /** 115 | * Gets the value of the lang property. 116 | * 117 | * @return 118 | * possible object is 119 | * {@link String } 120 | * 121 | */ 122 | public String getLang() { 123 | return lang; 124 | } 125 | 126 | /** 127 | * Sets the value of the lang property. 128 | * 129 | * @param value 130 | * allowed object is 131 | * {@link String } 132 | * 133 | */ 134 | public void setLang(String value) { 135 | this.lang = value; 136 | } 137 | 138 | /** 139 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 140 | * 141 | *

142 | * the map is keyed by the name of the attribute and 143 | * the value is the string value of the attribute. 144 | * 145 | * the map returned by this method is live, and you can add new attribute 146 | * by updating the map directly. Because of this design, there's no setter. 147 | * 148 | * 149 | * @return 150 | * always non-null 151 | */ 152 | public Map getOtherAttributes() { 153 | return otherAttributes; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/IdType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlAnyAttribute; 16 | import javax.xml.bind.annotation.XmlAttribute; 17 | import javax.xml.bind.annotation.XmlSchemaType; 18 | import javax.xml.bind.annotation.XmlType; 19 | import javax.xml.bind.annotation.XmlValue; 20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 22 | import javax.xml.namespace.QName; 23 | 24 | 25 | /** 26 | * 27 | * The Atom id construct is defined in section 4.2.6 of the format spec. 28 | * 29 | * 30 | *

Java class for idType complex type. 31 | * 32 | *

The following schema fragment specifies the expected content contained within this class. 33 | * 34 | *

 35 |  * <complexType name="idType">
 36 |  *   <simpleContent>
 37 |  *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
 38 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 39 |  *       <anyAttribute namespace='##other'/>
 40 |  *     </extension>
 41 |  *   </simpleContent>
 42 |  * </complexType>
 43 |  * 
44 | * 45 | * 46 | */ 47 | @XmlAccessorType(XmlAccessType.FIELD) 48 | @XmlType(name = "idType", propOrder = { 49 | "value" 50 | }) 51 | public class IdType { 52 | 53 | @XmlValue 54 | @XmlSchemaType(name = "anyURI") 55 | protected String value; 56 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 57 | @XmlSchemaType(name = "anyURI") 58 | protected String base; 59 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 60 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 61 | @XmlSchemaType(name = "language") 62 | protected String lang; 63 | @XmlAnyAttribute 64 | private Map otherAttributes = new HashMap(); 65 | 66 | /** 67 | * Gets the value of the value property. 68 | * 69 | * @return 70 | * possible object is 71 | * {@link String } 72 | * 73 | */ 74 | public String getValue() { 75 | return value; 76 | } 77 | 78 | /** 79 | * Sets the value of the value property. 80 | * 81 | * @param value 82 | * allowed object is 83 | * {@link String } 84 | * 85 | */ 86 | public void setValue(String value) { 87 | this.value = value; 88 | } 89 | 90 | /** 91 | * Gets the value of the base property. 92 | * 93 | * @return 94 | * possible object is 95 | * {@link String } 96 | * 97 | */ 98 | public String getBase() { 99 | return base; 100 | } 101 | 102 | /** 103 | * Sets the value of the base property. 104 | * 105 | * @param value 106 | * allowed object is 107 | * {@link String } 108 | * 109 | */ 110 | public void setBase(String value) { 111 | this.base = value; 112 | } 113 | 114 | /** 115 | * Gets the value of the lang property. 116 | * 117 | * @return 118 | * possible object is 119 | * {@link String } 120 | * 121 | */ 122 | public String getLang() { 123 | return lang; 124 | } 125 | 126 | /** 127 | * Sets the value of the lang property. 128 | * 129 | * @param value 130 | * allowed object is 131 | * {@link String } 132 | * 133 | */ 134 | public void setLang(String value) { 135 | this.lang = value; 136 | } 137 | 138 | /** 139 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 140 | * 141 | *

142 | * the map is keyed by the name of the attribute and 143 | * the value is the string value of the attribute. 144 | * 145 | * the map returned by this method is live, and you can add new attribute 146 | * by updating the map directly. Because of this design, there's no setter. 147 | * 148 | * 149 | * @return 150 | * always non-null 151 | */ 152 | public Map getOtherAttributes() { 153 | return otherAttributes; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/LinkType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.math.BigInteger; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | import javax.xml.bind.annotation.XmlAccessType; 15 | import javax.xml.bind.annotation.XmlAccessorType; 16 | import javax.xml.bind.annotation.XmlAnyAttribute; 17 | import javax.xml.bind.annotation.XmlAttribute; 18 | import javax.xml.bind.annotation.XmlSchemaType; 19 | import javax.xml.bind.annotation.XmlType; 20 | import javax.xml.bind.annotation.XmlValue; 21 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 22 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 23 | import javax.xml.namespace.QName; 24 | 25 | 26 | /** 27 | * 28 | * The Atom link construct is defined in section 3.4 of the format spec. 29 | * 30 | * 31 | *

Java class for linkType complex type. 32 | * 33 | *

The following schema fragment specifies the expected content contained within this class. 34 | * 35 | *

 36 |  * <complexType name="linkType">
 37 |  *   <complexContent>
 38 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 39 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 40 |  *       <attribute name="href" use="required" type="{http://www.w3.org/2001/XMLSchema}anyURI" />
 41 |  *       <attribute name="rel" type="{http://www.w3.org/2001/XMLSchema}string" />
 42 |  *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
 43 |  *       <attribute name="hreflang" type="{http://www.w3.org/2001/XMLSchema}NMTOKEN" />
 44 |  *       <attribute name="title" type="{http://www.w3.org/2001/XMLSchema}string" />
 45 |  *       <attribute name="length" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
 46 |  *       <anyAttribute namespace='##other'/>
 47 |  *     </restriction>
 48 |  *   </complexContent>
 49 |  * </complexType>
 50 |  * 
51 | * 52 | * 53 | */ 54 | @XmlAccessorType(XmlAccessType.FIELD) 55 | @XmlType(name = "linkType", propOrder = { 56 | "content" 57 | }) 58 | public class LinkType { 59 | 60 | @XmlValue 61 | protected String content; 62 | @XmlAttribute(name = "href", required = true) 63 | @XmlSchemaType(name = "anyURI") 64 | protected String href; 65 | @XmlAttribute(name = "rel") 66 | protected String rel; 67 | @XmlAttribute(name = "type") 68 | protected String type; 69 | @XmlAttribute(name = "hreflang") 70 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 71 | @XmlSchemaType(name = "NMTOKEN") 72 | protected String hreflang; 73 | @XmlAttribute(name = "title") 74 | protected String title; 75 | @XmlAttribute(name = "length") 76 | @XmlSchemaType(name = "positiveInteger") 77 | protected BigInteger length; 78 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 79 | @XmlSchemaType(name = "anyURI") 80 | protected String base; 81 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 82 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 83 | @XmlSchemaType(name = "language") 84 | protected String lang; 85 | @XmlAnyAttribute 86 | private Map otherAttributes = new HashMap(); 87 | 88 | /** 89 | * 90 | * The Atom link construct is defined in section 3.4 of the format spec. 91 | * 92 | * 93 | * @return 94 | * possible object is 95 | * {@link String } 96 | * 97 | */ 98 | public String getContent() { 99 | return content; 100 | } 101 | 102 | /** 103 | * Sets the value of the content property. 104 | * 105 | * @param value 106 | * allowed object is 107 | * {@link String } 108 | * 109 | */ 110 | public void setContent(String value) { 111 | this.content = value; 112 | } 113 | 114 | /** 115 | * Gets the value of the href property. 116 | * 117 | * @return 118 | * possible object is 119 | * {@link String } 120 | * 121 | */ 122 | public String getHref() { 123 | return href; 124 | } 125 | 126 | /** 127 | * Sets the value of the href property. 128 | * 129 | * @param value 130 | * allowed object is 131 | * {@link String } 132 | * 133 | */ 134 | public void setHref(String value) { 135 | this.href = value; 136 | } 137 | 138 | /** 139 | * Gets the value of the rel property. 140 | * 141 | * @return 142 | * possible object is 143 | * {@link String } 144 | * 145 | */ 146 | public String getRel() { 147 | return rel; 148 | } 149 | 150 | /** 151 | * Sets the value of the rel property. 152 | * 153 | * @param value 154 | * allowed object is 155 | * {@link String } 156 | * 157 | */ 158 | public void setRel(String value) { 159 | this.rel = value; 160 | } 161 | 162 | /** 163 | * Gets the value of the type property. 164 | * 165 | * @return 166 | * possible object is 167 | * {@link String } 168 | * 169 | */ 170 | public String getType() { 171 | return type; 172 | } 173 | 174 | /** 175 | * Sets the value of the type property. 176 | * 177 | * @param value 178 | * allowed object is 179 | * {@link String } 180 | * 181 | */ 182 | public void setType(String value) { 183 | this.type = value; 184 | } 185 | 186 | /** 187 | * Gets the value of the hreflang property. 188 | * 189 | * @return 190 | * possible object is 191 | * {@link String } 192 | * 193 | */ 194 | public String getHreflang() { 195 | return hreflang; 196 | } 197 | 198 | /** 199 | * Sets the value of the hreflang property. 200 | * 201 | * @param value 202 | * allowed object is 203 | * {@link String } 204 | * 205 | */ 206 | public void setHreflang(String value) { 207 | this.hreflang = value; 208 | } 209 | 210 | /** 211 | * Gets the value of the title property. 212 | * 213 | * @return 214 | * possible object is 215 | * {@link String } 216 | * 217 | */ 218 | public String getTitle() { 219 | return title; 220 | } 221 | 222 | /** 223 | * Sets the value of the title property. 224 | * 225 | * @param value 226 | * allowed object is 227 | * {@link String } 228 | * 229 | */ 230 | public void setTitle(String value) { 231 | this.title = value; 232 | } 233 | 234 | /** 235 | * Gets the value of the length property. 236 | * 237 | * @return 238 | * possible object is 239 | * {@link BigInteger } 240 | * 241 | */ 242 | public BigInteger getLength() { 243 | return length; 244 | } 245 | 246 | /** 247 | * Sets the value of the length property. 248 | * 249 | * @param value 250 | * allowed object is 251 | * {@link BigInteger } 252 | * 253 | */ 254 | public void setLength(BigInteger value) { 255 | this.length = value; 256 | } 257 | 258 | /** 259 | * Gets the value of the base property. 260 | * 261 | * @return 262 | * possible object is 263 | * {@link String } 264 | * 265 | */ 266 | public String getBase() { 267 | return base; 268 | } 269 | 270 | /** 271 | * Sets the value of the base property. 272 | * 273 | * @param value 274 | * allowed object is 275 | * {@link String } 276 | * 277 | */ 278 | public void setBase(String value) { 279 | this.base = value; 280 | } 281 | 282 | /** 283 | * Gets the value of the lang property. 284 | * 285 | * @return 286 | * possible object is 287 | * {@link String } 288 | * 289 | */ 290 | public String getLang() { 291 | return lang; 292 | } 293 | 294 | /** 295 | * Sets the value of the lang property. 296 | * 297 | * @param value 298 | * allowed object is 299 | * {@link String } 300 | * 301 | */ 302 | public void setLang(String value) { 303 | this.lang = value; 304 | } 305 | 306 | /** 307 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 308 | * 309 | *

310 | * the map is keyed by the name of the attribute and 311 | * the value is the string value of the attribute. 312 | * 313 | * the map returned by this method is live, and you can add new attribute 314 | * by updating the map directly. Because of this design, there's no setter. 315 | * 316 | * 317 | * @return 318 | * always non-null 319 | */ 320 | public Map getOtherAttributes() { 321 | return otherAttributes; 322 | } 323 | 324 | } 325 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/LogoType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlAnyAttribute; 16 | import javax.xml.bind.annotation.XmlAttribute; 17 | import javax.xml.bind.annotation.XmlSchemaType; 18 | import javax.xml.bind.annotation.XmlType; 19 | import javax.xml.bind.annotation.XmlValue; 20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 22 | import javax.xml.namespace.QName; 23 | 24 | 25 | /** 26 | * 27 | * The Atom logo construct is defined in section 4.2.8 of the format spec. 28 | * 29 | * 30 | *

Java class for logoType complex type. 31 | * 32 | *

The following schema fragment specifies the expected content contained within this class. 33 | * 34 | *

 35 |  * <complexType name="logoType">
 36 |  *   <simpleContent>
 37 |  *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
 38 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 39 |  *       <anyAttribute namespace='##other'/>
 40 |  *     </extension>
 41 |  *   </simpleContent>
 42 |  * </complexType>
 43 |  * 
44 | * 45 | * 46 | */ 47 | @XmlAccessorType(XmlAccessType.FIELD) 48 | @XmlType(name = "logoType", propOrder = { 49 | "value" 50 | }) 51 | public class LogoType { 52 | 53 | @XmlValue 54 | @XmlSchemaType(name = "anyURI") 55 | protected String value; 56 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 57 | @XmlSchemaType(name = "anyURI") 58 | protected String base; 59 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 60 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 61 | @XmlSchemaType(name = "language") 62 | protected String lang; 63 | @XmlAnyAttribute 64 | private Map otherAttributes = new HashMap(); 65 | 66 | /** 67 | * Gets the value of the value property. 68 | * 69 | * @return 70 | * possible object is 71 | * {@link String } 72 | * 73 | */ 74 | public String getValue() { 75 | return value; 76 | } 77 | 78 | /** 79 | * Sets the value of the value property. 80 | * 81 | * @param value 82 | * allowed object is 83 | * {@link String } 84 | * 85 | */ 86 | public void setValue(String value) { 87 | this.value = value; 88 | } 89 | 90 | /** 91 | * Gets the value of the base property. 92 | * 93 | * @return 94 | * possible object is 95 | * {@link String } 96 | * 97 | */ 98 | public String getBase() { 99 | return base; 100 | } 101 | 102 | /** 103 | * Sets the value of the base property. 104 | * 105 | * @param value 106 | * allowed object is 107 | * {@link String } 108 | * 109 | */ 110 | public void setBase(String value) { 111 | this.base = value; 112 | } 113 | 114 | /** 115 | * Gets the value of the lang property. 116 | * 117 | * @return 118 | * possible object is 119 | * {@link String } 120 | * 121 | */ 122 | public String getLang() { 123 | return lang; 124 | } 125 | 126 | /** 127 | * Sets the value of the lang property. 128 | * 129 | * @param value 130 | * allowed object is 131 | * {@link String } 132 | * 133 | */ 134 | public void setLang(String value) { 135 | this.lang = value; 136 | } 137 | 138 | /** 139 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 140 | * 141 | *

142 | * the map is keyed by the name of the attribute and 143 | * the value is the string value of the attribute. 144 | * 145 | * the map returned by this method is live, and you can add new attribute 146 | * by updating the map directly. Because of this design, there's no setter. 147 | * 148 | * 149 | * @return 150 | * always non-null 151 | */ 152 | public Map getOtherAttributes() { 153 | return otherAttributes; 154 | } 155 | 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/ObjectFactory.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import javax.xml.bind.JAXBElement; 12 | import javax.xml.bind.annotation.XmlElementDecl; 13 | import javax.xml.bind.annotation.XmlRegistry; 14 | import javax.xml.bind.annotation.adapters.NormalizedStringAdapter; 15 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 16 | import javax.xml.namespace.QName; 17 | 18 | 19 | /** 20 | * This object contains factory methods for each 21 | * Java content interface and Java element interface 22 | * generated in the org.w3._2005.atom package. 23 | *

An ObjectFactory allows you to programatically 24 | * construct new instances of the Java representation 25 | * for XML content. The Java representation of XML 26 | * content can consist of schema derived interfaces 27 | * and classes representing the binding of schema 28 | * type definitions, element declarations and model 29 | * groups. Factory methods for each of these are 30 | * provided in this class. 31 | * 32 | */ 33 | @XmlRegistry 34 | public class ObjectFactory { 35 | 36 | private final static QName _PersonTypeName_QNAME = new QName("http://www.w3.org/2005/Atom", "name"); 37 | private final static QName _PersonTypeEmail_QNAME = new QName("http://www.w3.org/2005/Atom", "email"); 38 | private final static QName _PersonTypeUri_QNAME = new QName("http://www.w3.org/2005/Atom", "uri"); 39 | private final static QName _Entry_QNAME = new QName("http://www.w3.org/2005/Atom", "entry"); 40 | private final static QName _Feed_QNAME = new QName("http://www.w3.org/2005/Atom", "feed"); 41 | private final static QName _EntryTypeTitle_QNAME = new QName("http://www.w3.org/2005/Atom", "title"); 42 | private final static QName _EntryTypeCategory_QNAME = new QName("http://www.w3.org/2005/Atom", "category"); 43 | private final static QName _EntryTypeAuthor_QNAME = new QName("http://www.w3.org/2005/Atom", "author"); 44 | private final static QName _EntryTypeSummary_QNAME = new QName("http://www.w3.org/2005/Atom", "summary"); 45 | private final static QName _EntryTypeId_QNAME = new QName("http://www.w3.org/2005/Atom", "id"); 46 | private final static QName _EntryTypeContent_QNAME = new QName("http://www.w3.org/2005/Atom", "content"); 47 | private final static QName _EntryTypeLink_QNAME = new QName("http://www.w3.org/2005/Atom", "link"); 48 | private final static QName _EntryTypeContributor_QNAME = new QName("http://www.w3.org/2005/Atom", "contributor"); 49 | private final static QName _EntryTypeUpdated_QNAME = new QName("http://www.w3.org/2005/Atom", "updated"); 50 | private final static QName _EntryTypeSource_QNAME = new QName("http://www.w3.org/2005/Atom", "source"); 51 | private final static QName _EntryTypeRights_QNAME = new QName("http://www.w3.org/2005/Atom", "rights"); 52 | private final static QName _EntryTypePublished_QNAME = new QName("http://www.w3.org/2005/Atom", "published"); 53 | private final static QName _FeedTypeGenerator_QNAME = new QName("http://www.w3.org/2005/Atom", "generator"); 54 | private final static QName _FeedTypeSubtitle_QNAME = new QName("http://www.w3.org/2005/Atom", "subtitle"); 55 | private final static QName _FeedTypeIcon_QNAME = new QName("http://www.w3.org/2005/Atom", "icon"); 56 | private final static QName _FeedTypeLogo_QNAME = new QName("http://www.w3.org/2005/Atom", "logo"); 57 | 58 | /** 59 | * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.w3._2005.atom 60 | * 61 | */ 62 | public ObjectFactory() { 63 | } 64 | 65 | /** 66 | * Create an instance of {@link EntryType } 67 | * 68 | */ 69 | public EntryType createEntryType() { 70 | return new EntryType(); 71 | } 72 | 73 | /** 74 | * Create an instance of {@link FeedType } 75 | * 76 | */ 77 | public FeedType createFeedType() { 78 | return new FeedType(); 79 | } 80 | 81 | /** 82 | * Create an instance of {@link SourceType } 83 | * 84 | */ 85 | public SourceType createSourceType() { 86 | return new SourceType(); 87 | } 88 | 89 | /** 90 | * Create an instance of {@link IdType } 91 | * 92 | */ 93 | public IdType createIdType() { 94 | return new IdType(); 95 | } 96 | 97 | /** 98 | * Create an instance of {@link GeneratorType } 99 | * 100 | */ 101 | public GeneratorType createGeneratorType() { 102 | return new GeneratorType(); 103 | } 104 | 105 | /** 106 | * Create an instance of {@link CategoryType } 107 | * 108 | */ 109 | public CategoryType createCategoryType() { 110 | return new CategoryType(); 111 | } 112 | 113 | /** 114 | * Create an instance of {@link LinkType } 115 | * 116 | */ 117 | public LinkType createLinkType() { 118 | return new LinkType(); 119 | } 120 | 121 | /** 122 | * Create an instance of {@link UriType } 123 | * 124 | */ 125 | public UriType createUriType() { 126 | return new UriType(); 127 | } 128 | 129 | /** 130 | * Create an instance of {@link ContentType } 131 | * 132 | */ 133 | public ContentType createContentType() { 134 | return new ContentType(); 135 | } 136 | 137 | /** 138 | * Create an instance of {@link LogoType } 139 | * 140 | */ 141 | public LogoType createLogoType() { 142 | return new LogoType(); 143 | } 144 | 145 | /** 146 | * Create an instance of {@link DateTimeType } 147 | * 148 | */ 149 | public DateTimeType createDateTimeType() { 150 | return new DateTimeType(); 151 | } 152 | 153 | /** 154 | * Create an instance of {@link TextType } 155 | * 156 | */ 157 | public TextType createTextType() { 158 | return new TextType(); 159 | } 160 | 161 | /** 162 | * Create an instance of {@link PersonType } 163 | * 164 | */ 165 | public PersonType createPersonType() { 166 | return new PersonType(); 167 | } 168 | 169 | /** 170 | * Create an instance of {@link IconType } 171 | * 172 | */ 173 | public IconType createIconType() { 174 | return new IconType(); 175 | } 176 | 177 | /** 178 | * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} 179 | * 180 | */ 181 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "name", scope = PersonType.class) 182 | public JAXBElement createPersonTypeName(String value) { 183 | return new JAXBElement(_PersonTypeName_QNAME, String.class, PersonType.class, value); 184 | } 185 | 186 | /** 187 | * Create an instance of {@link JAXBElement }{@code <}{@link String }{@code >}} 188 | * 189 | */ 190 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "email", scope = PersonType.class) 191 | @XmlJavaTypeAdapter(NormalizedStringAdapter.class) 192 | public JAXBElement createPersonTypeEmail(String value) { 193 | return new JAXBElement(_PersonTypeEmail_QNAME, String.class, PersonType.class, value); 194 | } 195 | 196 | /** 197 | * Create an instance of {@link JAXBElement }{@code <}{@link UriType }{@code >}} 198 | * 199 | */ 200 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "uri", scope = PersonType.class) 201 | public JAXBElement createPersonTypeUri(UriType value) { 202 | return new JAXBElement(_PersonTypeUri_QNAME, UriType.class, PersonType.class, value); 203 | } 204 | 205 | /** 206 | * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} 207 | * 208 | */ 209 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry") 210 | public JAXBElement createEntry(EntryType value) { 211 | return new JAXBElement(_Entry_QNAME, EntryType.class, null, value); 212 | } 213 | 214 | /** 215 | * Create an instance of {@link JAXBElement }{@code <}{@link FeedType }{@code >}} 216 | * 217 | */ 218 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "feed") 219 | public JAXBElement createFeed(FeedType value) { 220 | return new JAXBElement(_Feed_QNAME, FeedType.class, null, value); 221 | } 222 | 223 | /** 224 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 225 | * 226 | */ 227 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = EntryType.class) 228 | public JAXBElement createEntryTypeTitle(TextType value) { 229 | return new JAXBElement(_EntryTypeTitle_QNAME, TextType.class, EntryType.class, value); 230 | } 231 | 232 | /** 233 | * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} 234 | * 235 | */ 236 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = EntryType.class) 237 | public JAXBElement createEntryTypeCategory(CategoryType value) { 238 | return new JAXBElement(_EntryTypeCategory_QNAME, CategoryType.class, EntryType.class, value); 239 | } 240 | 241 | /** 242 | * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} 243 | * 244 | */ 245 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = EntryType.class) 246 | public JAXBElement createEntryTypeAuthor(PersonType value) { 247 | return new JAXBElement(_EntryTypeAuthor_QNAME, PersonType.class, EntryType.class, value); 248 | } 249 | 250 | /** 251 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 252 | * 253 | */ 254 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "summary", scope = EntryType.class) 255 | public JAXBElement createEntryTypeSummary(TextType value) { 256 | return new JAXBElement(_EntryTypeSummary_QNAME, TextType.class, EntryType.class, value); 257 | } 258 | 259 | /** 260 | * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} 261 | * 262 | */ 263 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = EntryType.class) 264 | public JAXBElement createEntryTypeId(IdType value) { 265 | return new JAXBElement(_EntryTypeId_QNAME, IdType.class, EntryType.class, value); 266 | } 267 | 268 | /** 269 | * Create an instance of {@link JAXBElement }{@code <}{@link ContentType }{@code >}} 270 | * 271 | */ 272 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "content", scope = EntryType.class) 273 | public JAXBElement createEntryTypeContent(ContentType value) { 274 | return new JAXBElement(_EntryTypeContent_QNAME, ContentType.class, EntryType.class, value); 275 | } 276 | 277 | /** 278 | * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} 279 | * 280 | */ 281 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = EntryType.class) 282 | public JAXBElement createEntryTypeLink(LinkType value) { 283 | return new JAXBElement(_EntryTypeLink_QNAME, LinkType.class, EntryType.class, value); 284 | } 285 | 286 | /** 287 | * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} 288 | * 289 | */ 290 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = EntryType.class) 291 | public JAXBElement createEntryTypeContributor(PersonType value) { 292 | return new JAXBElement(_EntryTypeContributor_QNAME, PersonType.class, EntryType.class, value); 293 | } 294 | 295 | /** 296 | * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} 297 | * 298 | */ 299 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = EntryType.class) 300 | public JAXBElement createEntryTypeUpdated(DateTimeType value) { 301 | return new JAXBElement(_EntryTypeUpdated_QNAME, DateTimeType.class, EntryType.class, value); 302 | } 303 | 304 | /** 305 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 306 | * 307 | */ 308 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "source", scope = EntryType.class) 309 | public JAXBElement createEntryTypeSource(TextType value) { 310 | return new JAXBElement(_EntryTypeSource_QNAME, TextType.class, EntryType.class, value); 311 | } 312 | 313 | /** 314 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 315 | * 316 | */ 317 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = EntryType.class) 318 | public JAXBElement createEntryTypeRights(TextType value) { 319 | return new JAXBElement(_EntryTypeRights_QNAME, TextType.class, EntryType.class, value); 320 | } 321 | 322 | /** 323 | * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} 324 | * 325 | */ 326 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "published", scope = EntryType.class) 327 | public JAXBElement createEntryTypePublished(DateTimeType value) { 328 | return new JAXBElement(_EntryTypePublished_QNAME, DateTimeType.class, EntryType.class, value); 329 | } 330 | 331 | /** 332 | * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} 333 | * 334 | */ 335 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = FeedType.class) 336 | public JAXBElement createFeedTypeCategory(CategoryType value) { 337 | return new JAXBElement(_EntryTypeCategory_QNAME, CategoryType.class, FeedType.class, value); 338 | } 339 | 340 | /** 341 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 342 | * 343 | */ 344 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = FeedType.class) 345 | public JAXBElement createFeedTypeTitle(TextType value) { 346 | return new JAXBElement(_EntryTypeTitle_QNAME, TextType.class, FeedType.class, value); 347 | } 348 | 349 | /** 350 | * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} 351 | * 352 | */ 353 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = FeedType.class) 354 | public JAXBElement createFeedTypeAuthor(PersonType value) { 355 | return new JAXBElement(_EntryTypeAuthor_QNAME, PersonType.class, FeedType.class, value); 356 | } 357 | 358 | /** 359 | * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} 360 | * 361 | */ 362 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = FeedType.class) 363 | public JAXBElement createFeedTypeId(IdType value) { 364 | return new JAXBElement(_EntryTypeId_QNAME, IdType.class, FeedType.class, value); 365 | } 366 | 367 | /** 368 | * Create an instance of {@link JAXBElement }{@code <}{@link EntryType }{@code >}} 369 | * 370 | */ 371 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "entry", scope = FeedType.class) 372 | public JAXBElement createFeedTypeEntry(EntryType value) { 373 | return new JAXBElement(_Entry_QNAME, EntryType.class, FeedType.class, value); 374 | } 375 | 376 | /** 377 | * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} 378 | * 379 | */ 380 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = FeedType.class) 381 | public JAXBElement createFeedTypeContributor(PersonType value) { 382 | return new JAXBElement(_EntryTypeContributor_QNAME, PersonType.class, FeedType.class, value); 383 | } 384 | 385 | /** 386 | * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} 387 | * 388 | */ 389 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = FeedType.class) 390 | public JAXBElement createFeedTypeUpdated(DateTimeType value) { 391 | return new JAXBElement(_EntryTypeUpdated_QNAME, DateTimeType.class, FeedType.class, value); 392 | } 393 | 394 | /** 395 | * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} 396 | * 397 | */ 398 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = FeedType.class) 399 | public JAXBElement createFeedTypeGenerator(GeneratorType value) { 400 | return new JAXBElement(_FeedTypeGenerator_QNAME, GeneratorType.class, FeedType.class, value); 401 | } 402 | 403 | /** 404 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 405 | * 406 | */ 407 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = FeedType.class) 408 | public JAXBElement createFeedTypeSubtitle(TextType value) { 409 | return new JAXBElement(_FeedTypeSubtitle_QNAME, TextType.class, FeedType.class, value); 410 | } 411 | 412 | /** 413 | * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} 414 | * 415 | */ 416 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = FeedType.class) 417 | public JAXBElement createFeedTypeIcon(IconType value) { 418 | return new JAXBElement(_FeedTypeIcon_QNAME, IconType.class, FeedType.class, value); 419 | } 420 | 421 | /** 422 | * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} 423 | * 424 | */ 425 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = FeedType.class) 426 | public JAXBElement createFeedTypeLogo(LogoType value) { 427 | return new JAXBElement(_FeedTypeLogo_QNAME, LogoType.class, FeedType.class, value); 428 | } 429 | 430 | /** 431 | * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} 432 | * 433 | */ 434 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = FeedType.class) 435 | public JAXBElement createFeedTypeLink(LinkType value) { 436 | return new JAXBElement(_EntryTypeLink_QNAME, LinkType.class, FeedType.class, value); 437 | } 438 | 439 | /** 440 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 441 | * 442 | */ 443 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = FeedType.class) 444 | public JAXBElement createFeedTypeRights(TextType value) { 445 | return new JAXBElement(_EntryTypeRights_QNAME, TextType.class, FeedType.class, value); 446 | } 447 | 448 | /** 449 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 450 | * 451 | */ 452 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "title", scope = SourceType.class) 453 | public JAXBElement createSourceTypeTitle(TextType value) { 454 | return new JAXBElement(_EntryTypeTitle_QNAME, TextType.class, SourceType.class, value); 455 | } 456 | 457 | /** 458 | * Create an instance of {@link JAXBElement }{@code <}{@link CategoryType }{@code >}} 459 | * 460 | */ 461 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "category", scope = SourceType.class) 462 | public JAXBElement createSourceTypeCategory(CategoryType value) { 463 | return new JAXBElement(_EntryTypeCategory_QNAME, CategoryType.class, SourceType.class, value); 464 | } 465 | 466 | /** 467 | * Create an instance of {@link JAXBElement }{@code <}{@link LogoType }{@code >}} 468 | * 469 | */ 470 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "logo", scope = SourceType.class) 471 | public JAXBElement createSourceTypeLogo(LogoType value) { 472 | return new JAXBElement(_FeedTypeLogo_QNAME, LogoType.class, SourceType.class, value); 473 | } 474 | 475 | /** 476 | * Create an instance of {@link JAXBElement }{@code <}{@link IconType }{@code >}} 477 | * 478 | */ 479 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "icon", scope = SourceType.class) 480 | public JAXBElement createSourceTypeIcon(IconType value) { 481 | return new JAXBElement(_FeedTypeIcon_QNAME, IconType.class, SourceType.class, value); 482 | } 483 | 484 | /** 485 | * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} 486 | * 487 | */ 488 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "author", scope = SourceType.class) 489 | public JAXBElement createSourceTypeAuthor(PersonType value) { 490 | return new JAXBElement(_EntryTypeAuthor_QNAME, PersonType.class, SourceType.class, value); 491 | } 492 | 493 | /** 494 | * Create an instance of {@link JAXBElement }{@code <}{@link IdType }{@code >}} 495 | * 496 | */ 497 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "id", scope = SourceType.class) 498 | public JAXBElement createSourceTypeId(IdType value) { 499 | return new JAXBElement(_EntryTypeId_QNAME, IdType.class, SourceType.class, value); 500 | } 501 | 502 | /** 503 | * Create an instance of {@link JAXBElement }{@code <}{@link LinkType }{@code >}} 504 | * 505 | */ 506 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "link", scope = SourceType.class) 507 | public JAXBElement createSourceTypeLink(LinkType value) { 508 | return new JAXBElement(_EntryTypeLink_QNAME, LinkType.class, SourceType.class, value); 509 | } 510 | 511 | /** 512 | * Create an instance of {@link JAXBElement }{@code <}{@link PersonType }{@code >}} 513 | * 514 | */ 515 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "contributor", scope = SourceType.class) 516 | public JAXBElement createSourceTypeContributor(PersonType value) { 517 | return new JAXBElement(_EntryTypeContributor_QNAME, PersonType.class, SourceType.class, value); 518 | } 519 | 520 | /** 521 | * Create an instance of {@link JAXBElement }{@code <}{@link DateTimeType }{@code >}} 522 | * 523 | */ 524 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "updated", scope = SourceType.class) 525 | public JAXBElement createSourceTypeUpdated(DateTimeType value) { 526 | return new JAXBElement(_EntryTypeUpdated_QNAME, DateTimeType.class, SourceType.class, value); 527 | } 528 | 529 | /** 530 | * Create an instance of {@link JAXBElement }{@code <}{@link GeneratorType }{@code >}} 531 | * 532 | */ 533 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "generator", scope = SourceType.class) 534 | public JAXBElement createSourceTypeGenerator(GeneratorType value) { 535 | return new JAXBElement(_FeedTypeGenerator_QNAME, GeneratorType.class, SourceType.class, value); 536 | } 537 | 538 | /** 539 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 540 | * 541 | */ 542 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "subtitle", scope = SourceType.class) 543 | public JAXBElement createSourceTypeSubtitle(TextType value) { 544 | return new JAXBElement(_FeedTypeSubtitle_QNAME, TextType.class, SourceType.class, value); 545 | } 546 | 547 | /** 548 | * Create an instance of {@link JAXBElement }{@code <}{@link TextType }{@code >}} 549 | * 550 | */ 551 | @XmlElementDecl(namespace = "http://www.w3.org/2005/Atom", name = "rights", scope = SourceType.class) 552 | public JAXBElement createSourceTypeRights(TextType value) { 553 | return new JAXBElement(_EntryTypeRights_QNAME, TextType.class, SourceType.class, value); 554 | } 555 | 556 | } 557 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/PersonType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | import javax.xml.bind.JAXBElement; 16 | import javax.xml.bind.annotation.XmlAccessType; 17 | import javax.xml.bind.annotation.XmlAccessorType; 18 | import javax.xml.bind.annotation.XmlAnyAttribute; 19 | import javax.xml.bind.annotation.XmlAnyElement; 20 | import javax.xml.bind.annotation.XmlAttribute; 21 | import javax.xml.bind.annotation.XmlElementRef; 22 | import javax.xml.bind.annotation.XmlElementRefs; 23 | import javax.xml.bind.annotation.XmlSchemaType; 24 | import javax.xml.bind.annotation.XmlType; 25 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 26 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 27 | import javax.xml.namespace.QName; 28 | 29 | 30 | /** 31 | * 32 | * The Atom person construct is defined in section 3.2 of the format spec. 33 | * 34 | * 35 | *

Java class for personType complex type. 36 | * 37 | *

The following schema fragment specifies the expected content contained within this class. 38 | * 39 | *

 40 |  * <complexType name="personType">
 41 |  *   <complexContent>
 42 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 43 |  *       <choice maxOccurs="unbounded">
 44 |  *         <element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/>
 45 |  *         <element name="uri" type="{http://www.w3.org/2005/Atom}uriType" minOccurs="0"/>
 46 |  *         <element name="email" type="{http://www.w3.org/2005/Atom}emailType" minOccurs="0"/>
 47 |  *         <any namespace='##other'/>
 48 |  *       </choice>
 49 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 50 |  *       <anyAttribute namespace='##other'/>
 51 |  *     </restriction>
 52 |  *   </complexContent>
 53 |  * </complexType>
 54 |  * 
55 | * 56 | * 57 | */ 58 | @XmlAccessorType(XmlAccessType.FIELD) 59 | @XmlType(name = "personType", propOrder = { 60 | "nameOrUriOrEmail" 61 | }) 62 | public class PersonType { 63 | 64 | @XmlElementRefs({ 65 | @XmlElementRef(name = "name", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 66 | @XmlElementRef(name = "uri", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 67 | @XmlElementRef(name = "email", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false) 68 | }) 69 | @XmlAnyElement(lax = true) 70 | protected List nameOrUriOrEmail; 71 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 72 | @XmlSchemaType(name = "anyURI") 73 | protected String base; 74 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 75 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 76 | @XmlSchemaType(name = "language") 77 | protected String lang; 78 | @XmlAnyAttribute 79 | private Map otherAttributes = new HashMap(); 80 | 81 | /** 82 | * Gets the value of the nameOrUriOrEmail property. 83 | * 84 | *

85 | * This accessor method returns a reference to the live list, 86 | * not a snapshot. Therefore any modification you make to the 87 | * returned list will be present inside the JAXB object. 88 | * This is why there is not a set method for the nameOrUriOrEmail property. 89 | * 90 | *

91 | * For example, to add a new item, do as follows: 92 | *

 93 |      *    getNameOrUriOrEmail().add(newItem);
 94 |      * 
95 | * 96 | * 97 | *

98 | * Objects of the following type(s) are allowed in the list 99 | * {@link JAXBElement }{@code <}{@link String }{@code >} 100 | * {@link JAXBElement }{@code <}{@link UriType }{@code >} 101 | * {@link JAXBElement }{@code <}{@link String }{@code >} 102 | * {@link Object } 103 | * 104 | * 105 | */ 106 | public List getNameOrUriOrEmail() { 107 | if (nameOrUriOrEmail == null) { 108 | nameOrUriOrEmail = new ArrayList(); 109 | } 110 | return this.nameOrUriOrEmail; 111 | } 112 | 113 | /** 114 | * Gets the value of the base property. 115 | * 116 | * @return 117 | * possible object is 118 | * {@link String } 119 | * 120 | */ 121 | public String getBase() { 122 | return base; 123 | } 124 | 125 | /** 126 | * Sets the value of the base property. 127 | * 128 | * @param value 129 | * allowed object is 130 | * {@link String } 131 | * 132 | */ 133 | public void setBase(String value) { 134 | this.base = value; 135 | } 136 | 137 | /** 138 | * Gets the value of the lang property. 139 | * 140 | * @return 141 | * possible object is 142 | * {@link String } 143 | * 144 | */ 145 | public String getLang() { 146 | return lang; 147 | } 148 | 149 | /** 150 | * Sets the value of the lang property. 151 | * 152 | * @param value 153 | * allowed object is 154 | * {@link String } 155 | * 156 | */ 157 | public void setLang(String value) { 158 | this.lang = value; 159 | } 160 | 161 | /** 162 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 163 | * 164 | *

165 | * the map is keyed by the name of the attribute and 166 | * the value is the string value of the attribute. 167 | * 168 | * the map returned by this method is live, and you can add new attribute 169 | * by updating the map directly. Because of this design, there's no setter. 170 | * 171 | * 172 | * @return 173 | * always non-null 174 | */ 175 | public Map getOtherAttributes() { 176 | return otherAttributes; 177 | } 178 | 179 | } 180 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/SourceType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | import javax.xml.bind.JAXBElement; 16 | import javax.xml.bind.annotation.XmlAccessType; 17 | import javax.xml.bind.annotation.XmlAccessorType; 18 | import javax.xml.bind.annotation.XmlAnyAttribute; 19 | import javax.xml.bind.annotation.XmlAnyElement; 20 | import javax.xml.bind.annotation.XmlAttribute; 21 | import javax.xml.bind.annotation.XmlElementRef; 22 | import javax.xml.bind.annotation.XmlElementRefs; 23 | import javax.xml.bind.annotation.XmlSchemaType; 24 | import javax.xml.bind.annotation.XmlType; 25 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 26 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 27 | import javax.xml.namespace.QName; 28 | 29 | 30 | /** 31 | * 32 | * The Atom source construct is defined in section 4.2.11 of the format spec. 33 | * 34 | * 35 | *

Java class for sourceType complex type. 36 | * 37 | *

The following schema fragment specifies the expected content contained within this class. 38 | * 39 | *

 40 |  * <complexType name="sourceType">
 41 |  *   <complexContent>
 42 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 43 |  *       <choice maxOccurs="unbounded">
 44 |  *         <element name="author" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
 45 |  *         <element name="category" type="{http://www.w3.org/2005/Atom}categoryType" maxOccurs="unbounded" minOccurs="0"/>
 46 |  *         <element name="contributor" type="{http://www.w3.org/2005/Atom}personType" maxOccurs="unbounded" minOccurs="0"/>
 47 |  *         <element name="generator" type="{http://www.w3.org/2005/Atom}generatorType" minOccurs="0"/>
 48 |  *         <element name="icon" type="{http://www.w3.org/2005/Atom}iconType" minOccurs="0"/>
 49 |  *         <element name="id" type="{http://www.w3.org/2005/Atom}idType" minOccurs="0"/>
 50 |  *         <element name="link" type="{http://www.w3.org/2005/Atom}linkType" maxOccurs="unbounded" minOccurs="0"/>
 51 |  *         <element name="logo" type="{http://www.w3.org/2005/Atom}logoType" minOccurs="0"/>
 52 |  *         <element name="rights" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 53 |  *         <element name="subtitle" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 54 |  *         <element name="title" type="{http://www.w3.org/2005/Atom}textType" minOccurs="0"/>
 55 |  *         <element name="updated" type="{http://www.w3.org/2005/Atom}dateTimeType" minOccurs="0"/>
 56 |  *         <any namespace='##other' maxOccurs="unbounded" minOccurs="0"/>
 57 |  *       </choice>
 58 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 59 |  *       <anyAttribute namespace='##other'/>
 60 |  *     </restriction>
 61 |  *   </complexContent>
 62 |  * </complexType>
 63 |  * 
64 | * 65 | * 66 | */ 67 | @XmlAccessorType(XmlAccessType.FIELD) 68 | @XmlType(name = "sourceType", propOrder = { 69 | "authorOrCategoryOrContributor" 70 | }) 71 | public class SourceType { 72 | 73 | @XmlElementRefs({ 74 | @XmlElementRef(name = "category", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 75 | @XmlElementRef(name = "rights", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 76 | @XmlElementRef(name = "logo", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 77 | @XmlElementRef(name = "updated", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 78 | @XmlElementRef(name = "link", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 79 | @XmlElementRef(name = "icon", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 80 | @XmlElementRef(name = "author", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 81 | @XmlElementRef(name = "id", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 82 | @XmlElementRef(name = "contributor", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 83 | @XmlElementRef(name = "title", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 84 | @XmlElementRef(name = "generator", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false), 85 | @XmlElementRef(name = "subtitle", namespace = "http://www.w3.org/2005/Atom", type = JAXBElement.class, required = false) 86 | }) 87 | @XmlAnyElement(lax = true) 88 | protected List authorOrCategoryOrContributor; 89 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 90 | @XmlSchemaType(name = "anyURI") 91 | protected String base; 92 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 93 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 94 | @XmlSchemaType(name = "language") 95 | protected String lang; 96 | @XmlAnyAttribute 97 | private Map otherAttributes = new HashMap(); 98 | 99 | /** 100 | * Gets the value of the authorOrCategoryOrContributor property. 101 | * 102 | *

103 | * This accessor method returns a reference to the live list, 104 | * not a snapshot. Therefore any modification you make to the 105 | * returned list will be present inside the JAXB object. 106 | * This is why there is not a set method for the authorOrCategoryOrContributor property. 107 | * 108 | *

109 | * For example, to add a new item, do as follows: 110 | *

111 |      *    getAuthorOrCategoryOrContributor().add(newItem);
112 |      * 
113 | * 114 | * 115 | *

116 | * Objects of the following type(s) are allowed in the list 117 | * {@link JAXBElement }{@code <}{@link CategoryType }{@code >} 118 | * {@link JAXBElement }{@code <}{@link LogoType }{@code >} 119 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 120 | * {@link JAXBElement }{@code <}{@link PersonType }{@code >} 121 | * {@link JAXBElement }{@code <}{@link IconType }{@code >} 122 | * {@link JAXBElement }{@code <}{@link LinkType }{@code >} 123 | * {@link JAXBElement }{@code <}{@link DateTimeType }{@code >} 124 | * {@link Object } 125 | * {@link JAXBElement }{@code <}{@link PersonType }{@code >} 126 | * {@link JAXBElement }{@code <}{@link IdType }{@code >} 127 | * {@link JAXBElement }{@code <}{@link GeneratorType }{@code >} 128 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 129 | * {@link JAXBElement }{@code <}{@link TextType }{@code >} 130 | * 131 | * 132 | */ 133 | public List getAuthorOrCategoryOrContributor() { 134 | if (authorOrCategoryOrContributor == null) { 135 | authorOrCategoryOrContributor = new ArrayList(); 136 | } 137 | return this.authorOrCategoryOrContributor; 138 | } 139 | 140 | /** 141 | * Gets the value of the base property. 142 | * 143 | * @return 144 | * possible object is 145 | * {@link String } 146 | * 147 | */ 148 | public String getBase() { 149 | return base; 150 | } 151 | 152 | /** 153 | * Sets the value of the base property. 154 | * 155 | * @param value 156 | * allowed object is 157 | * {@link String } 158 | * 159 | */ 160 | public void setBase(String value) { 161 | this.base = value; 162 | } 163 | 164 | /** 165 | * Gets the value of the lang property. 166 | * 167 | * @return 168 | * possible object is 169 | * {@link String } 170 | * 171 | */ 172 | public String getLang() { 173 | return lang; 174 | } 175 | 176 | /** 177 | * Sets the value of the lang property. 178 | * 179 | * @param value 180 | * allowed object is 181 | * {@link String } 182 | * 183 | */ 184 | public void setLang(String value) { 185 | this.lang = value; 186 | } 187 | 188 | /** 189 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 190 | * 191 | *

192 | * the map is keyed by the name of the attribute and 193 | * the value is the string value of the attribute. 194 | * 195 | * the map returned by this method is live, and you can add new attribute 196 | * by updating the map directly. Because of this design, there's no setter. 197 | * 198 | * 199 | * @return 200 | * always non-null 201 | */ 202 | public Map getOtherAttributes() { 203 | return otherAttributes; 204 | } 205 | 206 | } 207 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/TextType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | import javax.xml.bind.annotation.XmlAccessType; 16 | import javax.xml.bind.annotation.XmlAccessorType; 17 | import javax.xml.bind.annotation.XmlAnyAttribute; 18 | import javax.xml.bind.annotation.XmlAnyElement; 19 | import javax.xml.bind.annotation.XmlAttribute; 20 | import javax.xml.bind.annotation.XmlMixed; 21 | import javax.xml.bind.annotation.XmlSchemaType; 22 | import javax.xml.bind.annotation.XmlType; 23 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 24 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 25 | import javax.xml.namespace.QName; 26 | 27 | 28 | /** 29 | * 30 | * The Atom text construct is defined in section 3.1 of the format spec. 31 | * 32 | * 33 | *

Java class for textType complex type. 34 | * 35 | *

The following schema fragment specifies the expected content contained within this class. 36 | * 37 | *

 38 |  * <complexType name="textType">
 39 |  *   <complexContent>
 40 |  *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 41 |  *       <sequence>
 42 |  *         <any namespace='http://www.w3.org/1999/xhtml' minOccurs="0"/>
 43 |  *       </sequence>
 44 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 45 |  *       <attribute name="type">
 46 |  *         <simpleType>
 47 |  *           <restriction base="{http://www.w3.org/2001/XMLSchema}token">
 48 |  *             <enumeration value="text"/>
 49 |  *             <enumeration value="html"/>
 50 |  *             <enumeration value="xhtml"/>
 51 |  *           </restriction>
 52 |  *         </simpleType>
 53 |  *       </attribute>
 54 |  *       <anyAttribute namespace='##other'/>
 55 |  *     </restriction>
 56 |  *   </complexContent>
 57 |  * </complexType>
 58 |  * 
59 | * 60 | * 61 | */ 62 | @XmlAccessorType(XmlAccessType.FIELD) 63 | @XmlType(name = "textType", propOrder = { 64 | "content" 65 | }) 66 | public class TextType { 67 | 68 | @XmlMixed 69 | @XmlAnyElement(lax = true) 70 | protected List content; 71 | @XmlAttribute(name = "type") 72 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 73 | protected String type; 74 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 75 | @XmlSchemaType(name = "anyURI") 76 | protected String base; 77 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 78 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 79 | @XmlSchemaType(name = "language") 80 | protected String lang; 81 | @XmlAnyAttribute 82 | private Map otherAttributes = new HashMap(); 83 | 84 | /** 85 | * 86 | * The Atom text construct is defined in section 3.1 of the format spec. 87 | * Gets the value of the content property. 88 | * 89 | *

90 | * This accessor method returns a reference to the live list, 91 | * not a snapshot. Therefore any modification you make to the 92 | * returned list will be present inside the JAXB object. 93 | * This is why there is not a set method for the content property. 94 | * 95 | *

96 | * For example, to add a new item, do as follows: 97 | *

 98 |      *    getContent().add(newItem);
 99 |      * 
100 | * 101 | * 102 | *

103 | * Objects of the following type(s) are allowed in the list 104 | * {@link String } 105 | * {@link Object } 106 | * 107 | * 108 | */ 109 | public List getContent() { 110 | if (content == null) { 111 | content = new ArrayList(); 112 | } 113 | return this.content; 114 | } 115 | 116 | /** 117 | * Gets the value of the type property. 118 | * 119 | * @return 120 | * possible object is 121 | * {@link String } 122 | * 123 | */ 124 | public String getType() { 125 | return type; 126 | } 127 | 128 | /** 129 | * Sets the value of the type property. 130 | * 131 | * @param value 132 | * allowed object is 133 | * {@link String } 134 | * 135 | */ 136 | public void setType(String value) { 137 | this.type = value; 138 | } 139 | 140 | /** 141 | * Gets the value of the base property. 142 | * 143 | * @return 144 | * possible object is 145 | * {@link String } 146 | * 147 | */ 148 | public String getBase() { 149 | return base; 150 | } 151 | 152 | /** 153 | * Sets the value of the base property. 154 | * 155 | * @param value 156 | * allowed object is 157 | * {@link String } 158 | * 159 | */ 160 | public void setBase(String value) { 161 | this.base = value; 162 | } 163 | 164 | /** 165 | * Gets the value of the lang property. 166 | * 167 | * @return 168 | * possible object is 169 | * {@link String } 170 | * 171 | */ 172 | public String getLang() { 173 | return lang; 174 | } 175 | 176 | /** 177 | * Sets the value of the lang property. 178 | * 179 | * @param value 180 | * allowed object is 181 | * {@link String } 182 | * 183 | */ 184 | public void setLang(String value) { 185 | this.lang = value; 186 | } 187 | 188 | /** 189 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 190 | * 191 | *

192 | * the map is keyed by the name of the attribute and 193 | * the value is the string value of the attribute. 194 | * 195 | * the map returned by this method is live, and you can add new attribute 196 | * by updating the map directly. Because of this design, there's no setter. 197 | * 198 | * 199 | * @return 200 | * always non-null 201 | */ 202 | public Map getOtherAttributes() { 203 | return otherAttributes; 204 | } 205 | 206 | } 207 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/UriType.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | 9 | package org.w3._2005.atom; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | import javax.xml.bind.annotation.XmlAccessType; 14 | import javax.xml.bind.annotation.XmlAccessorType; 15 | import javax.xml.bind.annotation.XmlAnyAttribute; 16 | import javax.xml.bind.annotation.XmlAttribute; 17 | import javax.xml.bind.annotation.XmlSchemaType; 18 | import javax.xml.bind.annotation.XmlType; 19 | import javax.xml.bind.annotation.XmlValue; 20 | import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; 21 | import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 22 | import javax.xml.namespace.QName; 23 | 24 | 25 | /** 26 | *

Java class for uriType complex type. 27 | * 28 | *

The following schema fragment specifies the expected content contained within this class. 29 | * 30 | *

 31 |  * <complexType name="uriType">
 32 |  *   <simpleContent>
 33 |  *     <extension base="<http://www.w3.org/2001/XMLSchema>anyURI">
 34 |  *       <attGroup ref="{http://www.w3.org/2005/Atom}commonAttributes"/>
 35 |  *       <anyAttribute namespace='##other'/>
 36 |  *     </extension>
 37 |  *   </simpleContent>
 38 |  * </complexType>
 39 |  * 
40 | * 41 | * 42 | */ 43 | @XmlAccessorType(XmlAccessType.FIELD) 44 | @XmlType(name = "uriType", propOrder = { 45 | "value" 46 | }) 47 | public class UriType { 48 | 49 | @XmlValue 50 | @XmlSchemaType(name = "anyURI") 51 | protected String value; 52 | @XmlAttribute(name = "base", namespace = "http://www.w3.org/XML/1998/namespace") 53 | @XmlSchemaType(name = "anyURI") 54 | protected String base; 55 | @XmlAttribute(name = "lang", namespace = "http://www.w3.org/XML/1998/namespace") 56 | @XmlJavaTypeAdapter(CollapsedStringAdapter.class) 57 | @XmlSchemaType(name = "language") 58 | protected String lang; 59 | @XmlAnyAttribute 60 | private Map otherAttributes = new HashMap(); 61 | 62 | /** 63 | * Gets the value of the value property. 64 | * 65 | * @return 66 | * possible object is 67 | * {@link String } 68 | * 69 | */ 70 | public String getValue() { 71 | return value; 72 | } 73 | 74 | /** 75 | * Sets the value of the value property. 76 | * 77 | * @param value 78 | * allowed object is 79 | * {@link String } 80 | * 81 | */ 82 | public void setValue(String value) { 83 | this.value = value; 84 | } 85 | 86 | /** 87 | * Gets the value of the base property. 88 | * 89 | * @return 90 | * possible object is 91 | * {@link String } 92 | * 93 | */ 94 | public String getBase() { 95 | return base; 96 | } 97 | 98 | /** 99 | * Sets the value of the base property. 100 | * 101 | * @param value 102 | * allowed object is 103 | * {@link String } 104 | * 105 | */ 106 | public void setBase(String value) { 107 | this.base = value; 108 | } 109 | 110 | /** 111 | * Gets the value of the lang property. 112 | * 113 | * @return 114 | * possible object is 115 | * {@link String } 116 | * 117 | */ 118 | public String getLang() { 119 | return lang; 120 | } 121 | 122 | /** 123 | * Sets the value of the lang property. 124 | * 125 | * @param value 126 | * allowed object is 127 | * {@link String } 128 | * 129 | */ 130 | public void setLang(String value) { 131 | this.lang = value; 132 | } 133 | 134 | /** 135 | * Gets a map that contains attributes that aren't bound to any typed property on this class. 136 | * 137 | *

138 | * the map is keyed by the name of the attribute and 139 | * the value is the string value of the attribute. 140 | * 141 | * the map returned by this method is live, and you can add new attribute 142 | * by updating the map directly. Because of this design, there's no setter. 143 | * 144 | * 145 | * @return 146 | * always non-null 147 | */ 148 | public Map getOtherAttributes() { 149 | return otherAttributes; 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /src/main/java/org/w3/_2005/atom/package-info.java: -------------------------------------------------------------------------------- 1 | // 2 | // This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4-2 3 | // See http://java.sun.com/xml/jaxb 4 | // Any modifications to this file will be lost upon recompilation of the source schema. 5 | // Generated on: 2012.10.21 at 11:22:17 AM HST 6 | // 7 | 8 | @javax.xml.bind.annotation.XmlSchema(namespace = "http://www.w3.org/2005/Atom", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED) 9 | package org.w3._2005.atom; 10 | -------------------------------------------------------------------------------- /src/main/test/java/com/github/aruld/oneliners/ItemTest.java: -------------------------------------------------------------------------------- 1 | package com.github.aruld.oneliners; 2 | 3 | import org.junit.Assert; 4 | import org.junit.Test; 5 | 6 | import java.io.BufferedReader; 7 | import java.io.File; 8 | import java.io.FileReader; 9 | import java.net.URL; 10 | import java.nio.charset.Charset; 11 | import java.nio.file.Files; 12 | import java.util.*; 13 | import java.util.stream.IntStream; 14 | import java.util.stream.Stream; 15 | 16 | import static java.util.Comparator.comparing; 17 | import static java.util.stream.Collectors.groupingBy; 18 | import static java.util.stream.Collectors.toCollection; 19 | import static java.util.stream.Collectors.toList; 20 | import static java.util.stream.IntStream.range; 21 | import static junit.framework.TestCase.assertEquals; 22 | import static org.junit.Assert.assertArrayEquals; 23 | import static org.junit.Assert.assertTrue; 24 | 25 | import static com.github.aruld.oneliners.Item10.Album; 26 | import static com.github.aruld.oneliners.Item10.Track; 27 | 28 | public class ItemTest { 29 | 30 | @Test 31 | public void item1() { 32 | int[] actual = range(1, 10).map(i -> i * 2).toArray(); 33 | int[] expected = new int[]{2, 4, 6, 8, 10, 12, 14, 16, 18}; 34 | assertArrayEquals(actual, expected); 35 | List actualList = range(1, 10).map(i -> i * 2).boxed().collect(toList()); 36 | List expectedList = Arrays.asList(2, 4, 6, 8, 10, 12, 14, 16, 18); 37 | Assert.assertEquals(actualList, expectedList); 38 | } 39 | 40 | @Test 41 | public void item2() { 42 | int expected = 499500; 43 | assertEquals(range(1, 1000).sum(), expected); 44 | assertEquals(range(1, 1000).reduce(0, Integer::sum), expected); 45 | assertEquals(Stream.iterate(0, i -> i + 1).limit(1000).reduce(0, Integer::sum).intValue(), expected); 46 | assertEquals(IntStream.iterate(0, i -> i + 1).limit(1000).reduce(0, Integer::sum), expected); 47 | } 48 | 49 | @Test 50 | public void item3() { 51 | 52 | final List keywords = Arrays.asList("brown", "fox", "dog", "pangram"); 53 | final String tweet = "The quick brown fox jumps over a lazy dog. #pangram http://www.rinkworks.com/words/pangrams.shtml"; 54 | 55 | assertTrue(keywords.stream().anyMatch(tweet::contains)); 56 | assertTrue(keywords.stream().reduce(false, (b, keyword) -> b || tweet.contains(keyword), (l, r) -> l || r)); 57 | 58 | } 59 | 60 | @Test 61 | public void item4() throws Exception { 62 | URL url = this.getClass().getResource("/data.txt"); 63 | File data = new File(url.getFile()); 64 | List expected = Arrays.asList("banana", "pineapple", "guava", "papaya"); 65 | 66 | try (BufferedReader reader = new BufferedReader(new FileReader(data))) { 67 | String fileText = reader.lines().reduce("", String::concat); 68 | assertEquals(fileText, "bananapineappleguavapapaya"); 69 | } 70 | 71 | try (BufferedReader reader = new BufferedReader(new FileReader(data))) { 72 | List fileLines = reader.lines().collect(toCollection(LinkedList::new)); 73 | assertEquals(fileLines, expected); 74 | } 75 | 76 | try (Stream lines = Files.lines(data.toPath(), Charset.defaultCharset())) { 77 | List fileLines = lines.collect(toCollection(LinkedList::new)); 78 | assertEquals(fileLines, expected); 79 | } 80 | } 81 | 82 | @Test 83 | public void item6() { 84 | Map> result = Stream.of(49, 58, 76, 82, 88, 90).collect(groupingBy(Item6.forPredicate(i -> i > 60, "passed", "failed"))); 85 | 86 | Collection expected = Arrays.asList(76, 82, 88, 90); 87 | assertEquals(result.get("passed"), expected); 88 | assertEquals(result.get("failed"), Arrays.asList(49, 58)); 89 | } 90 | 91 | @Test 92 | public void item8() { 93 | int min = Stream.of(14, 35, -7, 46, 98).reduce(Integer::min).get(); 94 | assertEquals(min, -7); 95 | min = Stream.of(14, 35, -7, 46, 98).min(Integer::compare).get(); 96 | assertEquals(min, -7); 97 | 98 | int max = Stream.of(14, 35, -7, 46, 98).reduce(Integer::max).get(); 99 | assertEquals(max, 98); 100 | max = Stream.of(14, 35, -7, 46, 98).max(Integer::compare).get(); 101 | assertEquals(max, 98); 102 | } 103 | 104 | @Test 105 | public void item10() { 106 | Album tailgates = new Album("Tailgates & Tanlines", "Luke Bryan"); 107 | tailgates.tracks.add(new Track("Country Girl (Shake It for Me)", 5)); 108 | tailgates.tracks.add(new Track("Kiss Tomorrow Goodbye", 5)); 109 | tailgates.tracks.add(new Track("Drunk On You", 4)); 110 | tailgates.tracks.add(new Track("Too Damn Young", 4)); 111 | tailgates.tracks.add(new Track("I Don't Want This Night to End", 4)); 112 | tailgates.tracks.add(new Track("You Don't Know Jack", 4)); 113 | tailgates.tracks.add(new Track("Harvest Time", 3)); 114 | tailgates.tracks.add(new Track("I Know You're Gonna Be There", 3)); 115 | tailgates.tracks.add(new Track("Muckalee Creek Water", 3)); 116 | tailgates.tracks.add(new Track("Tailgate Blues", 3)); 117 | tailgates.tracks.add(new Track("Been There, Done That", 3)); 118 | tailgates.tracks.add(new Track("Faded Away", 3)); 119 | tailgates.tracks.add(new Track("I Knew You That Way", 3)); 120 | 121 | Album unapologetic = new Album("Unapologetic", "Rihanna"); 122 | unapologetic.tracks.add(new Track("Phresh Out the Runway", 5)); 123 | unapologetic.tracks.add(new Track("Diamonds", 3)); 124 | unapologetic.tracks.add(new Track("Numb", 3)); 125 | unapologetic.tracks.add(new Track("Pour It Up", 3)); 126 | unapologetic.tracks.add(new Track("Loveeeeeee Song", 4)); 127 | unapologetic.tracks.add(new Track("Jump", 4)); 128 | unapologetic.tracks.add(new Track("Right Now", 4)); 129 | unapologetic.tracks.add(new Track("What Now", 4)); 130 | unapologetic.tracks.add(new Track("Stay", 4)); 131 | unapologetic.tracks.add(new Track("Nobody's Business", 5)); 132 | unapologetic.tracks.add(new Track("Love Without Tragedy", 5)); 133 | unapologetic.tracks.add(new Track("Get It Over With", 5)); 134 | unapologetic.tracks.add(new Track("No Love Allowed", 3)); 135 | unapologetic.tracks.add(new Track("Lost In Paradise", 5)); 136 | 137 | Album red = new Album("Red", "Taylor Swift"); 138 | red.tracks.add(new Track("State of Grace", 4)); 139 | red.tracks.add(new Track("Red", 4)); 140 | red.tracks.add(new Track("Treacherous", 4)); 141 | red.tracks.add(new Track("I Knew You Were Trouble", 5)); 142 | red.tracks.add(new Track("All Too Well", 3)); 143 | red.tracks.add(new Track("22", 3)); 144 | red.tracks.add(new Track("I Almost Do", 3)); 145 | red.tracks.add(new Track("We Are Never Ever Getting Back", 3)); 146 | red.tracks.add(new Track("Stay Stay Stay", 5)); 147 | red.tracks.add(new Track("The Last Time", 5)); 148 | red.tracks.add(new Track("Holy Ground", 3)); 149 | red.tracks.add(new Track("Sad Beautiful Tragic", 3)); 150 | red.tracks.add(new Track("The Lucky One", 4)); 151 | red.tracks.add(new Track("Everything Has Changed", 3)); 152 | red.tracks.add(new Track("Starlight", 4)); 153 | red.tracks.add(new Track("Begin Again", 3)); 154 | 155 | List albums = Arrays.asList(unapologetic, tailgates, red); 156 | 157 | // Print the names of albums that have at least one track rated four or higher, sorted by name. 158 | Assert.assertEquals(albums.stream() 159 | .filter(a -> a.tracks.stream().anyMatch(t -> (t.rating >= 4))) 160 | .sorted(comparing(album -> album.name)) 161 | .map(a -> a.name).collect(toList()), Arrays.asList("Red", "Tailgates & Tanlines", "Unapologetic")); 162 | 163 | // Merge tracks from all albums 164 | List allTracks = albums.stream().flatMap(album -> album.tracks.stream()).collect(toList()); 165 | Assert.assertEquals(allTracks.size(), 43); 166 | 167 | // Group album tracks by rating 168 | Map> tracksByRating = allTracks.stream().collect(groupingBy(Track::getRating)); 169 | Assert.assertEquals(tracksByRating.get(3).size(), 19); 170 | Assert.assertEquals(tracksByRating.get(4).size(), 14); 171 | Assert.assertEquals(tracksByRating.get(5).size(), 10); 172 | } 173 | 174 | } 175 | -------------------------------------------------------------------------------- /src/main/test/resources/data.txt: -------------------------------------------------------------------------------- 1 | banana 2 | pineapple 3 | guava 4 | papaya --------------------------------------------------------------------------------