Skip to content

Commit d4e1b9e

Browse files
committed
Polishing
(cherry picked from commit 6fef8b9)
1 parent 44ee51a commit d4e1b9e

File tree

4 files changed

+31
-23
lines changed

4 files changed

+31
-23
lines changed

spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,6 @@
3737
import java.util.Date;
3838
import java.util.Map;
3939
import java.util.UUID;
40-
4140
import javax.activation.DataHandler;
4241
import javax.activation.DataSource;
4342
import javax.xml.XMLConstants;
@@ -78,6 +77,7 @@
7877
import org.xml.sax.SAXException;
7978
import org.xml.sax.XMLReader;
8079
import org.xml.sax.helpers.XMLReaderFactory;
80+
8181
import org.springframework.beans.factory.BeanClassLoaderAware;
8282
import org.springframework.beans.factory.InitializingBean;
8383
import org.springframework.core.JdkVersion;
@@ -111,6 +111,7 @@
111111
*
112112
* @author Arjen Poutsma
113113
* @author Juergen Hoeller
114+
* @author Rossen Stoyanchev
114115
* @since 3.0
115116
* @see #setContextPath(String)
116117
* @see #setClassesToBeBound(Class[])
@@ -893,7 +894,7 @@ private static class Jaxb2AttachmentMarshaller extends AttachmentMarshaller {
893894

894895
private final MimeContainer mimeContainer;
895896

896-
private Jaxb2AttachmentMarshaller(MimeContainer mimeContainer) {
897+
public Jaxb2AttachmentMarshaller(MimeContainer mimeContainer) {
897898
this.mimeContainer = mimeContainer;
898899
}
899900

@@ -947,7 +948,7 @@ private static class Jaxb2AttachmentUnmarshaller extends AttachmentUnmarshaller
947948

948949
private final MimeContainer mimeContainer;
949950

950-
private Jaxb2AttachmentUnmarshaller(MimeContainer mimeContainer) {
951+
public Jaxb2AttachmentUnmarshaller(MimeContainer mimeContainer) {
951952
this.mimeContainer = mimeContainer;
952953
}
953954

@@ -997,7 +998,7 @@ private static class ByteArrayDataSource implements DataSource {
997998

998999
private final int length;
9991000

1000-
private ByteArrayDataSource(String contentType, byte[] data, int offset, int length) {
1001+
public ByteArrayDataSource(String contentType, byte[] data, int offset, int length) {
10011002
this.contentType = contentType;
10021003
this.data = data;
10031004
this.offset = offset;
@@ -1025,6 +1026,7 @@ public String getName() {
10251026
}
10261027
}
10271028

1029+
10281030
private static final EntityResolver NO_OP_ENTITY_RESOLVER = new EntityResolver() {
10291031
@Override
10301032
public InputSource resolveEntity(String publicId, String systemId) {

spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2CollectionHttpMessageConverter.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
2626
import java.util.List;
2727
import java.util.SortedSet;
2828
import java.util.TreeSet;
29-
3029
import javax.xml.bind.JAXBException;
3130
import javax.xml.bind.UnmarshalException;
3231
import javax.xml.bind.Unmarshaller;
@@ -54,6 +53,7 @@
5453
* does not support writing.
5554
*
5655
* @author Arjen Poutsma
56+
* @author Rossen Stoyanchev
5757
* @since 3.2
5858
*/
5959
@SuppressWarnings("rawtypes")
@@ -62,6 +62,7 @@ public class Jaxb2CollectionHttpMessageConverter<T extends Collection>
6262

6363
private final XMLInputFactory inputFactory = createXmlInputFactory();
6464

65+
6566
/**
6667
* Always returns {@code false} since Jaxb2CollectionHttpMessageConverter
6768
* required generic type information in order to read a Collection.
@@ -166,7 +167,6 @@ else if (elementClass.isAnnotationPresent(XmlType.class)) {
166167
/**
167168
* Create a Collection of the given type, with the given initial capacity
168169
* (if supported by the Collection type).
169-
*
170170
* @param collectionClass the type of Collection to instantiate
171171
* @return the created Collection instance
172172
*/
@@ -224,10 +224,8 @@ protected void writeToResult(T t, HttpHeaders headers, Result result) throws IOE
224224
/**
225225
* Create a {@code XMLInputFactory} that this converter will use to create {@link
226226
* javax.xml.stream.XMLStreamReader} and {@link javax.xml.stream.XMLEventReader} objects.
227-
* <p/> Can be overridden in subclasses, adding further initialization of the factory.
227+
* <p>Can be overridden in subclasses, adding further initialization of the factory.
228228
* The resulting factory is cached, so this method will only be called once.
229-
*
230-
* @return the created factory
231229
*/
232230
protected XMLInputFactory createXmlInputFactory() {
233231
XMLInputFactory inputFactory = XMLInputFactory.newInstance();

spring-web/src/main/java/org/springframework/http/converter/xml/Jaxb2RootElementHttpMessageConverter.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,30 @@
3232
import javax.xml.transform.sax.SAXSource;
3333
import javax.xml.transform.stream.StreamSource;
3434

35+
import org.xml.sax.EntityResolver;
36+
import org.xml.sax.InputSource;
37+
import org.xml.sax.SAXException;
38+
import org.xml.sax.XMLReader;
39+
import org.xml.sax.helpers.XMLReaderFactory;
40+
3541
import org.springframework.core.annotation.AnnotationUtils;
3642
import org.springframework.http.HttpHeaders;
3743
import org.springframework.http.MediaType;
3844
import org.springframework.http.converter.HttpMessageConversionException;
3945
import org.springframework.http.converter.HttpMessageNotReadableException;
4046
import org.springframework.http.converter.HttpMessageNotWritableException;
4147
import org.springframework.util.ClassUtils;
42-
import org.xml.sax.EntityResolver;
43-
import org.xml.sax.InputSource;
44-
import org.xml.sax.SAXException;
45-
import org.xml.sax.XMLReader;
46-
import org.xml.sax.helpers.XMLReaderFactory;
4748

4849
/**
49-
* Implementation of {@link org.springframework.http.converter.HttpMessageConverter HttpMessageConverter} that can read
50-
* and write XML using JAXB2.
50+
* Implementation of {@link org.springframework.http.converter.HttpMessageConverter HttpMessageConverter}
51+
* that can read and write XML using JAXB2.
5152
*
52-
* <p>This converter can read classes annotated with {@link XmlRootElement} and {@link XmlType}, and write classes
53-
* annotated with with {@link XmlRootElement}, or subclasses thereof.
53+
* <p>This converter can read classes annotated with {@link XmlRootElement} and {@link XmlType},
54+
* and write classes annotated with with {@link XmlRootElement}, or subclasses thereof.
5455
*
5556
* @author Arjen Poutsma
5657
* @author Sebastien Deleuze
58+
* @author Rossen Stoyanchev
5759
* @since 3.0
5860
*/
5961
public class Jaxb2RootElementHttpMessageConverter extends AbstractJaxb2HttpMessageConverter<Object> {
@@ -69,10 +71,14 @@ public void setProcessExternalEntities(boolean processExternalEntities) {
6971
this.processExternalEntities = processExternalEntities;
7072
}
7173

74+
/**
75+
* Returns the configured value for whether XML external entities are allowed.
76+
*/
7277
public boolean isProcessExternalEntities() {
7378
return this.processExternalEntities;
7479
}
7580

81+
7682
@Override
7783
public boolean canRead(Class<?> clazz, MediaType mediaType) {
7884
return (clazz.isAnnotationPresent(XmlRootElement.class) || clazz.isAnnotationPresent(XmlType.class)) &&
@@ -81,7 +87,7 @@ public boolean canRead(Class<?> clazz, MediaType mediaType) {
8187

8288
@Override
8389
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
84-
return AnnotationUtils.findAnnotation(clazz, XmlRootElement.class) != null && canWrite(mediaType);
90+
return (AnnotationUtils.findAnnotation(clazz, XmlRootElement.class) != null && canWrite(mediaType));
8591
}
8692

8793
@Override

spring-web/src/main/java/org/springframework/http/converter/xml/SourceHttpMessageConverter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,6 +61,7 @@
6161
* that can read and write {@link Source} objects.
6262
*
6363
* @author Arjen Poutsma
64+
* @author Rossen Stoyanchev
6465
* @since 3.0
6566
*/
6667
public class SourceHttpMessageConverter<T extends Source> extends AbstractHttpMessageConverter<T> {
@@ -99,12 +100,13 @@ public void setProcessExternalEntities(boolean processExternalEntities) {
99100
}
100101

101102
/**
102-
* @return the configured value for whether XML external entities are allowed.
103+
* Returns the configured value for whether XML external entities are allowed.
103104
*/
104105
public boolean isProcessExternalEntities() {
105106
return this.processExternalEntities;
106107
}
107108

109+
108110
@Override
109111
public boolean supports(Class<?> clazz) {
110112
return SUPPORTED_CLASSES.contains(clazz);

0 commit comments

Comments
 (0)