1
1
/*
2
- * Copyright 2002-2011 the original author or authors.
2
+ * Copyright 2002-2012 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
@@ -202,7 +202,7 @@ else if (value instanceof String) {
202
202
* @param aliases
203
203
* @throws ClassNotFoundException
204
204
* @throws NoSuchFieldException
205
- * @see XStream#aliasField(String, Class, String)
205
+ * @see XStream#aliasField(String, Class, String)
206
206
*/
207
207
public void setFieldAliases (Map <String , String > aliases ) throws ClassNotFoundException , NoSuchFieldException {
208
208
for (Map .Entry <String , String > entry : aliases .entrySet ()) {
@@ -483,7 +483,12 @@ else if (node instanceof Element) {
483
483
else {
484
484
throw new IllegalArgumentException ("DOMSource contains neither Document nor Element" );
485
485
}
486
- return unmarshal (streamReader );
486
+ try {
487
+ return getXStream ().unmarshal (streamReader );
488
+ }
489
+ catch (Exception ex ) {
490
+ throw convertXStreamException (ex , false );
491
+ }
487
492
}
488
493
489
494
@ Override
@@ -499,7 +504,14 @@ protected Object unmarshalXmlEventReader(XMLEventReader eventReader) throws XmlM
499
504
500
505
@ Override
501
506
protected Object unmarshalXmlStreamReader (XMLStreamReader streamReader ) throws XmlMappingException {
502
- return unmarshal (new StaxReader (new QNameMap (), streamReader ));
507
+ try {
508
+ HierarchicalStreamReader hierarchicalStreamReader =
509
+ new StaxReader (new QNameMap (),streamReader );
510
+ return getXStream ().unmarshal (hierarchicalStreamReader );
511
+ }
512
+ catch (Exception ex ) {
513
+ throw convertXStreamException (ex , false );
514
+ }
503
515
}
504
516
505
517
@ Override
@@ -509,11 +521,18 @@ protected Object unmarshalInputStream(InputStream inputStream) throws XmlMapping
509
521
510
522
@ Override
511
523
protected Object unmarshalReader (Reader reader ) throws XmlMappingException , IOException {
512
- if (streamDriver != null ) {
513
- return unmarshal (streamDriver .createReader (reader ));
524
+ try {
525
+ HierarchicalStreamReader streamReader ;
526
+ if (this .streamDriver != null ) {
527
+ streamReader = this .streamDriver .createReader (reader );
528
+ }
529
+ else {
530
+ streamReader = new XppReader (reader );
531
+ }
532
+ return getXStream ().unmarshal (streamReader );
514
533
}
515
- else {
516
- return unmarshal ( new XppReader ( reader ) );
534
+ catch ( Exception ex ) {
535
+ throw convertXStreamException ( ex , false );
517
536
}
518
537
}
519
538
@@ -525,16 +544,6 @@ protected Object unmarshalSaxReader(XMLReader xmlReader, InputSource inputSource
525
544
"XStreamMarshaller does not support unmarshalling using SAX XMLReaders" );
526
545
}
527
546
528
- private Object unmarshal (HierarchicalStreamReader streamReader ) {
529
- try {
530
- return this .getXStream ().unmarshal (streamReader );
531
- }
532
- catch (Exception ex ) {
533
- throw convertXStreamException (ex , false );
534
- }
535
- }
536
-
537
-
538
547
/**
539
548
* Convert the given XStream exception to an appropriate exception from the
540
549
* <code>org.springframework.oxm</code> hierarchy.
0 commit comments