Package list libxstream-java / 3e39d69
New upstream version 1.4.11 Markus Koschany 2 years ago
134 changed file(s) with 2310 addition(s) and 785 deletion(s). Raw diff Collapse all Expand all
0 <settings>
1 <mirrors>
2 <mirror>
3 <id>central</id>
4 <url>http://repo1.maven.org/maven2</url>
5 <mirrorOf>*</mirrorOf>
6 </mirror>
7 </mirrors>
8 </settings>
00 language: java
11 sudo: false
2 addons:
3 apt:
4 packages:
5 - openjdk-6-jdk
26 jdk:
7 - openjdk11
8 - openjdk10
9 - oraclejdk9
310 - oraclejdk8
4 - oraclejdk7
11 - openjdk7
512 - openjdk6
613 install: true
714 script:
8 if ( `javac -version 2>&1 | grep '1\.8\.0' > /dev/null` ); then
15 if [ "$TRAVIS_JDK_VERSION" == "openjdk6" ]; then
16 wget https://archive.apache.org/dist/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.zip -P ./target;
17 unzip -qq ./target/apache-maven-3.2.5-bin.zip -d ./target;
18 export M2_HOME=$PWD/target/apache-maven-3.2.5;
19 export PATH=$M2_HOME/bin:$JAVA_HOME/bin:$PATH;
20 export SETTINGS="-s .travis.settings.xml";
21 fi;
22 if [ "$TRAVIS_JDK_VERSION" == "oraclejdk8" ]; then
923 mkdir -p xstream/profiles/coveralls;
1024 mkdir -p xstream-hibernate/profiles/coveralls;
11 mvn -V -B -e clean package cobertura:cobertura coveralls:report;
25 mvn -V -B -e clean package jacoco:report coveralls:report;
1226 else
13 mvn -V -B -e clean package;
27 mvn -V -B -e clean package $SETTINGS;
1428 fi
1529 cache:
16 directories:
30 directories:
1731 - $HOME/.m2
1313 ## Documentation
1414 Documentation can be found at [GitHub](http://x-stream.github.io). This
1515 includes:
16 * Introduction and tutorial
17 * JavaDoc
18 * Change log
19 * Frequently asked questions
16 * [Introduction](http://x-stream.github.io) and [Tutorials](http://x-stream.github.io/tutorial.html)
17 * [JavaDoc](http://x-stream.github.io/javadoc/index.html)
18 * [Change History](http://x-stream.github.io/changes.html)
19 * [Frequently Asked Questions](http://x-stream.github.io/faq.html)
2020
2121 ## Source
2222 The complete source for XStream is bundled in the -src archive. This includes:
2323 * Main API [xstream/src/java]
24 * Unit tests [xstream/src/test]
25 * Maven build files [pom.xml]
26 * Hibernate module [xstream-hibernate]
27 * Web site [xstream-distribution]
24 * Unit Tests [xstream/src/test]
25 * Maven Build Files [pom.xml]
26 * Hibernate Module [xstream-hibernate]
27 * Website [xstream-distribution]
2828
1616
1717 Documentation can be found at http://x-stream.github.io. This
1818 includes:
19 * Introduction and tutorial
19 * Introduction and Tutorials
2020 * JavaDoc
21 * Change log
22 * Frequently asked questions
21 * Change History
22 * Frequently Asked Questions
2323
2424 --[ Source ]-------------------------------------------------
2525
2626 The complete source for XStream is bundled in the -src archive.
2727 This includes:
2828 * Main API [xstream/src/java]
29 * Unit tests [xstream/src/test]
30 * Maven build files [pom.xml]
31 * Hibernate module [xstream-hibernate]
32 * Web site [xstream-distribution]
29 * Unit Tests [xstream/src/test]
30 * Maven Build Files [pom.xml]
31 * Hibernate Module [xstream-hibernate]
32 * Website [xstream-distribution]
3333
3434 -------------------------------------------------------------
3535
00 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
11 <!--
22 Copyright (C) 2006 Joe Walnes.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017 XStream committers.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2015, 2016, 2017, 2018 XStream committers.
44 All rights reserved.
55
66 The software in this package is published under the terms of the BSD
1313 <groupId>com.thoughtworks.xstream</groupId>
1414 <artifactId>xstream-parent</artifactId>
1515 <packaging>pom</packaging>
16 <version>1.4.10</version>
16 <version>1.4.11</version>
1717 <name>XStream Parent</name>
1818 <url>http://x-stream.github.io</url>
1919 <description>
3636
3737 <profiles>
3838 <profile>
39 <id>jdk19</id>
39 <id>jdk9-ge</id>
4040 <activation>
41 <jdk>9</jdk>
41 <jdk>[9,</jdk>
4242 </activation>
4343 <properties>
44 <version.java.5>1.6</version.java.5>
4445 <version.java.source>1.6</version.java.source>
4546 <version.java.target>1.6</version.java.target>
47 <version.plugin.maven.enforcer>3.0.0-M1</version.plugin.maven.enforcer>
4648 </properties>
4749 </profile>
4850 <profile>
49 <id>jdk18ge</id>
51 <id>jdk18-ge</id>
5052 <activation>
5153 <jdk>[1.8,)</jdk>
5254 </activation>
5355 <properties>
5456 <javadoc.xdoclint>-Xdoclint:-missing</javadoc.xdoclint>
5557 <version.plugin.felix.bundle>2.5.4</version.plugin.felix.bundle>
58 </properties>
59 </profile>
60 <profile>
61 <id>jdk18</id>
62 <activation>
63 <jdk>1.8</jdk>
64 </activation>
65 <properties>
66 <version.java.source>1.4</version.java.source>
67 <version.java.target>1.4</version.java.target>
5668 </properties>
5769 </profile>
5870 <profile>
165177 <configuration>
166178 <instructions combine.children="append">
167179 <Export-Package>${bundle.export.package}</Export-Package>
180 <Import-Package>${bundle.import.package}</Import-Package>
168181 </instructions>
169182 </configuration>
170183 </plugin>
189202 </build>
190203 <properties>
191204 <bundle.export.package>${project.groupId}.*;-noimport:=true</bundle.export.package>
205 <bundle.import.package>*</bundle.import.package>
192206 </properties>
193207 </profile>
194208 <profile>
224238 <build>
225239 <plugins>
226240 <plugin>
227 <groupId>org.codehaus.mojo</groupId>
228 <artifactId>cobertura-maven-plugin</artifactId>
229 <configuration>
230 <formats>
231 <format>xml</format>
232 </formats>
233 <aggregate>true</aggregate>
234 </configuration>
241 <groupId>org.eluder.coveralls</groupId>
242 <artifactId>coveralls-maven-plugin</artifactId>
235243 </plugin>
236244 <plugin>
237 <groupId>org.eluder.coveralls</groupId>
238 <artifactId>coveralls-maven-plugin</artifactId>
245 <groupId>org.jacoco</groupId>
246 <artifactId>jacoco-maven-plugin</artifactId>
247 <executions>
248 <execution>
249 <id>prepare-agent</id>
250 <goals>
251 <goal>prepare-agent</goal>
252 </goals>
253 </execution>
254 </executions>
239255 </plugin>
240256 </plugins>
241257 </build>
304320 <dependency>
305321 <groupId>com.thoughtworks.xstream</groupId>
306322 <artifactId>xstream</artifactId>
307 <version>1.4.10</version>
323 <version>1.4.11</version>
308324 </dependency>
309325 <dependency>
310326 <groupId>com.thoughtworks.xstream</groupId>
311327 <artifactId>xstream</artifactId>
312 <version>1.4.10</version>
328 <version>1.4.11</version>
313329 <classifier>tests</classifier>
314330 <type>test-jar</type>
315331 <scope>test</scope>
317333 <dependency>
318334 <groupId>com.thoughtworks.xstream</groupId>
319335 <artifactId>xstream</artifactId>
320 <version>1.4.10</version>
336 <version>1.4.11</version>
321337 <classifier>javadoc</classifier>
322338 <scope>provided</scope>
323339 </dependency>
324340 <dependency>
325341 <groupId>com.thoughtworks.xstream</groupId>
326342 <artifactId>xstream-hibernate</artifactId>
327 <version>1.4.10</version>
343 <version>1.4.11</version>
328344 </dependency>
329345 <dependency>
330346 <groupId>com.thoughtworks.xstream</groupId>
331347 <artifactId>xstream-hibernate</artifactId>
332 <version>1.4.10</version>
348 <version>1.4.11</version>
333349 <classifier>javadoc</classifier>
334350 <scope>provided</scope>
335351 </dependency>
336352 <dependency>
337353 <groupId>com.thoughtworks.xstream</groupId>
338354 <artifactId>xstream-jmh</artifactId>
339 <version>1.4.10</version>
355 <version>1.4.11</version>
340356 </dependency>
341357 <dependency>
342358 <groupId>com.thoughtworks.xstream</groupId>
343359 <artifactId>xstream-jmh</artifactId>
344 <version>1.4.10</version>
360 <version>1.4.11</version>
345361 <classifier>javadoc</classifier>
346362 <scope>provided</scope>
347363 </dependency>
348364 <dependency>
349365 <groupId>com.thoughtworks.xstream</groupId>
350366 <artifactId>xstream-benchmark</artifactId>
351 <version>1.4.10</version>
367 <version>1.4.11</version>
352368 </dependency>
353369 <dependency>
354370 <groupId>com.thoughtworks.xstream</groupId>
355371 <artifactId>xstream-benchmark</artifactId>
356 <version>1.4.10</version>
372 <version>1.4.11</version>
357373 <classifier>javadoc</classifier>
358374 <scope>provided</scope>
359375 </dependency>
524540 <groupId>javax.activation</groupId>
525541 <artifactId>activation</artifactId>
526542 <version>${version.javax.activation}</version>
527 <scope>provided</scope>
543 </dependency>
544 <dependency>
545 <groupId>javax.annotation</groupId>
546 <artifactId>javax.annotation-api</artifactId>
547 <version>${version.javax.annotation.api}</version>
548 </dependency>
549 <dependency>
550 <groupId>javax.xml.bind</groupId>
551 <artifactId>jaxb-api</artifactId>
552 <version>${version.javax.xml.bind.api}</version>
528553 </dependency>
529554
530555 <dependency>
571596 <artifactId>jmh-generator-annprocess</artifactId>
572597 <version>${version.org.openjdk.jmh}</version>
573598 <scope>provided</scope>
599 </dependency>
600 <dependency>
601 <groupId>commons-codec</groupId>
602 <artifactId>commons-codec</artifactId>
603 <version>${version.commons.codec}</version>
604 </dependency>
605 <dependency>
606 <groupId>com.brsanthu</groupId>
607 <artifactId>migbase64</artifactId>
608 <version>${version.com.brsanthu.migbase64}</version>
574609 </dependency>
575610
576611 <!-- always test-scoped -->
709744 <additionalparam>${javadoc.xdoclint}</additionalparam>
710745 <source>${version.java.source}</source>
711746 <links>
712 <link>${link.javadoc.javase}</link>
747 <link>${javadoc.link.javase}</link>
713748 </links>
714749 <archive>
715750 <manifest>
721756 </manifestEntries>
722757 </archive>
723758 </configuration>
759 </plugin>
760 <plugin>
761 <groupId>org.apache.maven.plugins</groupId>
762 <artifactId>maven-jxr-plugin</artifactId>
763 <version>${version.plugin.maven.jxr}</version>
724764 </plugin>
725765 <plugin>
726766 <groupId>org.apache.maven.plugins</groupId>
785825 <artifactId>maven-surefire-plugin</artifactId>
786826 <version>${version.plugin.maven.surefire}</version>
787827 <configuration>
788 <argLine>${surefire.argline}</argLine>
789828 <forkMode>once</forkMode>
790829 <printSummary>true</printSummary>
791830 <useFile>false</useFile>
816855 <version>${version.plugin.mojo.build-helper}</version>
817856 </plugin>
818857 <plugin>
819 <groupId>org.codehaus.mojo</groupId>
820 <artifactId>cobertura-maven-plugin</artifactId>
821 <version>${version.plugin.mojo.cobertura}</version>
822 <executions>
823 <execution>
824 <goals>
825 <goal>clean</goal>
826 </goals>
827 </execution>
828 </executions>
829 </plugin>
830 <plugin>
831 <groupId>org.codehaus.mojo</groupId>
832 <artifactId>jxr-maven-plugin</artifactId>
833 <version>${version.plugin.mojo.jxr}</version>
834 </plugin>
835 <plugin>
836858 <groupId>org.codehaus.xsite</groupId>
837859 <artifactId>xsite-maven-plugin</artifactId>
838860 <version>${version.plugin.codehaus.xsite}</version>
859881 <groupId>org.eluder.coveralls</groupId>
860882 <artifactId>coveralls-maven-plugin</artifactId>
861883 <version>${version.plugin.eluder.coveralls}</version>
884 </plugin>
885 <plugin>
886 <groupId>org.jacoco</groupId>
887 <artifactId>jacoco-maven-plugin</artifactId>
888 <version>${version.plugin.jacoco}</version>
862889 </plugin>
863890 </plugins>
864891 </pluginManagement>
888915 </configuration>
889916 </plugin>
890917 </plugins>
891 <extensions>
892 <extension>
893 <groupId>org.apache.maven.wagon</groupId>
894 <artifactId>wagon-webdav</artifactId>
895 <version>${version.org.apache.maven.wagon.webdev}</version>
896 </extension>
897 </extensions>
898918 </build>
899919
900920 <distributionManagement>
922942 <properties>
923943 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
924944
945 <version.java.5>1.5</version.java.5>
925946 <version.java.source>1.5</version.java.source>
926947 <version.java.target>1.5</version.java.target>
927948 <version.java.enforced>[1.4,)</version.java.enforced>
939960 <version.plugin.maven.install>2.2</version.plugin.maven.install>
940961 <version.plugin.maven.jar>2.2</version.plugin.maven.jar>
941962 <version.plugin.maven.javadoc>2.10</version.plugin.maven.javadoc>
963 <version.plugin.maven.jxr>2.5</version.plugin.maven.jxr>
942964 <version.plugin.maven.release>2.1</version.plugin.maven.release>
943965 <version.plugin.maven.resources>2.2</version.plugin.maven.resources>
944966 <version.plugin.maven.site>2.0-beta-6</version.plugin.maven.site>
945967 <version.plugin.maven.source>2.1.2</version.plugin.maven.source>
946968 <version.plugin.maven.surefire>2.4.3</version.plugin.maven.surefire>
947969 <version.plugin.mojo.build-helper>1.5</version.plugin.mojo.build-helper>
948 <version.plugin.mojo.cobertura>2.7</version.plugin.mojo.cobertura>
949 <version.plugin.mojo.jxr>2.0-beta-1</version.plugin.mojo.jxr>
950970 <version.plugin.eluder.coveralls>4.2.0</version.plugin.eluder.coveralls>
951
952 <version.org.apache.maven.wagon.webdev>1.0-beta-2</version.org.apache.maven.wagon.webdev>
971 <version.plugin.jacoco>0.8.1</version.plugin.jacoco>
953972
954973 <version.cglib.nodep>2.2</version.cglib.nodep>
974 <version.com.brsanthu.migbase64>2.2</version.com.brsanthu.migbase64>
955975 <version.com.megginson.sax.xml-writer>0.2</version.com.megginson.sax.xml-writer>
956976 <version.commons.cli>1.1</version.commons.cli>
977 <version.commons.codec>1.10</version.commons.codec>
957978 <version.commons.io>1.4</version.commons.io>
958979 <version.commons.lang>2.4</version.commons.lang>
959980 <version.dom4j>1.6.1</version.dom4j>
960981 <version.hsqldb>2.2.8</version.hsqldb>
961982 <version.javaassist>3.12.1.GA</version.javaassist>
962983 <version.javax.activation>1.1.1</version.javax.activation>
984 <version.javax.annotation.api>1.3.2</version.javax.annotation.api>
985 <version.javax.xml.bind.api>2.3.1</version.javax.xml.bind.api>
963986 <version.jmock>1.0.1</version.jmock>
964987 <version.joda-time>1.6</version.joda-time>
965988 <version.junit>3.8.1</version.junit>
971994 <version.org.jdom>1.1.3</version.org.jdom>
972995 <version.org.jdom2>2.0.5</version.org.jdom2>
973996 <version.org.json>20080701</version.org.json>
974 <version.org.openjdk.jmh>1.19</version.org.openjdk.jmh>
997 <version.org.openjdk.jmh>1.21</version.org.openjdk.jmh>
975998 <version.org.slf4j>1.6.1</version.org.slf4j>
976999 <version.oro>2.0.8</version.oro>
9771000 <version.stax>1.2.0</version.stax>
9821005 <version.xom>1.1</version.xom>
9831006 <version.xpp3>1.1.4c</version.xpp3>
9841007
985 <link.javadoc.javase>http://docs.oracle.com/javase/8/docs/api/</link.javadoc.javase>
986
1008 <javadoc.link.javase>http://docs.oracle.com/javase/8/docs/api/</javadoc.link.javase>
1009 <surefire.illegal.access>permit</surefire.illegal.access>
1010
1011 <argLine>${surefire.argline}</argLine>
9871012 <javadoc.xdoclint />
9881013 <surefire.argline />
9891014 </properties>
00 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
11 <!--
22 Copyright (C) 2006 Joe Walnes.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 XStream committers.
3 Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 XStream committers.
44 All rights reserved.
55
66 The software in this package is published under the terms of the BSD
1313 <parent>
1414 <groupId>com.thoughtworks.xstream</groupId>
1515 <artifactId>xstream-parent</artifactId>
16 <version>1.4.10</version>
16 <version>1.4.11</version>
1717 </parent>
1818 <artifactId>xstream</artifactId>
1919 <packaging>jar</packaging>
7878 <optional>true</optional>
7979 </dependency>
8080
81 <!-- Registers itself as Service like Xpp3
8182 <dependency>
8283 <groupId>net.sf.kxml</groupId>
8384 <artifactId>kxml2</artifactId>
8485 <optional>true</optional>
8586 </dependency>
87 -->
8688
8789 <dependency>
8890 <groupId>xpp3</groupId>
104106 <dependency>
105107 <groupId>javax.activation</groupId>
106108 <artifactId>activation</artifactId>
109 <optional>true</optional>
110 </dependency>
111 <dependency>
112 <groupId>javax.xml.bind</groupId>
113 <artifactId>jaxb-api</artifactId>
114 <scope>provided</scope><!-- only required for compilation with Java 11 or higher, but only used by Java 7 or below -->
107115 </dependency>
108116
109117 <!-- test-scoped -->
205213
206214 <profiles>
207215 <profile>
208 <id>jdk19-ge</id>
209 <activation>
210 <jdk>[9,)</jdk>
211 </activation>
216 <id>jdk11-ge</id>
217 <activation>
218 <jdk>[11,)</jdk>
219 </activation>
220 <build>
221 <plugins>
222 <plugin>
223 <groupId>org.apache.maven.plugins</groupId>
224 <artifactId>maven-surefire-plugin</artifactId>
225 <dependencies>
226 <dependency>
227 <groupId>javax.xml.bind</groupId>
228 <artifactId>jaxb-api</artifactId>
229 <version>${version.javax.xml.bind.api}</version>
230 </dependency>
231 </dependencies>
232 </plugin>
233 </plugins>
234 </build>
212235 <properties>
213 <surefire.argline>--add-modules java.activation --permit-illegal-access</surefire.argline>
236 <surefire.argline>--illegal-access=${surefire.illegal.access}</surefire.argline>
237 </properties>
238 </profile>
239 <profile>
240 <id>jdk9-ge-jdk10</id>
241 <activation>
242 <jdk>[9,11)</jdk>
243 </activation>
244 <properties>
245 <surefire.argline>--add-modules java.activation,java.xml.bind --illegal-access=${surefire.illegal.access}</surefire.argline>
214246 </properties>
215247 </profile>
216248 <profile>
231263 <exclude>**/Lambda**</exclude>
232264 <exclude>**/time/**</exclude>
233265 <exclude>**/ISO8601JavaTimeConverter.java</exclude>
266 <exclude>**/annotations/*</exclude>
267 <exclude>**/AnnotationMapper*</exclude>
268 <exclude>**/enums/*</exclude>
269 <exclude>**/EnumMapper*</exclude>
270 <exclude>**/*15.java</exclude>
271 <exclude>**/PathConverter.java</exclude>
272 <exclude>**/Base64*Codec.java</exclude>
273 <exclude>**/Types.java</exclude>
274 <exclude>**/JDom2*.java</exclude>
234275 </excludes>
235276 <testExcludes>
236277 <exclude>**/Lambda**</exclude>
237278 <exclude>**/*18TypesTest.java</exclude>
279 <exclude>**/*17TypesTest.java</exclude>
280 <exclude>**/*15TypesTest.java</exclude>
281 <exclude>**/FieldDictionaryTest.java</exclude>
282 <exclude>**/annotations/*</exclude>
283 <exclude>**/enums/*</exclude>
238284 </testExcludes>
239285 </configuration>
240286 <executions>
241287 <execution>
242 <id>compile-jdk18</id>
288 <id>compile-jdk15</id>
243289 <configuration>
244 <source>1.8</source>
245 <target>1.8</target>
246 <excludes>
247 <exclude>foo</exclude>
248 <exclude>foo</exclude>
249 <exclude>foo</exclude>
290 <source>${version.java.5}</source>
291 <target>${version.java.5}</target>
292 <excludes combine.self="override">
293 <exclude>**/Lambda**</exclude>
294 <exclude>**/time/**</exclude>
295 <exclude>**/ISO8601JavaTimeConverter.java</exclude>
250296 </excludes>
251 <testExcludes>
252 <exclude>foo</exclude>
253 <exclude>foo</exclude>
297 <testExcludes combine.self="override">
298 <exclude>**/Lambda**</exclude>
299 <exclude>**/*18TypesTest.java</exclude>
254300 </testExcludes>
255301 </configuration>
256302 <goals>
258304 <goal>testCompile</goal>
259305 </goals>
260306 </execution>
307 <execution>
308 <id>compile-jdk18</id>
309 <configuration>
310 <source>1.8</source>
311 <target>1.8</target>
312 <excludes combine.self="override" />
313 <textExcludes combine.self="override" />
314 </configuration>
315 <goals>
316 <goal>compile</goal>
317 <goal>testCompile</goal>
318 </goals>
319 </execution>
261320 </executions>
262321 </plugin>
263322 </plugins>
292351 <detectJavaApiLink>false</detectJavaApiLink>
293352 <source>1.8</source>
294353 <links>
295 <link>${link.javadoc.javase}</link>
354 <link>${javadoc.link.javase}</link>
296355 </links>
297356 </configuration>
298357 </plugin>
317376 <exclude>**/Lambda**</exclude>
318377 <exclude>**/time/**</exclude>
319378 <exclude>**/ISO8601JavaTimeConverter.java</exclude>
379 <exclude>**/Base64JavaUtilCodec.java</exclude>
320380 </excludes>
321381 <testExcludes>
322382 <exclude>**/Lambda**</exclude>
383 <exclude>**/Base64JavaUtilCodecTest.java</exclude>
323384 <exclude>**/*18TypesTest.java</exclude>
324385 </testExcludes>
325386 </configuration>
326387 </plugin>
327 </plugins>
328 </build>
329 </profile>
330 <profile>
331 <id>jdk15-16</id>
332 <activation>
333 <jdk>[1.5,1.7)</jdk>
388 <plugin><!-- required for Maven Central -->
389 <groupId>org.apache.maven.plugins</groupId>
390 <artifactId>maven-javadoc-plugin</artifactId>
391 <configuration>
392 <source>1.7</source>
393 <excludePackageNames>com.thoughtworks.xstream.core.util</excludePackageNames>
394 </configuration>
395 </plugin>
396 </plugins>
397 </build>
398 </profile>
399 <profile>
400 <id>jdk16</id>
401 <activation>
402 <jdk>1.6</jdk>
334403 </activation>
335404 <build>
336405 <plugins>
346415 <exclude>**/extended/PathConverter*</exclude>
347416 <exclude>**/time/**</exclude>
348417 <exclude>**/ISO8601JavaTimeConverter.java</exclude>
418 <exclude>**/Base64JavaUtilCodec.java</exclude>
349419 </excludes>
350420 <testExcludes>
351421 <exclude>**/Lambda**</exclude>
352422 <exclude>**/extended/*17Test*</exclude>
423 <exclude>**/Base64JavaUtilCodecTest.java</exclude>
353424 <exclude>**/acceptance/Extended17TypesTest*</exclude>
354425 <exclude>**/acceptance/*18TypesTest.java</exclude>
355426 </testExcludes>
359430 </build>
360431 </profile>
361432 <profile>
362 <id>jdk15-ge</id>
363 <activation>
364 <jdk>[1.5,)</jdk>
433 <id>jdk15</id>
434 <activation>
435 <jdk>1.5</jdk>
436 </activation>
437 <build>
438 <plugins>
439 <plugin>
440 <groupId>org.apache.maven.plugins</groupId>
441 <artifactId>maven-compiler-plugin</artifactId>
442 <configuration>
443 <compilerArgs>
444 <arg>-XDignore.symbol.file</arg>
445 </compilerArgs>
446 <excludes>
447 <exclude>**/Lambda**</exclude>
448 <exclude>**/extended/PathConverter*</exclude>
449 <exclude>**/time/**</exclude>
450 <exclude>**/ISO8601JavaTimeConverter.java</exclude>
451 <exclude>**/Base64JavaUtilCodec.java</exclude>
452 <exclude>**/Base64JAXBCodec.java</exclude>
453 </excludes>
454 <testExcludes>
455 <exclude>**/Lambda**</exclude>
456 <exclude>**/extended/*17Test*</exclude>
457 <exclude>**/Base64JavaUtilCodecTest.java</exclude>
458 <exclude>**/Base64JAXBCodecTest.java</exclude>
459 <exclude>**/acceptance/Extended17TypesTest*</exclude>
460 <exclude>**/acceptance/*18TypesTest.java</exclude>
461 </testExcludes>
462 </configuration>
463 </plugin>
464 </plugins>
465 </build>
466 </profile>
467 <profile>
468 <id>jdk16-ge</id>
469 <activation>
470 <jdk>[1.6,)</jdk>
365471 </activation>
366472 <build>
367473 <plugins>
417523 <exclude>**/enums/*</exclude>
418524 <exclude>**/time/**</exclude>
419525 <exclude>**/ISO8601JavaTimeConverter.java</exclude>
526 <exclude>**/Base64JavaUtilCodec.java</exclude>
527 <exclude>**/Base64JAXBCodec.java</exclude>
420528 <exclude>**/basic/StringBuilder*</exclude>
421529 <exclude>**/basic/UUID*</exclude>
422530 <exclude>**/core/util/Types*</exclude>
531 <exclude>**/reflection/*15*</exclude>
423532 <exclude>**/extended/*15*</exclude>
424533 <exclude>**/extended/PathConverter*</exclude>
425534 <exclude>**/io/xml/JDom2*</exclude>
431540 <exclude>**/extended/*17Test*</exclude>
432541 <exclude>**/reflection/SunLimitedUnsafeReflectionProviderTest*</exclude>
433542 <exclude>**/reflection/PureJavaReflectionProvider15Test*</exclude>
543 <exclude>**/Base64JavaUtilCodecTest.java</exclude>
544 <exclude>**/Base64JAXBCodecTest.java</exclude>
434545 <exclude>**/io/xml/JDom2*Test*</exclude>
435546 <exclude>**/acceptance/Basic15TypesTest*</exclude>
436547 <exclude>**/acceptance/Concurrent15TypesTest*</exclude>
465576 <version>${version.plugin.maven.surefire}</version>
466577 </plugin>
467578 <plugin>
468 <groupId>org.codehaus.mojo</groupId>
469 <artifactId>cobertura-maven-plugin</artifactId>
470 <version>${version.plugin.mojo.cobertura}</version>
579 <groupId>org.jacoco</groupId>
580 <artifactId>jacoco-maven-plugin</artifactId>
581 <version>${version.plugin.jacoco}</version>
582 <reportSets>
583 <reportSet>
584 <reports>
585 <report>report</report>
586 </reports>
587 </reportSet>
588 </reportSets>
471589 </plugin>
472590 </plugins>
473591 </reporting>
474592
475593 <properties>
476594 <bundle.export.package>!com.thoughtworks.xstream.core.util,com.thoughtworks.xstream.*;-noimport:=true</bundle.export.package>
595 <bundle.import.package>org.xmlpull.mxp1;resolution:=optional,org.xmlpull.v1;resolution:=optional,*</bundle.import.package>
477596 </properties>
478597
479598 </project>
00 /*
11 * Copyright (C) 2003, 2004, 2005, 2006 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
337337 private SecurityMapper securityMapper;
338338 private AnnotationConfiguration annotationConfiguration;
339339
340 private transient boolean insecureWarning;
340 private transient boolean securityInitialized;
341 private transient boolean securityWarningGiven;
341342
342343 public static final int NO_REFERENCES = 1001;
343344 public static final int ID_REFERENCES = 1002;
610611 mapper = new ArrayMapper(mapper);
611612 mapper = new DefaultImplementationsMapper(mapper);
612613 mapper = new AttributeMapper(mapper, converterLookup, reflectionProvider);
613 if (JVM.is15()) {
614 if (JVM.isVersion(5)) {
614615 mapper = buildMapperDynamically(
615616 "com.thoughtworks.xstream.mapper.EnumMapper", new Class[]{Mapper.class},
616617 new Object[]{mapper});
617618 }
618619 mapper = new LocalConversionMapper(mapper);
619620 mapper = new ImmutableTypesMapper(mapper);
620 if (JVM.is18()) {
621 if (JVM.isVersion(8)) {
621622 mapper = buildMapperDynamically("com.thoughtworks.xstream.mapper.LambdaMapper", new Class[]{Mapper.class},
622623 new Object[]{mapper});
623624 }
624625 mapper = new SecurityMapper(mapper);
625 if (JVM.is15()) {
626 if (JVM.isVersion(5)) {
626627 mapper = buildMapperDynamically(ANNOTATION_MAPPER_TYPE, new Class[]{
627628 Mapper.class, ConverterRegistry.class, ConverterLookup.class,
628629 ClassLoaderReference.class, ReflectionProvider.class}, new Object[]{
695696 }
696697
697698 addPermission(AnyTypePermission.ANY);
698 insecureWarning = true;
699 securityInitialized = false;
699700 }
700701
701702 /**
710711 * @since 1.4.10
711712 */
712713 public static void setupDefaultSecurity(final XStream xstream) {
713 if (xstream.insecureWarning) {
714 if (!xstream.securityInitialized) {
714715 xstream.addPermission(NoTypePermission.NONE);
715716 xstream.addPermission(NullPermission.NULL);
716717 xstream.addPermission(PrimitiveTypePermission.PRIMITIVES);
757758 types.add(JVM.loadClassForName("java.sql.Time"));
758759 types.add(JVM.loadClassForName("java.sql.Date"));
759760 }
760 if (JVM.is18()) {
761 if (JVM.isVersion(8)) {
761762 xstream.allowTypeHierarchy(JVM.loadClassForName("java.time.Clock"));
762763 types.add(JVM.loadClassForName("java.time.Duration"));
763764 types.add(JVM.loadClassForName("java.time.Instant"));
870871 alias("locale", Locale.class);
871872 alias("gregorian-calendar", Calendar.class);
872873
873 if (JVM.is14()) {
874 if (JVM.isVersion(4)) {
874875 aliasDynamically("auth-subject", "javax.security.auth.Subject");
875876 alias("linked-hash-map", JVM.loadClassForName("java.util.LinkedHashMap"));
876877 alias("linked-hash-set", JVM.loadClassForName("java.util.LinkedHashSet"));
879880 aliasType("charset", JVM.loadClassForName("java.nio.charset.Charset"));
880881 }
881882
882 if (JVM.is15()) {
883 if (JVM.isVersion(5)) {
883884 aliasDynamically("xml-duration", "javax.xml.datatype.Duration");
884885 alias("concurrent-hash-map", JVM.loadClassForName("java.util.concurrent.ConcurrentHashMap"));
885886 alias("enum-set", JVM.loadClassForName("java.util.EnumSet"));
888889 alias("uuid", JVM.loadClassForName("java.util.UUID"));
889890 }
890891
891 if (JVM.is17()) {
892 if (JVM.isVersion(7)) {
892893 aliasType("path", JVM.loadClassForName("java.nio.file.Path"));
893894 }
894895
895 if (JVM.is18()) {
896 if (JVM.isVersion(8)) {
896897 alias("fixed-clock", JVM.loadClassForName("java.time.Clock$FixedClock"));
897898 alias("offset-clock", JVM.loadClassForName("java.time.Clock$OffsetClock"));
898899 alias("system-clock", JVM.loadClassForName("java.time.Clock$SystemClock"));
10151016 registerConverter(new LocaleConverter(), PRIORITY_NORMAL);
10161017 registerConverter(new GregorianCalendarConverter(), PRIORITY_NORMAL);
10171018
1018 if (JVM.is14()) {
1019 if (JVM.isVersion(4)) {
10191020 // late bound converters - allows XStream to be compiled on earlier JDKs
10201021 registerConverterDynamically(
10211022 "com.thoughtworks.xstream.converters.extended.SubjectConverter",
10381039 PRIORITY_NORMAL, null, null);
10391040 }
10401041
1041 if (JVM.is15()) {
1042 if (JVM.isVersion(5)) {
10421043 // late bound converters - allows XStream to be compiled on earlier JDKs
10431044 if (JVM.loadClassForName("javax.xml.datatype.Duration") != null) {
10441045 registerConverterDynamically(
10651066 registerConverterDynamically("com.thoughtworks.xstream.converters.extended.ActivationDataFlavorConverter",
10661067 PRIORITY_NORMAL, null, null);
10671068 }
1068 if (JVM.is17()) {
1069 if (JVM.isVersion(7)) {
10691070 registerConverterDynamically("com.thoughtworks.xstream.converters.extended.PathConverter",
10701071 PRIORITY_NORMAL, null, null);
10711072 }
1072 if (JVM.is18()) {
1073 if (JVM.isVersion(8)) {
10731074 registerConverterDynamically("com.thoughtworks.xstream.converters.time.ChronologyConverter",
10741075 PRIORITY_NORMAL, null, null);
10751076 registerConverterDynamically("com.thoughtworks.xstream.converters.time.DurationConverter", PRIORITY_NORMAL,
11751176 addImmutableType(File.class, false);
11761177 addImmutableType(Class.class, false);
11771178
1178 if (JVM.is17()) {
1179 if (JVM.isVersion(7)) {
11791180 Class type = JVM.loadClassForName("java.nio.file.Paths");
11801181 if (type != null) {
11811182 Method methodGet;
11991200 addImmutableTypeDynamically("java.awt.font.TextAttribute", false);
12001201 }
12011202
1202 if (JVM.is14()) {
1203 if (JVM.isVersion(4)) {
12031204 // late bound types - allows XStream to be compiled on earlier JDKs
12041205 addImmutableTypeDynamically("java.nio.charset.Charset", true);
12051206 addImmutableTypeDynamically("java.util.Currency", true);
12061207 }
12071208
1208 if (JVM.is15()) {
1209 if (JVM.isVersion(5)) {
12091210 addImmutableTypeDynamically("java.util.UUID", true);
12101211 }
12111212
12141215 addImmutableType(Collections.EMPTY_SET.getClass(), true);
12151216 addImmutableType(Collections.EMPTY_MAP.getClass(), true);
12161217
1217 if (JVM.is18()) {
1218 if (JVM.isVersion(8)) {
12181219 addImmutableTypeDynamically("java.time.Duration", false);
12191220 addImmutableTypeDynamically("java.time.Instant", false);
12201221 addImmutableTypeDynamically("java.time.LocalDate", false);
14781479 */
14791480 public Object unmarshal(HierarchicalStreamReader reader, Object root, DataHolder dataHolder) {
14801481 try {
1481 if (insecureWarning) {
1482 insecureWarning = false;
1482 if (!securityInitialized && !securityWarningGiven) {
1483 securityWarningGiven = true;
14831484 System.err.println("Security framework of XStream not initialized, XStream is probably vulnerable.");
14841485 }
14851486 return marshallingStrategy.unmarshal(
23582359 */
23592360 public void addPermission(TypePermission permission) {
23602361 if (securityMapper != null) {
2361 insecureWarning &= permission != NoTypePermission.NONE;
2362 securityInitialized = true;
23622363 securityMapper.addPermission(permission);
23632364 }
23642365 }
25092510 denyPermission(new WildcardTypePermission(patterns));
25102511 }
25112512
2513 private Object readResolve() {
2514 securityWarningGiven = true;
2515 return this;
2516 }
2517
25122518 /**
25132519 * @deprecated As of 1.3, use {@link com.thoughtworks.xstream.InitializationException}
25142520 * instead
25372543
25382544 public boolean canConvert(final Class type) {
25392545 return (type == void.class || type == Void.class)
2540 || (insecureWarning
2546 || (!securityInitialized
25412547 && type != null
25422548 && (type.getName().equals("java.beans.EventHandler")
25432549 || type.getName().endsWith("$LazyIterator")
00 /*
1 * Copyright (C) 2006, 2007, 2014, 2016, 2017 XStream Committers.
1 * Copyright (C) 2006, 2007, 2014, 2016, 2017, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
3535 import com.thoughtworks.xstream.io.naming.NameCoder;
3636 import com.thoughtworks.xstream.io.xml.XppDriver;
3737 import com.thoughtworks.xstream.mapper.Mapper;
38 import com.thoughtworks.xstream.security.AnyTypePermission;
3938 import com.thoughtworks.xstream.security.TypeHierarchyPermission;
4039 import com.thoughtworks.xstream.security.TypePermission;
4140 import com.thoughtworks.xstream.security.WildcardTypePermission;
251250 */
252251 public Object fromXML(final HierarchicalStreamDriver driver, final Reader xml)
253252 throws IOException, ClassNotFoundException {
254 return fromXML(driver, xml, new TypePermission[]{AnyTypePermission.ANY});
253 return fromXML(driver, xml, PERMISSIONS);
255254 }
256255
257256 /**
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2121 public class BigDecimalConverter extends AbstractSingleValueConverter {
2222
2323 public boolean canConvert(Class type) {
24 return type.equals(BigDecimal.class);
24 return type == BigDecimal.class;
2525 }
2626
2727 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2020 public class BigIntegerConverter extends AbstractSingleValueConverter {
2121
2222 public boolean canConvert(Class type) {
23 return type.equals(BigInteger.class);
23 return type == BigInteger.class;
2424 }
2525
2626 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2014 XStream Committers.
2 * Copyright (C) 2006, 2007, 2014, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2121 public class BooleanConverter extends AbstractSingleValueConverter {
2222
2323 public static final BooleanConverter TRUE_FALSE = new BooleanConverter("true", "false", false);
24
2524 public static final BooleanConverter YES_NO = new BooleanConverter("yes", "no", false);
26
2725 public static final BooleanConverter BINARY = new BooleanConverter("1", "0", true);
2826
2927 private final String positive;
4846 }
4947
5048 public boolean canConvert(final Class type) {
51 return type.equals(boolean.class) || type.equals(Boolean.class);
49 return type == boolean.class || type == Boolean.class;
5250 }
5351
5452 public Object fromString(final String str) {
00 /*
11 * Copyright (C) 2003, 2004, 2005, 2006 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
1919 public class ByteConverter extends AbstractSingleValueConverter {
2020
2121 public boolean canConvert(Class type) {
22 return type.equals(byte.class) || type.equals(Byte.class);
22 return type == byte.class || type == Byte.class;
2323 }
2424
2525 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2727 public class CharConverter implements Converter, SingleValueConverter {
2828
2929 public boolean canConvert(Class type) {
30 return type.equals(char.class) || type.equals(Character.class);
30 return type == char.class || type == Character.class;
3131 }
3232
3333 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015, 2016 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015, 2016, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
200200 }
201201
202202 public boolean canConvert(Class type) {
203 return type.equals(Date.class);
203 return type == Date.class;
204204 }
205205
206206 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
1919 public class DoubleConverter extends AbstractSingleValueConverter {
2020
2121 public boolean canConvert(Class type) {
22 return type.equals(double.class) || type.equals(Double.class);
22 return type == double.class || type == Double.class;
2323 }
2424
2525 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
1919 public class FloatConverter extends AbstractSingleValueConverter {
2020
2121 public boolean canConvert(Class type) {
22 return type.equals(float.class) || type.equals(Float.class);
22 return type == float.class || type == Float.class;
2323 }
2424
2525 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2014, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
1919 public class IntConverter extends AbstractSingleValueConverter {
2020
2121 public boolean canConvert(Class type) {
22 return type.equals(int.class) || type.equals(Integer.class);
22 return type == int.class || type == Integer.class;
2323 }
2424
2525 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
1818 public class LongConverter extends AbstractSingleValueConverter {
1919
2020 public boolean canConvert(Class type) {
21 return type.equals(long.class) || type.equals(Long.class);
21 return type == long.class || type == Long.class;
2222 }
2323
2424 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
1919 public class ShortConverter extends AbstractSingleValueConverter {
2020
2121 public boolean canConvert(Class type) {
22 return type.equals(short.class) || type.equals(Short.class);
22 return type == short.class || type == Short.class;
2323 }
2424
2525 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2222 }
2323
2424 public boolean canConvert(Class type) {
25 return type.equals(StringBuffer.class);
25 return type == StringBuffer.class;
2626 }
2727 }
00 /*
1 * Copyright (C) 2008 XStream Committers.
1 * Copyright (C) 2008, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
2121 }
2222
2323 public boolean canConvert(Class type) {
24 return type.equals(StringBuilder.class);
24 return type == StringBuilder.class;
2525 }
2626 }
00 /*
11 * Copyright (C) 2003, 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2011 XStream Committers.
2 * Copyright (C) 2006, 2007, 2011, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
8080 }
8181
8282 public boolean canConvert(final Class type) {
83 return type.equals(String.class);
83 return type == String.class;
8484 }
8585
8686 public Object fromString(final String str) {
00 /*
1 * Copyright (C) 2010 XStream Committers.
1 * Copyright (C) 2010, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
2323 public class URIConverter extends AbstractSingleValueConverter {
2424
2525 public boolean canConvert(Class type) {
26 return type.equals(URI.class);
26 return type == URI.class;
2727 }
2828
2929 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2323 public class URLConverter extends AbstractSingleValueConverter {
2424
2525 public boolean canConvert(Class type) {
26 return type.equals(URL.class);
26 return type == URL.class;
2727 }
2828
2929 public Object fromString(String str) {
00 /*
1 * Copyright (C) 2008 XStream Committers.
1 * Copyright (C) 2008, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
2222 public class UUIDConverter extends AbstractSingleValueConverter {
2323
2424 public boolean canConvert(Class type) {
25 return type.equals(UUID.class);
25 return type == UUID.class;
2626 }
2727
2828 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2013, 2016 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2013, 2016, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
5050
5151 public abstract Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context);
5252
53
54
53 /**
54 * @deprecated As of 1.4.11 use {@link #writeCompleteItem(Object, MarshallingContext, HierarchicalStreamWriter)}
55 * instead.
56 */
5557 protected void writeItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) {
5658 // PUBLISHED API METHOD! If changing signature, ensure backwards compatibility.
5759 if (item == null) {
5860 // todo: this is duplicated in TreeMarshaller.start()
59 String name = mapper().serializedClass(null);
60 ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, Mapper.Null.class);
61 writer.endNode();
61 writeNullItem(context, writer);
6262 } else {
6363 String name = mapper().serializedClass(item.getClass());
6464 ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, item.getClass());
65 context.convertAnother(item);
65 writeBareItem(item, context, writer);
6666 writer.endNode();
6767 }
6868 }
6969
70 protected Object readItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) {
70 /**
71 * Write an item of the collection into the writer including surrounding tags.
72 *
73 * @param item the item to write
74 * @param context the current marshalling context
75 * @param writer the target writer
76 * @since 1.4.11
77 */
78 protected void writeCompleteItem(final Object item, final MarshallingContext context,
79 final HierarchicalStreamWriter writer) {
80 writeItem(item, context, writer);
81 }
82
83 /**
84 * Write the bare item of the collection into the writer.
85 *
86 * @param item the item to write
87 * @param context the current marshalling context
88 * @param writer the target writer
89 * @since 1.4.11
90 */
91 protected void writeBareItem(final Object item, final MarshallingContext context,
92 final HierarchicalStreamWriter writer) {
93 context.convertAnother(item);
94 }
95
96 /**
97 * Write a null item of the collection into the writer. The method readItem should be able to process the written
98 * data i.e. it has to write the tags or may not write anything at all.
99 *
100 * @param context the current marshalling context
101 * @param writer the target writer
102 * @since 1.4.11
103 */
104 protected void writeNullItem(final MarshallingContext context, final HierarchicalStreamWriter writer) {
105 final String name = mapper().serializedClass(null);
106 ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, Mapper.Null.class);
107 writer.endNode();
108 }
109
110 /**
111 * @deprecated As of 1.4.11 use {@link #readBareItem(HierarchicalStreamReader, UnmarshallingContext, Object)} or
112 * {@link #readCompleteItem(HierarchicalStreamReader, UnmarshallingContext, Object)} instead.
113 */
114 protected Object readItem(final HierarchicalStreamReader reader, final UnmarshallingContext context,
115 final Object current) {
116 return readBareItem(reader, context, current);
117 }
118
119 /**
120 * Read a bare item of the collection from the reader.
121 *
122 * @param reader the source reader
123 * @param context the unmarshalling context
124 * @param current the target collection (if already available)
125 * @return the read item
126 * @since 1.4.11
127 */
128 protected Object readBareItem(final HierarchicalStreamReader reader, final UnmarshallingContext context,
129 final Object current) {
71130 Class type = HierarchicalStreams.readClassType(reader, mapper());
72131 return context.convertAnother(current, type);
132 }
133
134 /**
135 * Read an item of the collection including the tags from the reader.
136 *
137 * @param reader the source reader
138 * @param context the unmarshalling context
139 * @param current the target collection (if already available)
140 * @return the read item
141 * @since 1.4.11
142 */
143 protected Object readCompleteItem(final HierarchicalStreamReader reader, final UnmarshallingContext context,
144 final Object current) {
145 reader.moveDown();
146 final Object result = readItem(reader, context, current);
147 reader.moveUp();
148 return result;
73149 }
74150
75151 protected Object createCollection(Class type) {
00 /*
11 * Copyright (C) 2003, 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
3434 }
3535
3636 public boolean canConvert(Class type) {
37 return type.isArray();
37 return type != null && type.isArray();
3838 }
3939
4040 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
4141 int length = Array.getLength(source);
4242 for (int i = 0; i < length; i++) {
43 Object item = Array.get(source, i);
44 writeItem(item, context, writer);
43 final Object item = Array.get(source, i);
44 writeCompleteItem(item, context, writer);
4545 }
4646
4747 }
5050 // read the items from xml into a list
5151 List items = new ArrayList();
5252 while (reader.hasMoreChildren()) {
53 reader.moveDown();
54 Object item = readItem(reader, context, null); // TODO: arg, what should replace null?
53 final Object item = readCompleteItem(reader, context, null); // TODO: arg, what should replace null?
5554 items.add(item);
56 reader.moveUp();
5755 }
5856 // now convertAnother the list into an array
5957 // (this has to be done as a separate list as the array size is not
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2828 public class BitSetConverter implements Converter {
2929
3030 public boolean canConvert(Class type) {
31 return type.equals(BitSet.class);
31 return type == BitSet.class;
3232 }
3333
3434 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2525 public class CharArrayConverter implements Converter {
2626
2727 public boolean canConvert(Class type) {
28 return type.isArray() && type.getComponentType().equals(char.class);
28 return type != null && type.isArray() && type.getComponentType().equals(char.class);
2929 }
3030
3131 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2003, 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2010, 2011, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2010, 2011, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
1212
1313 import com.thoughtworks.xstream.converters.MarshallingContext;
1414 import com.thoughtworks.xstream.converters.UnmarshallingContext;
15 import com.thoughtworks.xstream.core.JVM;
1615 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
1716 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
1817 import com.thoughtworks.xstream.mapper.Mapper;
2120 import java.util.Collection;
2221 import java.util.HashSet;
2322 import java.util.Iterator;
23 import java.util.LinkedHashSet;
2424 import java.util.LinkedList;
2525 import java.util.Vector;
2626
6363 || type.equals(HashSet.class)
6464 || type.equals(LinkedList.class)
6565 || type.equals(Vector.class)
66 || (JVM.is14() && type.getName().equals("java.util.LinkedHashSet"));
66 || type.equals(LinkedHashSet.class);
6767 }
6868
6969 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
7070 Collection collection = (Collection) source;
7171 for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
7272 Object item = iterator.next();
73 writeItem(item, context, writer);
73 writeCompleteItem(item, context, writer);
7474 }
7575 }
7676
9494
9595 protected void addCurrentElementToCollection(HierarchicalStreamReader reader, UnmarshallingContext context,
9696 Collection collection, Collection target) {
97 Object item = readItem(reader, context, collection);
97 final Object item = readItem(reader, context, collection); // call readBareItem when deprecated method is removed
9898 target.add(item);
9999 }
100100
00 /*
11 * Copyright (C) 2003, 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
7474 Map.Entry entry = (Map.Entry) iterator.next();
7575 ExtendedHierarchicalStreamWriterHelper.startNode(writer, entryName, entry.getClass());
7676
77 writeItem(entry.getKey(), context, writer);
78 writeItem(entry.getValue(), context, writer);
77 writeCompleteItem(entry.getKey(), context, writer);
78 writeCompleteItem(entry.getValue(), context, writer);
7979
8080 writer.endNode();
8181 }
101101
102102 protected void putCurrentEntryIntoMap(HierarchicalStreamReader reader, UnmarshallingContext context,
103103 Map map, Map target) {
104 reader.moveDown();
105 Object key = readItem(reader, context, map);
106 reader.moveUp();
107
108 reader.moveDown();
109 Object value = readItem(reader, context, map);
110 reader.moveUp();
111
104 final Object key = readCompleteItem(reader, context, map);
105 final Object value = readCompleteItem(reader, context, map);
112106 target.put(key, value);
113107 }
114108
00 /*
1 * Copyright (C) 2011 XStream Committers.
1 * Copyright (C) 2011, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
4646 }
4747
4848 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
49 reader.moveDown();
50 Object item = readItem(reader, context, null);
51 reader.moveUp();
49 final Object item = readCompleteItem(reader, context, null);
5250 return context.getRequiredType() == LIST
5351 ? (Object)Collections.singletonList(item)
5452 : (Object)Collections.singleton(item);
00 /*
1 * Copyright (C) 2011 XStream Committers.
1 * Copyright (C) 2011, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
4545
4646 public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
4747 reader.moveDown();
48 reader.moveDown();
49 Object key = readItem(reader, context, null);
50 reader.moveUp();
51
52 reader.moveDown();
53 Object value = readItem(reader, context, null);
54 reader.moveUp();
48 final Object key = readCompleteItem(reader, context, null);
49 final Object value = readCompleteItem(reader, context, null);
5550 reader.moveUp();
5651
5752 return Collections.singletonMap(key, value);
00 /*
11 * Copyright (C) 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2010, 2011, 2013, 2016 XStream Committers.
2 * Copyright (C) 2006, 2007, 2010, 2011, 2013, 2016, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
7373 TreeMap result = comparatorField != null ? new TreeMap() : null;
7474 final Comparator comparator = unmarshalComparator(reader, context, result);
7575 if (result == null) {
76 result = comparator == null ? new TreeMap() : new TreeMap(comparator);
76 result = comparator == null || comparator == NULL_MARKER ? new TreeMap() : new TreeMap(comparator);
7777 }
7878 populateTreeMap(reader, context, result, comparator);
7979 return result;
00 /*
11 * Copyright (C) 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2010, 2011, 2013, 2014, 2016 XStream Committers.
2 * Copyright (C) 2006, 2007, 2010, 2011, 2013, 2014, 2016, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
149149
150150 protected void putCurrentEntryIntoMap(HierarchicalStreamReader reader, UnmarshallingContext context,
151151 Map map, Map target) {
152 Object key = readItem(reader, context, map);
152 final Object key = readItem(reader, context, map); // call readBareItem when deprecated method is removed
153153 target.put(key, key);
154154 }
155155 };
00 /*
11 * Copyright (C) 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2009, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2009, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
3030 public class EnumConverter implements Converter {
3131
3232 public boolean canConvert(Class type) {
33 return type.isEnum() || Enum.class.isAssignableFrom(type);
33 return type != null && type.isEnum() || Enum.class.isAssignableFrom(type);
3434 }
3535
3636 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2009 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
4646 }
4747
4848 public boolean canConvert(Class type) {
49 return typeField != null && EnumSet.class.isAssignableFrom(type);
49 return typeField != null && type != null && EnumSet.class.isAssignableFrom(type);
5050 }
5151
5252 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
1 * Copyright (C) 2008, 2009, 2010, 2013 XStream Committers.
1 * Copyright (C) 2008, 2009, 2010, 2013, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
3232
3333 @Override
3434 public boolean canConvert(Class type) {
35 return enumType.isAssignableFrom(type);
35 return type != null && enumType.isAssignableFrom(type);
3636 }
3737
3838 @Override
00 /*
1 * Copyright (C) 2013, 2016 XStream Committers.
1 * Copyright (C) 2013, 2016, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
7777
7878 @Override
7979 public boolean canConvert(Class type) {
80 return enumType.isAssignableFrom(type);
80 return type != null && enumType.isAssignableFrom(type);
8181 }
8282
8383 @Override
00 /*
1 * Copyright (C) 2006, 2007 XStream Committers.
1 * Copyright (C) 2006, 2007, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
2222 public class CharsetConverter extends AbstractSingleValueConverter {
2323
2424 public boolean canConvert(Class type) {
25 return Charset.class.isAssignableFrom(type);
25 return type != null && Charset.class.isAssignableFrom(type);
2626 }
2727
2828 public String toString(Object obj) {
3232 public boolean canConvert(Class type) {
3333 // String comparison is used here because Color.class loads the class which in turns instantiates AWT,
3434 // which is nasty if you don't want it.
35 return type.getName().equals("java.awt.Color");
35 return type != null && type.getName().equals("java.awt.Color");
3636 }
3737
3838 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2424 public class CurrencyConverter extends AbstractSingleValueConverter {
2525
2626 public boolean canConvert(Class type) {
27 return type.equals(Currency.class);
27 return type == Currency.class;
2828 }
2929
3030 public Object fromString(String str) {
00 /*
1 * Copyright (C) 2007, 2008, 2011 XStream Committers.
1 * Copyright (C) 2007, 2008, 2011, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
4747 this.factory = factory;
4848 }
4949
50 public boolean canConvert(Class c) {
51 return factory != null && Duration.class.isAssignableFrom(c);
50 public boolean canConvert(Class type) {
51 return factory != null && type != null && Duration.class.isAssignableFrom(type);
5252 }
5353
5454 public Object fromString(String s) {
00 /*
11 * Copyright (C) 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2010, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2010, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
7171 }
7272
7373 public boolean canConvert(Class type) {
74 return type.equals(DynamicProxyMapper.DynamicProxy.class) || Proxy.isProxyClass(type);
74 return type != null && (type.equals(DynamicProxyMapper.DynamicProxy.class) || Proxy.isProxyClass(type));
7575 }
7676
7777 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2010 XStream Committers.
2 * Copyright (C) 2006, 2007, 2010, 2017, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
66 * style license a copy of which has been included with this distribution in
77 * the LICENSE.txt file.
8 *
8 *
99 * Created on 03. March 2004 by Joe Walnes
1010 */
1111 package com.thoughtworks.xstream.converters.extended;
1515 import com.thoughtworks.xstream.converters.SingleValueConverter;
1616 import com.thoughtworks.xstream.converters.UnmarshallingContext;
1717 import com.thoughtworks.xstream.converters.basic.ByteConverter;
18 import com.thoughtworks.xstream.core.util.Base64Encoder;
18 import com.thoughtworks.xstream.core.JVM;
19 import com.thoughtworks.xstream.core.StringCodec;
1920 import com.thoughtworks.xstream.io.HierarchicalStreamReader;
2021 import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
2122
2425 import java.util.List;
2526
2627 /**
27 * Converts a byte array to a single Base64 encoding string.
28 * Converts a byte array by default to a single Base64 encoding string.
2829 *
2930 * @author Joe Walnes
3031 * @author J&ouml;rg Schaible
3132 */
3233 public class EncodedByteArrayConverter implements Converter, SingleValueConverter {
3334
34 private static final Base64Encoder base64 = new Base64Encoder();
3535 private static final ByteConverter byteConverter = new ByteConverter();
36 private final StringCodec codec;
37
38 /**
39 * Constructs an EncodedByteArrayConverter. Initializes the converter with a Base64 codec.
40 */
41 public EncodedByteArrayConverter() {
42 this(JVM.getBase64Codec());
43 }
44
45 /**
46 * Constructs an EncodedByteArrayConverter with a provided string codec.
47 *
48 * @param stringCodec the codec to encode and decode the data as string
49 * @since 1.4.11
50 */
51 public EncodedByteArrayConverter(final StringCodec stringCodec) {
52 codec = stringCodec;
53 }
3654
3755 public boolean canConvert(Class type) {
38 return type.isArray() && type.getComponentType().equals(byte.class);
56 return type != null && type.isArray() && type.getComponentType().equals(byte.class);
3957 }
4058
4159 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
7290 return result;
7391 }
7492
75 public String toString(Object obj) {
76 return base64.encode((byte[]) obj);
93 public String toString(final Object obj) {
94 return codec.encode((byte[])obj);
7795 }
7896
79 public Object fromString(String str) {
80 return base64.decode(str);
97 public Object fromString(final String str) {
98 return codec.decode(str);
8199 }
82100 }
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2323 public class FileConverter extends AbstractSingleValueConverter {
2424
2525 public boolean canConvert(Class type) {
26 return type.equals(File.class);
26 return type == File.class;
2727 }
2828
2929 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
5959 public boolean canConvert(Class type) {
6060 // String comparison is used here because Font.class loads the class which in turns instantiates AWT,
6161 // which is nasty if you don't want it.
62 return type.getName().equals("java.awt.Font") || type.getName().equals("javax.swing.plaf.FontUIResource");
62 return type != null
63 && (type.getName().equals("java.awt.Font") || type.getName().equals("javax.swing.plaf.FontUIResource"));
6364 }
6465
6566 public void marshal(Object source, HierarchicalStreamWriter writer,
112113 } else {
113114 attributes = Collections.EMPTY_MAP;
114115 }
115 if (!JVM.is16()) {
116 if (!JVM.isVersion(6)) {
116117 for (Iterator iter = attributes.values().iterator(); iter.hasNext(); ) {
117118 if (iter.next() == null) {
118119 iter.remove();
3131 public class GregorianCalendarConverter implements Converter {
3232
3333 public boolean canConvert(Class type) {
34 return type.equals(GregorianCalendar.class);
34 return type == GregorianCalendar.class;
3535 }
3636
3737 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2017 XStream Committers.
2 * Copyright (C) 2006, 2007, 2017, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2828 private final ISO8601GregorianCalendarConverter converter = new ISO8601GregorianCalendarConverter();
2929
3030 public boolean canConvert(Class type) {
31 return type.equals(Date.class) && converter.canConvert(GregorianCalendar.class);
31 return type == Date.class && converter.canConvert(GregorianCalendar.class);
3232 }
3333
3434 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2011, 2013, 2014, 2015, 2016, 2017 XStream Committers.
2 * Copyright (C) 2006, 2007, 2011, 2013, 2014, 2015, 2016, 2017, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
3434
3535 public ISO8601GregorianCalendarConverter() {
3636 SingleValueConverter svConverter = null;
37 final Class type = JVM.loadClassForName(JVM.is18()
37 final Class type = JVM.loadClassForName(JVM.isVersion(8)
3838 ? "com.thoughtworks.xstream.core.util.ISO8601JavaTimeConverter"
3939 : "com.thoughtworks.xstream.core.util.ISO8601JodaTimeConverter");
4040 try {
5353 }
5454
5555 public boolean canConvert(final Class type) {
56 return converter != null && type.equals(GregorianCalendar.class);
56 return converter != null && type == GregorianCalendar.class;
5757 }
5858
5959 public Object fromString(final String str) {
00 /*
11 * Copyright (C) 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2017 XStream Committers.
2 * Copyright (C) 2006, 2007, 2017, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2626 private final static String PADDING = "000000000";
2727
2828 public boolean canConvert(Class type) {
29 return type.equals(Timestamp.class) && super.canConvert(Date.class);
29 return type == Timestamp.class && super.canConvert(Date.class);
3030 }
3131
3232 public Object fromString(String str) {
00 /*
1 * Copyright (C) 2009, 2013 XStream Committers.
1 * Copyright (C) 2009, 2013, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
6060 }
6161
6262 public boolean canConvert(Class type) {
63 return type.equals(Field.class);
63 return type == Field.class;
6464 }
6565
6666 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2009, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2009, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
6060 }
6161
6262 public boolean canConvert(Class type) {
63 return type.equals(Method.class) || type.equals(Constructor.class);
63 return type == Method.class || type == Constructor.class;
6464 }
6565
6666 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2323 public class LocaleConverter extends AbstractSingleValueConverter {
2424
2525 public boolean canConvert(Class type) {
26 return type.equals(Locale.class);
26 return type == Locale.class;
2727 }
2828
2929 public Object fromString(String str) {
00 /*
1 * Copyright (C) 2007, 2008, 2013 XStream Committers.
1 * Copyright (C) 2007, 2008, 2013, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
4040 }
4141
4242 public boolean canConvert(Class type) {
43 return LookAndFeel.class.isAssignableFrom(type) && canAccess(type);
43 return type != null && LookAndFeel.class.isAssignableFrom(type) && canAccess(type);
4444 }
4545 }
00 /*
1 * Copyright (C) 2013 XStream Committers.
1 * Copyright (C) 2013, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
6161 this.type = itemType;
6262 }
6363
64 protected void writeCompleteItem(final Object item, final MarshallingContext context,
65 final HierarchicalStreamWriter writer) {
66 writeItem(item, context, writer);
67 }
68
69 /**
70 * @deprecated As of 1.4.11 use {@link #writeCompleteItem(Object, MarshallingContext, HierarchicalStreamWriter)}
71 * instead.
72 */
6473 protected void writeItem(Object item, MarshallingContext context, HierarchicalStreamWriter writer) {
65 Class itemType = item == null ? Mapper.Null.class : item.getClass();
74 final Class itemType = item == null ? Mapper.Null.class : item.getClass();
6675 ExtendedHierarchicalStreamWriterHelper.startNode(writer, name, itemType);
6776 if (!itemType.equals(type)) {
6877 String attributeName = mapper().aliasForSystemAttribute("class");
7685 writer.endNode();
7786 }
7887
79 protected Object readItem(HierarchicalStreamReader reader, UnmarshallingContext context, Object current) {
80 String className = HierarchicalStreams.readClassAttribute(reader, mapper());
81 Class itemType = className == null ? type : mapper().realClass(className);
88 protected Object readBareItem(final HierarchicalStreamReader reader, final UnmarshallingContext context,
89 final Object current) {
90 final String className = HierarchicalStreams.readClassAttribute(reader, mapper());
91 final Class itemType = className == null ? type : mapper().realClass(className);
8292 if (Mapper.Null.class.equals(itemType)) {
8393 return null;
8494 } else {
00 /*
1 * Copyright (C) 2013, 2016 XStream Committers.
1 * Copyright (C) 2013, 2016, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
207207 this.keyAsAttribute = keyAsAttribute;
208208 this.valueAsAttribute = valueAsAttribute;
209209 this.lookup = lookup;
210 enumMapper = JVM.is15() ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
210 enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
211211
212212 if (keyType == null || valueType == null) {
213213 throw new IllegalArgumentException("Class types of key and value are mandatory");
00 /*
1 * Copyright (C) 2016 XStream Committers.
1 * Copyright (C) 2016, 2017, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
1313 import java.net.URI;
1414 import java.net.URISyntaxException;
1515 import java.nio.file.FileSystems;
16 import java.nio.file.InvalidPathException;
1617 import java.nio.file.Path;
1718 import java.nio.file.Paths;
1819
20 import com.thoughtworks.xstream.converters.ConversionException;
1921 import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
2022
2123
2931
3032 @Override
3133 public boolean canConvert(@SuppressWarnings("rawtypes") final Class type) {
32 return Path.class.isAssignableFrom(type);
34 return type != null && Path.class.isAssignableFrom(type);
3335 }
3436
3537 @Override
3638 public Path fromString(final String str) {
3739 try {
38 final URI uri = new URI(str);
39 if (uri.getScheme() == null) {
40 try {
41 final URI uri = new URI(str);
42 if (uri.getScheme() == null || uri.getScheme().length() == 1) {
43 return Paths.get(File.separatorChar != '/' ? str.replace('/', File.separatorChar) : str);
44 } else {
45 return Paths.get(uri);
46 }
47 } catch (final URISyntaxException e) {
4048 return Paths.get(str);
41 } else {
42 return Paths.get(uri);
4349 }
44 } catch (final URISyntaxException e) {
45 return Paths.get(str);
50 } catch (final InvalidPathException e) {
51 throw new ConversionException(e);
4652 }
4753 }
4854
00 /*
11 * Copyright (C) 2004, 2005 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
3939 }
4040
4141 public boolean canConvert(final Class type) {
42 return type.equals(Pattern.class);
42 return type == Pattern.class;
4343 }
4444
4545 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2222 public class SqlDateConverter extends AbstractSingleValueConverter {
2323
2424 public boolean canConvert(Class type) {
25 return type.equals(Date.class);
25 return type == Date.class;
2626 }
2727
2828 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
2222 public class SqlTimeConverter extends AbstractSingleValueConverter {
2323
2424 public boolean canConvert(Class type) {
25 return type.equals(Time.class);
25 return type == Time.class;
2626 }
2727
2828 public Object fromString(String str) {
00 /*
11 * Copyright (C) 2003, 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2012, 2014, 2016, 2017 XStream Committers.
2 * Copyright (C) 2006, 2007, 2012, 2014, 2016, 2017, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
5252 }
5353
5454 public boolean canConvert(Class type) {
55 return type.equals(Timestamp.class);
55 return type == Timestamp.class;
5656 }
5757
5858 public String toString(final Object obj) {
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007 XStream Committers.
2 * Copyright (C) 2006, 2007, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
3535 private static final StackTraceElementFactory FACTORY;
3636 static {
3737 StackTraceElementFactory factory = null;
38 if (JVM.is15()) {
38 if (JVM.isVersion(5)) {
3939 Class factoryType = JVM.loadClassForName(
4040 "com.thoughtworks.xstream.converters.extended.StackTraceElementFactory15",
4141 false);
00 /*
1 * Copyright (C) 2006, 2007 XStream Committers.
1 * Copyright (C) 2006, 2007, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
3838 }
3939
4040 public boolean canConvert(Class type) {
41 return type.equals(Subject.class);
41 return type == Subject.class;
4242 }
4343
4444 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
5353 writer.startNode("principals");
5454 for (final Iterator iter = principals.iterator(); iter.hasNext();) {
5555 final Object principal = iter.next(); // pre jdk 1.4 a Principal was also in javax.security
56 writeItem(principal, context, writer);
56 writeCompleteItem(principal, context, writer);
5757 }
5858 writer.endNode();
5959 };
101101 Set set = new HashSet();
102102 reader.moveDown();
103103 while (reader.hasMoreChildren()) {
104 reader.moveDown();
105 Object elementl = readItem(reader, context, set);
106 reader.moveUp();
107 set.add(elementl);
104 final Object principal = readCompleteItem(reader, context, set);
105 set.add(principal);
108106 }
109107 reader.moveUp();
110108 return set;
00 /*
11 * Copyright (C) 2004 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2013 XStream Committers.
2 * Copyright (C) 2006, 2007, 2013, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
4545 }
4646
4747 public boolean canConvert(final Class type) {
48 return Throwable.class.isAssignableFrom(type);
48 return type != null && Throwable.class.isAssignableFrom(type);
4949 }
5050
5151 public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
00 /*
1 * Copyright (C) 2011, 2013, 2016 XStream Committers.
1 * Copyright (C) 2011, 2013, 2016, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
121121 }
122122 this.valueField = field;
123123 }
124 enumMapper = JVM.is15() ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
124 enumMapper = JVM.isVersion(5) ? UseAttributeForEnumMapper.createEnumMapper(mapper) : null;
125125 }
126126
127127 public boolean canConvert(final Class type) {
00 /*
1 * Copyright (C) 2006, 2007, 2016 XStream Committers.
1 * Copyright (C) 2006, 2007, 2016, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
3535 ctor = clazz.getConstructor(STRING_PARAMETER);
3636 }
3737 public boolean canConvert(Class type) {
38 return type.equals(clazz);
38 return type == clazz;
3939 }
4040 public String toString(Object obj) {
4141 return obj == null ? null : obj.toString();
00 /*
11 * Copyright (C) 2004, 2005, 2006 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
140140 }
141141 });
142142
143 new Object() {
144 {
145 final Map hiddenMappers = new HashMap();
146 for (Iterator fieldIter = fields.iterator(); fieldIter.hasNext();) {
147 FieldInfo info = (FieldInfo)fieldIter.next();
148 if (info.value != null) {
149 final Field defaultField = (Field)defaultFieldDefinition.get(info.fieldName);
150 Mapper.ImplicitCollectionMapping mapping = mapper
151 .getImplicitCollectionDefForFieldName(
152 defaultField.getDeclaringClass() == info.definedIn ? sourceType : info.definedIn,
153 info.fieldName);
154 if (mapping != null) {
155 Set mappings = (Set)hiddenMappers.get(info.fieldName);
156 if (mappings == null) {
157 mappings = new HashSet();
158 mappings.add(mapping);
159 hiddenMappers.put(info.fieldName, mappings);
160 } else {
161 if (!mappings.add(mapping)) {
162 mapping = null;
163 }
164 }
165 }
166 if (mapping != null) {
167 if (context instanceof ReferencingMarshallingContext) {
168 if (info.value != Collections.EMPTY_LIST
169 && info.value != Collections.EMPTY_SET
170 && info.value != Collections.EMPTY_MAP) {
171 ReferencingMarshallingContext refContext = (ReferencingMarshallingContext)context;
172 refContext.registerImplicit(info.value);
173 }
174 }
175 final boolean isCollection = info.value instanceof Collection;
176 final boolean isMap = info.value instanceof Map;
177 final boolean isEntry = isMap && mapping.getKeyFieldName() == null;
178 final boolean isArray = info.value.getClass().isArray();
179 for (Iterator iter = isArray
180 ? new ArrayIterator(info.value)
181 : isCollection ? ((Collection)info.value).iterator() : isEntry
182 ? ((Map)info.value).entrySet().iterator()
183 : ((Map)info.value).values().iterator(); iter.hasNext();) {
184 Object obj = iter.next();
185 final String itemName;
186 final Class itemType;
187 if (obj == null) {
188 itemType = Object.class;
189 itemName = mapper.serializedClass(null);
190 } else if (isEntry) {
191 final String entryName = mapping.getItemFieldName() != null
192 ? mapping.getItemFieldName()
193 : mapper.serializedClass(Map.Entry.class);
194 Map.Entry entry = (Map.Entry)obj;
195 ExtendedHierarchicalStreamWriterHelper.startNode(
196 writer, entryName, entry.getClass());
197 writeItem(entry.getKey(), context, writer);
198 writeItem(entry.getValue(), context, writer);
199 writer.endNode();
200 continue;
201 } else if (mapping.getItemFieldName() != null) {
202 itemType = mapping.getItemType();
203 itemName = mapping.getItemFieldName();
204 } else {
205 itemType = obj.getClass();
206 itemName = mapper.serializedClass(itemType);
207 }
208 writeField(
209 info.fieldName, itemName, itemType, info.definedIn, obj);
210 }
211 } else {
212 writeField(
213 info.fieldName, null, info.type, info.definedIn, info.value);
214 }
215 }
216 }
217
218 }
219
220 void writeField(String fieldName, String aliasName, Class fieldType,
143 final FieldMarshaller fieldMarshaller = new FieldMarshaller() {
144 public void writeField(String fieldName, String aliasName, Class fieldType,
221145 Class definedIn, Object newObj) {
222146 Class actualType = newObj != null ? newObj.getClass() : fieldType;
223147 ExtendedHierarchicalStreamWriterHelper.startNode(writer, aliasName != null
251175 writer.endNode();
252176 }
253177
254 void writeItem(Object item, MarshallingContext context,
255 HierarchicalStreamWriter writer) {
178 public void writeItem(Object item) {
256179 if (item == null) {
257180 String name = mapper.serializedClass(null);
258181 ExtendedHierarchicalStreamWriterHelper.startNode(
267190 }
268191 }
269192 };
193
194 final Map hiddenMappers = new HashMap();
195 for (Iterator fieldIter = fields.iterator(); fieldIter.hasNext();) {
196 FieldInfo info = (FieldInfo)fieldIter.next();
197 if (info.value != null) {
198 final Field defaultField = (Field)defaultFieldDefinition.get(info.fieldName);
199 Mapper.ImplicitCollectionMapping mapping = mapper
200 .getImplicitCollectionDefForFieldName(
201 defaultField.getDeclaringClass() == info.definedIn ? sourceType : info.definedIn,
202 info.fieldName);
203 if (mapping != null) {
204 Set mappings = (Set)hiddenMappers.get(info.fieldName);
205 if (mappings == null) {
206 mappings = new HashSet();
207 mappings.add(mapping);
208 hiddenMappers.put(info.fieldName, mappings);
209 } else {
210 if (!mappings.add(mapping)) {
211 mapping = null;
212 }
213 }
214 }
215 if (mapping != null) {
216 if (context instanceof ReferencingMarshallingContext) {
217 if (info.value != Collections.EMPTY_LIST
218 && info.value != Collections.EMPTY_SET
219 && info.value != Collections.EMPTY_MAP) {
220 ReferencingMarshallingContext refContext = (ReferencingMarshallingContext)context;
221 refContext.registerImplicit(info.value);
222 }
223 }
224 final boolean isCollection = info.value instanceof Collection;
225 final boolean isMap = info.value instanceof Map;
226 final boolean isEntry = isMap && mapping.getKeyFieldName() == null;
227 final boolean isArray = info.value.getClass().isArray();
228 for (Iterator iter = isArray
229 ? new ArrayIterator(info.value)
230 : isCollection ? ((Collection)info.value).iterator() : isEntry
231 ? ((Map)info.value).entrySet().iterator()
232 : ((Map)info.value).values().iterator(); iter.hasNext();) {
233 Object obj = iter.next();
234 final String itemName;
235 final Class itemType;
236 if (obj == null) {
237 itemType = Object.class;
238 itemName = mapper.serializedClass(null);
239 } else if (isEntry) {
240 final String entryName = mapping.getItemFieldName() != null
241 ? mapping.getItemFieldName()
242 : mapper.serializedClass(Map.Entry.class);
243 Map.Entry entry = (Map.Entry)obj;
244 ExtendedHierarchicalStreamWriterHelper.startNode(
245 writer, entryName, entry.getClass());
246 fieldMarshaller.writeItem(entry.getKey());
247 fieldMarshaller.writeItem(entry.getValue());
248 writer.endNode();
249 continue;
250 } else if (mapping.getItemFieldName() != null) {
251 itemType = mapping.getItemType();
252 itemName = mapping.getItemFieldName();
253 } else {
254 itemType = obj.getClass();
255 itemName = mapper.serializedClass(itemType);
256 }
257 fieldMarshaller.writeField(
258 info.fieldName, itemName, itemType, info.definedIn, obj);
259 }
260 } else {
261 fieldMarshaller.writeField(
262 info.fieldName, null, info.type, info.definedIn, info.value);
263 }
264 }
265 }
270266 }
271267
272268 protected void marshallField(final MarshallingContext context, Object newObj, Field field) {
661657 }
662658 }
663659
660 private interface FieldMarshaller {
661 void writeItem(final Object item);
662 void writeField(final String fieldName, final String aliasName, final Class fieldType,
663 final Class definedIn, final Object newObj);
664 }
665
664666 private static class ArraysList extends ArrayList {
665667 final Class physicalFieldType;
666668
00 /*
1 * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2013, 2014, 2015, 2016 XStream Committers.
1 * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2013, 2014, 2015, 2016, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
8888 }
8989
9090 public boolean canConvert(Class type) {
91 return (Enhancer.isEnhanced(type) && type.getName().indexOf(DEFAULT_NAMING_MARKER) > 0)
91 return type != null && Enhancer.isEnhanced(type) && type.getName().indexOf(DEFAULT_NAMING_MARKER) > 0
9292 || type == CGLIBMapper.Marker.class;
9393 }
9494
7575 }
7676
7777 public boolean canConvert(Class type) {
78 return JVM.canCreateDerivedObjectOutputStream() && Externalizable.class.isAssignableFrom(type);
78 return type != null && JVM.canCreateDerivedObjectOutputStream() && Externalizable.class.isAssignableFrom(type);
7979 }
8080
8181 public void marshal(final Object original, final HierarchicalStreamWriter writer, final MarshallingContext context) {
00 /*
11 * Copyright (C) 2004, 2005, 2006 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2018 XStream Committers.
33 * All rights reserved.
44 * The software in this package is published under the terms of the BSD
55 * style license a copy of which has been included with this distribution in
3434 Collections.EMPTY_MAP);
3535
3636 private transient Map dictionaryEntries;
37 private transient FieldUtil fieldUtil;
3738 private final FieldKeySorter sorter;
3839
3940 public FieldDictionary() {
4748
4849 private void init() {
4950 dictionaryEntries = new HashMap();
51 if (JVM.is15())
52 try {
53 fieldUtil = (FieldUtil)JVM.loadClassForName("com.thoughtworks.xstream.converters.reflection.FieldUtil15", true).newInstance();
54 } catch (Exception e) {
55 ;
56 }
57 if (fieldUtil == null)
58 fieldUtil = new FieldUtil14();
5059 }
5160
5261 /**
159168 }
160169 for (int i = 0; i < fields.length; i++) {
161170 final Field field = fields[i];
171 if (fieldUtil.isSynthetic(field) && field.getName().startsWith("$jacoco")) {
172 continue;
173 }
162174 if (!field.isAccessible()) {
163175 field.setAccessible(true);
164176 }
193205 return this;
194206 }
195207
208 interface FieldUtil {
209 boolean isSynthetic(Field field);
210 }
211
196212 private static final class DictionaryEntry {
197213
198214 private final Map keyedByFieldName;
0 /*
1 * Copyright (C) 2018 XStream Committers.
2 * All rights reserved.
3 * The software in this package is published under the terms of the BSD
4 * style license a copy of which has been included with this distribution in
5 * the LICENSE.txt file.
6 * Created on 10. October 2018 by Joerg Schaible.
7 */
8 package com.thoughtworks.xstream.converters.reflection;
9
10 import java.lang.reflect.Field;
11
12 /**
13 * @author J&ouml;rg Schaible
14 */
15 class FieldUtil14 implements FieldDictionary.FieldUtil {
16
17 public boolean isSynthetic(final Field field) {
18 return false;
19 }
20 }
0 /*
1 * Copyright (C) 2018 XStream Committers.
2 * All rights reserved.
3 * The software in this package is published under the terms of the BSD
4 * style license a copy of which has been included with this distribution in
5 * the LICENSE.txt file.
6 * Created on 10. October 2018 by Joerg Schaible.
7 */
8 package com.thoughtworks.xstream.converters.reflection;
9
10 import java.lang.reflect.Field;
11
12 /**
13 * @author J&ouml;rg Schaible
14 */
15 class FieldUtil15 implements FieldDictionary.FieldUtil {
16
17 public boolean isSynthetic(final Field field) {
18 return field.isSynthetic();
19 }
20 }
00 /*
11 * Copyright (C) 2004, 2005, 2006 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2009, 2011, 2013, 2016 XStream Committers.
2 * Copyright (C) 2006, 2007, 2009, 2011, 2013, 2016, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
167167
168168 protected void validateFieldAccess(Field field) {
169169 if (Modifier.isFinal(field.getModifiers())) {
170 if (JVM.is15()) {
170 if (JVM.isVersion(5)) {
171171 if (!field.isAccessible()) {
172172 field.setAccessible(true);
173173 }
00 /*
1 * Copyright (C) 2017 XStream Committers.
1 * Copyright (C) 2017, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
2626
2727 @Override
2828 public boolean canConvert(@SuppressWarnings("rawtypes") final Class type) {
29 return Chronology.class.isAssignableFrom(type);
29 return type != null && Chronology.class.isAssignableFrom(type);
3030 }
3131
3232 @Override
00 /*
1 * Copyright (C) 2017 XStream Committers.
1 * Copyright (C) 2017, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
2525
2626 @Override
2727 public boolean canConvert(@SuppressWarnings("rawtypes") final Class type) {
28 return JapaneseEra.class.isAssignableFrom(type);
28 return type != null && JapaneseEra.class.isAssignableFrom(type);
2929 }
3030
3131 @Override
00 /*
1 * Copyright (C) 2017 XStream Committers.
1 * Copyright (C) 2017, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
2727
2828 @Override
2929 public boolean canConvert(@SuppressWarnings("rawtypes") final Class type) {
30 return ZoneId.class.isAssignableFrom(type);
30 return type != null && ZoneId.class.isAssignableFrom(type);
3131 }
3232
3333 @Override
00 /*
1 * Copyright (C) 2006, 2007, 2008, 2011, 2015 XStream Committers.
1 * Copyright (C) 2006, 2007, 2008, 2011, 2015, 2018 XStream Committers.
22 * All rights reserved.
33 *
44 * The software in this package is published under the terms of the BSD
6666 } else {
6767 Object currentReferenceKey = getCurrentReferenceKey();
6868 parentStack.push(currentReferenceKey);
69 result = super.convert(parent, type, converter);
70 if (currentReferenceKey != null) {
71 values.put(currentReferenceKey, result == null ? NULL : result);
69 Object localResult = null;
70 try {
71 localResult = super.convert(parent, type, converter);
72 } finally {
73 result = localResult;
74 if (currentReferenceKey != null) {
75 values.put(currentReferenceKey, result == null ? NULL : result);
76 }
77 parentStack.popSilently();
7278 }
73 parentStack.popSilently();
7479 }
7580 return result;
7681 }
1414 import com.thoughtworks.xstream.converters.Converter;
1515 import com.thoughtworks.xstream.converters.ConverterLookup;
1616 import com.thoughtworks.xstream.converters.ConverterRegistry;
17 import com.thoughtworks.xstream.core.util.Cloneables;
1718 import com.thoughtworks.xstream.core.util.PrioritizedList;
1819 import com.thoughtworks.xstream.mapper.Mapper;
1920
20 import java.util.Collections;
21 import java.util.HashMap;
2122 import java.util.Iterator;
2223 import java.util.LinkedHashMap;
2324 import java.util.Map;
24 import java.util.WeakHashMap;
25
2526
2627 /**
2728 * The default implementation of converters lookup.
3435
3536 private final PrioritizedList converters = new PrioritizedList();
3637 private transient Map typeToConverterMap;
38 private Map serializationMap = null;
3739
3840 public DefaultConverterLookup() {
39 readResolve();
41 this(new HashMap());
42 }
43
44 /**
45 * Constructs a DefaultConverterLookup with a provided map.
46 *
47 * @param map the map to use
48 * @throws NullPointerException if map is null
49 * @since 1.4.11
50 */
51 public DefaultConverterLookup(Map map) {
52 typeToConverterMap = map;
53 typeToConverterMap.clear();
4054 }
4155
4256 /**
4357 * @deprecated As of 1.3, use {@link #DefaultConverterLookup()}
4458 */
4559 public DefaultConverterLookup(Mapper mapper) {
60 this();
4661 }
4762
4863 public Converter lookupConverterForType(Class type) {
49 Converter cachedConverter = (Converter) typeToConverterMap.get(type);
64 Converter cachedConverter = type != null ? (Converter)typeToConverterMap.get(type.getName()) : null;
5065 if (cachedConverter != null) {
5166 return cachedConverter;
5267 }
5469 final Map errors = new LinkedHashMap();
5570 Iterator iterator = converters.iterator();
5671 while (iterator.hasNext()) {
57 Converter converter = (Converter) iterator.next();
72 Converter converter = (Converter)iterator.next();
5873 try {
5974 if (converter.canConvert(type)) {
60 typeToConverterMap.put(type, converter);
75 if (type != null) {
76 typeToConverterMap.put(type.getName(), converter);
77 }
6178 return converter;
6279 }
6380 } catch (final RuntimeException e) {
7996 }
8097 throw exception;
8198 }
82
99
83100 public void registerConverter(Converter converter, int priority) {
101 typeToConverterMap.clear();
84102 converters.add(converter, priority);
85 for (Iterator iter = typeToConverterMap.keySet().iterator(); iter.hasNext();) {
86 Class type = (Class) iter.next();
87 try {
88 if (converter.canConvert(type)) {
89 iter.remove();
90 }
91 } catch (final RuntimeException e) {
92 // ignore
93 } catch (final LinkageError e) {
94 // ignore
95 }
96 }
97103 }
98
104
99105 public void flushCache() {
100106 typeToConverterMap.clear();
101107 Iterator iterator = converters.iterator();
102108 while (iterator.hasNext()) {
103 Converter converter = (Converter) iterator.next();
109 Converter converter = (Converter)iterator.next();
104110 if (converter instanceof Caching) {
105111 ((Caching)converter).flushCache();
106112 }
107113 }
108114 }
109115
116 private Object writeReplace() {
117 serializationMap = (Map)Cloneables.cloneIfPossible(typeToConverterMap);
118 serializationMap.clear();
119 return this;
120 }
121
110122 private Object readResolve() {
111 typeToConverterMap = Collections.synchronizedMap(new WeakHashMap());
123 typeToConverterMap = serializationMap == null ? new HashMap() : serializationMap;
124 serializationMap = null;
112125 return this;
113126 }
114127 }
00 /*
11 * Copyright (C) 2004, 2005, 2006 Joe Walnes.
2 * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 XStream Committers.
2 * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 XStream Committers.
33 * All rights reserved.
44 *
55 * The software in this package is published under the terms of the BSD
66 * style license a copy of which has been included with this distribution in
77 * the LICENSE.txt file.
8 *
8 *
99 * Created on 09. May 2004 by Joe Walnes
1010 */
1111 package com.thoughtworks.xstream.core;
12
13 import com.thoughtworks.xstream.converters.reflection.FieldDictionary;
14 import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
15 import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
16 import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
17 import com.thoughtworks.xstream.core.util.CustomObjectOutputStream;
18 import com.thoughtworks.xstream.core.util.DependencyInjectionFactory;
19 import com.thoughtworks.xstream.core.util.PresortedMap;
20 import com.thoughtworks.xstream.core.util.PresortedSet;
2112
2213 import java.io.IOException;
2314 import java.lang.reflect.Field;
3122 import java.util.TreeMap;
3223 import java.util.TreeSet;
3324
25 import com.thoughtworks.xstream.converters.reflection.FieldDictionary;
26 import com.thoughtworks.xstream.converters.reflection.ObjectAccessException;
27 import com.thoughtworks.xstream.converters.reflection.PureJavaReflectionProvider;
28 import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
29 import com.thoughtworks.xstream.core.util.Base64Encoder;
30 import com.thoughtworks.xstream.core.util.CustomObjectOutputStream;
31 import com.thoughtworks.xstream.core.util.DependencyInjectionFactory;
32 import com.thoughtworks.xstream.core.util.PresortedMap;
33 import com.thoughtworks.xstream.core.util.PresortedSet;
34
35
3436 public class JVM implements Caching {
3537
3638 private ReflectionProvider reflectionProvider;
5153 private static final float DEFAULT_JAVA_VERSION = 1.4f;
5254 private static final boolean reverseFieldOrder = false;
5355 private static final Class reflectionProviderType;
56 private static final StringCodec base64Codec;
5457
5558 static class Test {
5659 private Object o;
109112 cls = null;
110113 }
111114 if (cls == null) {
112 cls = loadClassForName("com.thoughtworks.xstream.converters.reflection.SunLimitedUnsafeReflectionProvider");
115 cls = loadClassForName(
116 "com.thoughtworks.xstream.converters.reflection.SunLimitedUnsafeReflectionProvider");
113117 }
114118 type = cls;
115119 } catch (ObjectAccessException e) {
170174 isAWTAvailable = loadClassForName("java.awt.Color", false) != null;
171175 isSwingAvailable = loadClassForName("javax.swing.LookAndFeel", false) != null;
172176 isSQLAvailable = loadClassForName("java.sql.Date") != null;
177
178 StringCodec base64 = null;
179 Class base64Class = loadClassForName(
180 "com.thoughtworks.xstream.core.util.Base64JavaUtilCodec");
181 if (base64Class == null) {
182 base64Class = loadClassForName("com.thoughtworks.xstream.core.util.Base64JAXBCodec");
183 }
184 if (base64Class != null) {
185 try {
186 base64 = (StringCodec)base64Class.newInstance();
187 } catch (final Exception e) {
188 }
189 }
190 if (base64 == null) {
191 base64 = new Base64Encoder();
192 }
193 base64Codec = base64;
173194 }
174195
175196 /**
179200 }
180201
181202 /**
182 * Parses the java version system property to determine the major java version,
183 * i.e. 1.x
203 * Parses the java version system property to determine the major java version, i.e. 1.x
184204 *
185205 * @return A float of the form 1.x
186206 */
197217 * @deprecated As of 1.4.4, minimal JDK version is 1.4 already
198218 */
199219 public static boolean is14() {
200 return majorJavaVersion >= 1.4f;
220 return isVersion(4);
201221 }
202222
203223 /**
204224 * @deprecated As of 1.4.4, minimal JDK version will be 1.7 for next major release
205225 */
206226 public static boolean is15() {
207 return majorJavaVersion >= 1.5f;
227 return isVersion(5);
208228 }
209229
210230 /**
211231 * @deprecated As of 1.4.4, minimal JDK version will be 1.7 for next major release
212232 */
213233 public static boolean is16() {
214 return majorJavaVersion >= 1.6f;
234 return isVersion(6);
215235 }
216236
217237 /**
219239 * @deprecated As of 1.4.10, minimal JDK version will be 1.7 for next major release
220240 */
221241 public static boolean is17() {
222 return majorJavaVersion >= 1.7f;
242 return isVersion(7);
223243 }
224244
225245 /**
226246 * @since 1.4
247 * @deprecated As of 1.4.11 use {@link #isVersion(int)}.
227248 */
228249 public static boolean is18() {
229 return majorJavaVersion >= 1.8f;
250 return isVersion(8);
230251 }
231252
232253 /**
233254 * @since 1.4.8
234 * @deprecated As of upcoming use {@link #is9()}
255 * @deprecated As of 1.4.10 use {@link #isVersion(int)}.
235256 */
236257 public static boolean is19() {
237258 return majorJavaVersion >= 1.9f;
239260
240261 /**
241262 * @since 1.4.10
263 * @deprecated As of 1.4.11 use {@link #isVersion(int)}
242264 */
243265 public static boolean is9() {
244 return majorJavaVersion >= 9f;
266 return isVersion(9);
267 }
268
269 /**
270 * Checks current runtime against provided major Java version.
271 *
272 * @param version the requested major Java version
273 * @return true if current runtime is at least the provided major version
274 * @since 1.4.11
275 */
276 public static boolean isVersion(final int version) {
277 if (version < 1) {
278 throw new IllegalArgumentException("Java version range starts with at least 1.");
279 }
280 final float v = majorJavaVersion < 9 ? 1f + version * 0.1f : version;
281 return majorJavaVersion >= v;
245282 }
246283
247284 private static boolean isIBM() {
257294
258295 /**
259296 * Load a XStream class for the given name.
260 *
261 * <p>This method is not meant to use loading arbitrary classes. It is used by XStream bootstrap
262 * until it is able to use the user provided or the default {@link ClassLoader}.</p>
263 *
297 * <p>
298 * This method is not meant to use loading arbitrary classes. It is used by XStream bootstrap until it is able to
299 * use the user provided or the default {@link ClassLoader}.
300 * </p>
301 *
264302 * @since 1.4.5
265303 */
266304 public static Class loadClassForName(String name) {
276314
277315 /**
278316 * Load a XStream class for the given name.
279 *
280 * <p>This method is not meant to use loading arbitrary classes. It is used by XStream bootstrap
281 * until it is able to use the user provided or the default {@link ClassLoader}.</p>
282 *
317 * <p>
318 * This method is not meant to use loading arbitrary classes. It is used by XStream bootstrap until it is able to
319 * use the user provided or the default {@link ClassLoader}.
320 * </p>
321 *
283322 * @since 1.4.5
284323 */
285324 public static Class loadClassForName(String name, boolean initialize) {
303342
304343 /**
305344 * Create the best matching ReflectionProvider.
306 *
345 *
307346 * @return a new instance
308347 * @since 1.4.5
309348 */
331370 * implementations configured in <em>lib/stax.properties</em> or registered with the Service
332371 * API.
333372 * </p>
334 *
373 *
335374 * @return the XMLInputFactory implementation or null
336375 * @throws ClassNotFoundException if the standard class cannot be found
337376 * @since 1.4.5
338377 */
339378 public static Class getStaxInputFactory() throws ClassNotFoundException {
340 if (is16()) {
379 if (isVersion(6)) {
341380 if (isIBM()) {
342381 return Class.forName("com.ibm.xml.xlxp.api.stax.XMLInputFactoryImpl");
343382 } else {
356395 * implementations configured in <em>lib/stax.properties</em> or registered with the Service
357396 * API.
358397 * </p>
359 *
398 *
360399 * @return the XMLOutputFactory implementation or null
361400 * @throws ClassNotFoundException if the standard class cannot be found
362401 * @since 1.4.5
363402 */
364403 public static Class getStaxOutputFactory() throws ClassNotFoundException {
365 if (is16()) {
404 if (isVersion(6)) {
366405 if (isIBM()) {
367406 return Class.forName("com.ibm.xml.xlxp.api.stax.XMLOutputFactoryImpl");
368407 } else {
373412 }
374413
375414 /**
415 * Get an available Base64 implementation. Prefers java.util.Base64 over DataTypeConverter from JAXB over XStream's
416 * own implementation.
417 *
418 * @return a Base64 codec implementation
419 * @since 1.4.11
420 */
421 public static StringCodec getBase64Codec() {
422 return base64Codec;
423 }
424
425 /**
376426 * @deprecated As of 1.4.5 use {@link #newReflectionProvider()}
377427 */
378428 public synchronized ReflectionProvider bestReflectionProvider() {
383433 }
384434
385435 private static boolean canUseSunUnsafeReflectionProvider() {
386 return canAllocateWithUnsafe && is14();
436 return canAllocateWithUnsafe;
387437 }
388438
389439 private static boolean canUseSunLimitedUnsafeReflectionProvider() {
399449
400450 /**
401451 * Checks if AWT is available.
452 *
402453 * @since 1.4.5
403454 */
404455 public static boolean isAWTAvailable() {
406457 }
407458
408459 /**
409 * Checks if the jvm supports awt.
460 * Checks if the JVM supports AWT.
461 *
410462 * @deprecated As of 1.4.5 use {@link #isAWTAvailable()}
411463 */
412464 public boolean supportsAWT() {
415467
416468 /**
417469 * Checks if Swing is available.
470 *
418471 * @since 1.4.5
419472 */
420473 public static boolean isSwingAvailable() {
422475 }
423476
424477 /**
425 * Checks if the jvm supports swing.
478 * Checks if the JVM supports Swing.
479 *
426480 * @deprecated As of 1.4.5 use {@link #isSwingAvailable()}
427481 */
428482 public boolean supportsSwing() {
431485
432486 /**
433487 * Checks if SQL is available.
488 *
434489 * @since 1.4.5
435490 */
436491 public static boolean isSQLAvailable() {
438493 }
439494
440495 /**
441 * Checks if the jvm supports sql.
496 * Checks if the JVM supports SQL.
497 *
442498 * @deprecated As of 1.4.5 use {@link #isSQLAvailable()}
443499 */
444500 public boolean supportsSQL() {
447503
448504 /**
449505 * Checks if TreeSet.addAll is optimized for SortedSet argument.
450 *
506 *
451507 * @since 1.4
452508 */
453509 public static boolean hasOptimizedTreeSetAddAll() {
456512
457513 /**
458514 * Checks if TreeMap.putAll is optimized for SortedMap argument.
459 *
515 *
460516 * @since 1.4
461517 */
462518 public static boolean hasOptimizedTreeMapPutAll() {
538594 System.out.println("Java Beans EventHandler present: " + (loadClassForName("java.beans.EventHandler") != null));
539595 System.out.println("Standard StAX XMLInputFactory: " + staxInputFactory);
540596 System.out.println("Standard StAX XMLOutputFactory: " + staxOutputFactory);
597 System.out.println("Standard Base64 Codec: " + getBase64Codec().getClass().toString());
541598 System.out.println("Optimized TreeSet.addAll: " + hasOptimizedTreeSetAddAll());
542599 System.out.println("Optimized TreeMap.putAll: " + hasOptimizedTreeMapPutAll());
543600 System.out.println("Can parse UTC date format: " + canParseUTCDateFormat());
544601 System.out.println("Can create derive ObjectOutputStream: " + canCreateDerivedObjectOutputStream());
545602 System.out.println("Reverse field order detected for JDK: " + reverseJDK);
546 System.out.println("Reverse field order detected (only if JVM class itself has been compiled): " + reverseLocal);
603 System.out.println("Reverse field order detected (only if JVM class itself has been compiled): "
604 + reverseLocal);
547605 }
548606 }
0 /*
1 * Copyright (C) 2017, 2018 XStream Committers.
2 * All rights reserved.
3 *
4 * The software in this package is published under the terms of the BSD
5 * style license a copy of which has been included with this distribution in
6 * the LICENSE.txt file.
7 *
8 * Created on 12. August 2017 by Joerg Schaible
9 */
10 package com.thoughtworks.xstream.core;
11
12 /**
13 * Interface for an encoder and decoder of data to string values and back.
14 *
15 * @author J&ouml;rg Schaible
16 * @since 1.4.11
17 */
18 public interface StringCodec {
19
20 /**
21 * Decode the provided encoded string.
22 *
23