Browse Source

Polishing

pull/1935/head
Juergen Hoeller 8 years ago
parent
commit
484a2f3f2d
  1. 11
      spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java
  2. 8
      spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java
  3. 8
      spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java
  4. 17
      spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java
  5. 27
      spring-core/src/main/java/org/springframework/util/xml/AbstractXMLStreamReader.java
  6. 60
      spring-core/src/main/java/org/springframework/util/xml/DomContentHandler.java
  7. 16
      spring-core/src/main/java/org/springframework/util/xml/StaxEventHandler.java
  8. 10
      spring-core/src/main/java/org/springframework/util/xml/StaxEventXMLReader.java
  9. 3
      spring-core/src/main/java/org/springframework/util/xml/StaxStreamHandler.java
  10. 6
      spring-core/src/main/java/org/springframework/util/xml/StaxStreamXMLReader.java
  11. 6
      spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamReader.java
  12. 6
      spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamWriter.java

11
spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCache.java vendored

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@
package org.springframework.cache.jcache; package org.springframework.cache.jcache;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import javax.cache.Cache;
import javax.cache.processor.EntryProcessor; import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException; import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry; import javax.cache.processor.MutableEntry;
@ -36,14 +37,14 @@ import org.springframework.util.Assert;
*/ */
public class JCacheCache extends AbstractValueAdaptingCache { public class JCacheCache extends AbstractValueAdaptingCache {
private final javax.cache.Cache<Object, Object> cache; private final Cache<Object, Object> cache;
/** /**
* Create an {@link org.springframework.cache.jcache.JCacheCache} instance. * Create an {@link org.springframework.cache.jcache.JCacheCache} instance.
* @param jcache backing JCache Cache instance * @param jcache backing JCache Cache instance
*/ */
public JCacheCache(javax.cache.Cache<Object, Object> jcache) { public JCacheCache(Cache<Object, Object> jcache) {
this(jcache, true); this(jcache, true);
} }
@ -52,7 +53,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
* @param jcache backing JCache Cache instance * @param jcache backing JCache Cache instance
* @param allowNullValues whether to accept and convert null values for this cache * @param allowNullValues whether to accept and convert null values for this cache
*/ */
public JCacheCache(javax.cache.Cache<Object, Object> jcache, boolean allowNullValues) { public JCacheCache(Cache<Object, Object> jcache, boolean allowNullValues) {
super(allowNullValues); super(allowNullValues);
Assert.notNull(jcache, "Cache must not be null"); Assert.notNull(jcache, "Cache must not be null");
this.cache = jcache; this.cache = jcache;
@ -65,7 +66,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
} }
@Override @Override
public final javax.cache.Cache<Object, Object> getNativeCache() { public final Cache<Object, Object> getNativeCache() {
return this.cache; return this.cache;
} }

8
spring-context-support/src/main/java/org/springframework/cache/jcache/JCacheCacheManager.java vendored

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ import org.springframework.cache.transaction.AbstractTransactionSupportingCacheM
*/ */
public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager { public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager {
private javax.cache.CacheManager cacheManager; private CacheManager cacheManager;
private boolean allowNullValues = true; private boolean allowNullValues = true;
@ -60,14 +60,14 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
/** /**
* Set the backing JCache {@link javax.cache.CacheManager}. * Set the backing JCache {@link javax.cache.CacheManager}.
*/ */
public void setCacheManager(javax.cache.CacheManager cacheManager) { public void setCacheManager(CacheManager cacheManager) {
this.cacheManager = cacheManager; this.cacheManager = cacheManager;
} }
/** /**
* Return the backing JCache {@link javax.cache.CacheManager}. * Return the backing JCache {@link javax.cache.CacheManager}.
*/ */
public javax.cache.CacheManager getCacheManager() { public CacheManager getCacheManager() {
return this.cacheManager; return this.cacheManager;
} }

8
spring-context/src/main/java/org/springframework/cache/annotation/SpringCacheAnnotationParser.java vendored

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -58,7 +58,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
return parseCacheAnnotations(defaultConfig, method); return parseCacheAnnotations(defaultConfig, method);
} }
protected Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) { private Collection<CacheOperation> parseCacheAnnotations(DefaultCacheConfig cachingConfig, AnnotatedElement ae) {
Collection<CacheOperation> ops = null; Collection<CacheOperation> ops = null;
Collection<Cacheable> cacheables = AnnotatedElementUtils.getAllMergedAnnotations(ae, Cacheable.class); Collection<Cacheable> cacheables = AnnotatedElementUtils.getAllMergedAnnotations(ae, Cacheable.class);
@ -68,6 +68,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable)); ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable));
} }
} }
Collection<CacheEvict> evicts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CacheEvict.class); Collection<CacheEvict> evicts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CacheEvict.class);
if (!evicts.isEmpty()) { if (!evicts.isEmpty()) {
ops = lazyInit(ops); ops = lazyInit(ops);
@ -75,6 +76,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parseEvictAnnotation(ae, cachingConfig, evict)); ops.add(parseEvictAnnotation(ae, cachingConfig, evict));
} }
} }
Collection<CachePut> puts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CachePut.class); Collection<CachePut> puts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CachePut.class);
if (!puts.isEmpty()) { if (!puts.isEmpty()) {
ops = lazyInit(ops); ops = lazyInit(ops);
@ -82,6 +84,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parsePutAnnotation(ae, cachingConfig, put)); ops.add(parsePutAnnotation(ae, cachingConfig, put));
} }
} }
Collection<Caching> cachings = AnnotatedElementUtils.getAllMergedAnnotations(ae, Caching.class); Collection<Caching> cachings = AnnotatedElementUtils.getAllMergedAnnotations(ae, Caching.class);
if (!cachings.isEmpty()) { if (!cachings.isEmpty()) {
ops = lazyInit(ops); ops = lazyInit(ops);
@ -283,7 +286,6 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
builder.setCacheManager(this.cacheManager); builder.setCacheManager(this.cacheManager);
} }
} }
} }
} }

17
spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -145,7 +145,7 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* Parse the StAX XML reader passed at construction-time. * Parse the StAX XML reader passed at construction-time.
* <p><b>NOTE:</b>: The given system identifier is not read, but ignored. * <p><b>NOTE:</b>: The given system identifier is not read, but ignored.
* @param ignored is ignored * @param ignored is ignored
* @throws SAXException A SAX exception, possibly wrapping a {@code XMLStreamException} * @throws SAXException a SAX exception, possibly wrapping a {@code XMLStreamException}
*/ */
@Override @Override
public final void parse(String ignored) throws SAXException { public final void parse(String ignored) throws SAXException {
@ -182,13 +182,10 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* @see org.xml.sax.ContentHandler#startPrefixMapping(String, String) * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
*/ */
protected void startPrefixMapping(String prefix, String namespace) throws SAXException { protected void startPrefixMapping(String prefix, String namespace) throws SAXException {
if (getContentHandler() != null) { if (getContentHandler() != null && StringUtils.hasLength(namespace)) {
if (prefix == null) { if (prefix == null) {
prefix = ""; prefix = "";
} }
if (!StringUtils.hasLength(namespace)) {
return;
}
if (!namespace.equals(this.namespaces.get(prefix))) { if (!namespace.equals(this.namespaces.get(prefix))) {
getContentHandler().startPrefixMapping(prefix, namespace); getContentHandler().startPrefixMapping(prefix, namespace);
this.namespaces.put(prefix, namespace); this.namespaces.put(prefix, namespace);
@ -201,11 +198,9 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* @see org.xml.sax.ContentHandler#endPrefixMapping(String) * @see org.xml.sax.ContentHandler#endPrefixMapping(String)
*/ */
protected void endPrefixMapping(String prefix) throws SAXException { protected void endPrefixMapping(String prefix) throws SAXException {
if (getContentHandler() != null) { if (getContentHandler() != null && this.namespaces.containsKey(prefix)) {
if (this.namespaces.containsKey(prefix)) { getContentHandler().endPrefixMapping(prefix);
getContentHandler().endPrefixMapping(prefix); this.namespaces.remove(prefix);
this.namespaces.remove(prefix);
}
} }
} }

27
spring-core/src/main/java/org/springframework/util/xml/AbstractXMLStreamReader.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -21,8 +21,6 @@ import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader; import javax.xml.stream.XMLStreamReader;
import org.springframework.util.Assert;
/** /**
* Abstract base class for {@code XMLStreamReader}s. * Abstract base class for {@code XMLStreamReader}s.
* *
@ -34,7 +32,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
@Override @Override
public String getElementText() throws XMLStreamException { public String getElementText() throws XMLStreamException {
if (getEventType() != XMLStreamConstants.START_ELEMENT) { if (getEventType() != XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException("parser must be on START_ELEMENT to read next text", getLocation()); throw new XMLStreamException("Parser must be on START_ELEMENT to read next text", getLocation());
} }
int eventType = next(); int eventType = next();
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -48,11 +46,11 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
// skipping // skipping
} }
else if (eventType == XMLStreamConstants.END_DOCUMENT) { else if (eventType == XMLStreamConstants.END_DOCUMENT) {
throw new XMLStreamException("unexpected end of document when reading element text content", throw new XMLStreamException("Unexpected end of document when reading element text content",
getLocation()); getLocation());
} }
else if (eventType == XMLStreamConstants.START_ELEMENT) { else if (eventType == XMLStreamConstants.START_ELEMENT) {
throw new XMLStreamException("element text content may not contain START_ELEMENT", getLocation()); throw new XMLStreamException("Element text content may not contain START_ELEMENT", getLocation());
} }
else { else {
throw new XMLStreamException("Unexpected event type " + eventType, getLocation()); throw new XMLStreamException("Unexpected event type " + eventType, getLocation());
@ -84,22 +82,21 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
return getName().getNamespaceURI(); return getName().getNamespaceURI();
} }
else { else {
throw new IllegalStateException("parser must be on START_ELEMENT or END_ELEMENT state"); throw new IllegalStateException("Parser must be on START_ELEMENT or END_ELEMENT state");
} }
} }
@Override @Override
public String getNamespaceURI(String prefix) { public String getNamespaceURI(String prefix) {
Assert.notNull(prefix, "No prefix given");
return getNamespaceContext().getNamespaceURI(prefix); return getNamespaceContext().getNamespaceURI(prefix);
} }
@Override @Override
public boolean hasText() { public boolean hasText() {
int eventType = getEventType(); int eventType = getEventType();
return eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.CHARACTERS || return (eventType == XMLStreamConstants.SPACE || eventType == XMLStreamConstants.CHARACTERS ||
eventType == XMLStreamConstants.COMMENT || eventType == XMLStreamConstants.CDATA || eventType == XMLStreamConstants.COMMENT || eventType == XMLStreamConstants.CDATA ||
eventType == XMLStreamConstants.ENTITY_REFERENCE; eventType == XMLStreamConstants.ENTITY_REFERENCE);
} }
@Override @Override
@ -109,14 +106,14 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
return getName().getPrefix(); return getName().getPrefix();
} }
else { else {
throw new IllegalStateException("parser must be on START_ELEMENT or END_ELEMENT state"); throw new IllegalStateException("Parser must be on START_ELEMENT or END_ELEMENT state");
} }
} }
@Override @Override
public boolean hasName() { public boolean hasName() {
int eventType = getEventType(); int eventType = getEventType();
return eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT; return (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT);
} }
@Override @Override
@ -174,7 +171,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
} }
@Override @Override
public boolean hasNext() throws XMLStreamException { public boolean hasNext() {
return getEventType() != END_DOCUMENT; return getEventType() != END_DOCUMENT;
} }
@ -189,8 +186,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
} }
@Override @Override
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) {
throws XMLStreamException {
char[] source = getTextCharacters(); char[] source = getTextCharacters();
length = Math.min(length, source.length); length = Math.min(length, source.length);
System.arraycopy(source, sourceStart, target, targetStart, length); System.arraycopy(source, sourceStart, target, targetStart, length);
@ -201,4 +197,5 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
public int getTextLength() { public int getTextLength() {
return getText().length(); return getText().length();
} }
} }

60
spring-core/src/main/java/org/springframework/util/xml/DomContentHandler.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2012 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,16 +27,13 @@ import org.w3c.dom.Text;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler; import org.xml.sax.ContentHandler;
import org.xml.sax.Locator; import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.springframework.util.Assert;
/** /**
* SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s. * SAX {@code ContentHandler} that transforms callback calls to DOM {@code Node}s.
* *
* @author Arjen Poutsma * @author Arjen Poutsma
* @see org.w3c.dom.Node
* @since 3.0 * @since 3.0
* @see org.w3c.dom.Node
*/ */
class DomContentHandler implements ContentHandler { class DomContentHandler implements ContentHandler {
@ -46,36 +43,35 @@ class DomContentHandler implements ContentHandler {
private final Node node; private final Node node;
/** /**
* Creates a new instance of the {@code DomContentHandler} with the given node. * Create a new instance of the {@code DomContentHandler} with the given node.
*
* @param node the node to publish events to * @param node the node to publish events to
*/ */
DomContentHandler(Node node) { DomContentHandler(Node node) {
Assert.notNull(node, "node must not be null");
this.node = node; this.node = node;
if (node instanceof Document) { if (node instanceof Document) {
document = (Document) node; this.document = (Document) node;
} }
else { else {
document = node.getOwnerDocument(); this.document = node.getOwnerDocument();
} }
Assert.notNull(document, "document must not be null");
} }
private Node getParent() { private Node getParent() {
if (!elements.isEmpty()) { if (!this.elements.isEmpty()) {
return elements.get(elements.size() - 1); return this.elements.get(this.elements.size() - 1);
} }
else { else {
return node; return this.node;
} }
} }
@Override @Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { public void startElement(String uri, String localName, String qName, Attributes attributes) {
Node parent = getParent(); Node parent = getParent();
Element element = document.createElementNS(uri, qName); Element element = this.document.createElementNS(uri, qName);
for (int i = 0; i < attributes.getLength(); i++) { for (int i = 0; i < attributes.getLength(); i++) {
String attrUri = attributes.getURI(i); String attrUri = attributes.getURI(i);
String attrQname = attributes.getQName(i); String attrQname = attributes.getQName(i);
@ -85,16 +81,16 @@ class DomContentHandler implements ContentHandler {
} }
} }
element = (Element) parent.appendChild(element); element = (Element) parent.appendChild(element);
elements.add(element); this.elements.add(element);
} }
@Override @Override
public void endElement(String uri, String localName, String qName) throws SAXException { public void endElement(String uri, String localName, String qName) {
elements.remove(elements.size() - 1); this.elements.remove(this.elements.size() - 1);
} }
@Override @Override
public void characters(char[] ch, int start, int length) throws SAXException { public void characters(char[] ch, int start, int length) {
String data = new String(ch, start, length); String data = new String(ch, start, length);
Node parent = getParent(); Node parent = getParent();
Node lastChild = parent.getLastChild(); Node lastChild = parent.getLastChild();
@ -102,47 +98,47 @@ class DomContentHandler implements ContentHandler {
((Text) lastChild).appendData(data); ((Text) lastChild).appendData(data);
} }
else { else {
Text text = document.createTextNode(data); Text text = this.document.createTextNode(data);
parent.appendChild(text); parent.appendChild(text);
} }
} }
@Override @Override
public void processingInstruction(String target, String data) throws SAXException { public void processingInstruction(String target, String data) {
Node parent = getParent(); Node parent = getParent();
ProcessingInstruction pi = document.createProcessingInstruction(target, data); ProcessingInstruction pi = this.document.createProcessingInstruction(target, data);
parent.appendChild(pi); parent.appendChild(pi);
} }
/*
* Unsupported // Unsupported
*/
@Override @Override
public void setDocumentLocator(Locator locator) { public void setDocumentLocator(Locator locator) {
} }
@Override @Override
public void startDocument() throws SAXException { public void startDocument() {
} }
@Override @Override
public void endDocument() throws SAXException { public void endDocument() {
} }
@Override @Override
public void startPrefixMapping(String prefix, String uri) throws SAXException { public void startPrefixMapping(String prefix, String uri) {
} }
@Override @Override
public void endPrefixMapping(String prefix) throws SAXException { public void endPrefixMapping(String prefix) {
} }
@Override @Override
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException { public void ignorableWhitespace(char[] ch, int start, int length) {
} }
@Override @Override
public void skippedEntity(String name) throws SAXException { public void skippedEntity(String name) {
} }
} }

16
spring-core/src/main/java/org/springframework/util/xml/StaxEventHandler.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -95,9 +95,9 @@ class StaxEventHandler extends AbstractStaxHandler {
} }
private List<Namespace> getNamespaces(Map<String, String> namespaceMapping) { private List<Namespace> getNamespaces(Map<String, String> namespaceMappings) {
List<Namespace> result = new ArrayList<Namespace>(); List<Namespace> result = new ArrayList<Namespace>(namespaceMappings.size());
for (Map.Entry<String, String> entry : namespaceMapping.entrySet()) { for (Map.Entry<String, String> entry : namespaceMappings.entrySet()) {
String prefix = entry.getKey(); String prefix = entry.getKey();
String namespaceUri = entry.getValue(); String namespaceUri = entry.getValue();
result.add(this.eventFactory.createNamespace(prefix, namespaceUri)); result.add(this.eventFactory.createNamespace(prefix, namespaceUri));
@ -106,8 +106,9 @@ class StaxEventHandler extends AbstractStaxHandler {
} }
private List<Attribute> getAttributes(Attributes attributes) { private List<Attribute> getAttributes(Attributes attributes) {
List<Attribute> result = new ArrayList<Attribute>(); int attrLength = attributes.getLength();
for (int i = 0; i < attributes.getLength(); i++) { List<Attribute> result = new ArrayList<Attribute>(attrLength);
for (int i = 0; i < attrLength; i++) {
QName attrName = toQName(attributes.getURI(i), attributes.getQName(i)); QName attrName = toQName(attributes.getURI(i), attributes.getQName(i));
if (!isNamespaceDeclaration(attrName)) { if (!isNamespaceDeclaration(attrName)) {
result.add(this.eventFactory.createAttribute(attrName, attributes.getValue(i))); result.add(this.eventFactory.createAttribute(attrName, attributes.getValue(i)));
@ -153,9 +154,8 @@ class StaxEventHandler extends AbstractStaxHandler {
} }
// Ignored // Ignored
@Override @Override
protected void skippedEntityInternal(String name) throws XMLStreamException { protected void skippedEntityInternal(String name) {
} }

10
spring-core/src/main/java/org/springframework/util/xml/StaxEventXMLReader.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -41,7 +41,6 @@ import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2; import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -69,14 +68,13 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
/** /**
* Constructs a new instance of the {@code StaxEventXmlReader} that reads from the given * Constructs a new instance of the {@code StaxEventXmlReader} that reads from
* {@code XMLEventReader}. The supplied event reader must be in {@code XMLStreamConstants.START_DOCUMENT} or * the given {@code XMLEventReader}. The supplied event reader must be in
* {@code XMLStreamConstants.START_ELEMENT} state. * {@code XMLStreamConstants.START_DOCUMENT} or {@code XMLStreamConstants.START_ELEMENT} state.
* @param reader the {@code XMLEventReader} to read from * @param reader the {@code XMLEventReader} to read from
* @throws IllegalStateException if the reader is not at the start of a document or element * @throws IllegalStateException if the reader is not at the start of a document or element
*/ */
StaxEventXMLReader(XMLEventReader reader) { StaxEventXMLReader(XMLEventReader reader) {
Assert.notNull(reader, "'reader' must not be null");
try { try {
XMLEvent event = reader.peek(); XMLEvent event = reader.peek();
if (event != null && !(event.isStartDocument() || event.isStartElement())) { if (event != null && !(event.isStartDocument() || event.isStartElement())) {

3
spring-core/src/main/java/org/springframework/util/xml/StaxStreamHandler.java

@ -27,8 +27,6 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler; import org.xml.sax.ext.LexicalHandler;
import org.springframework.util.Assert;
/** /**
* SAX {@link org.xml.sax.ContentHandler} and {@link LexicalHandler} * SAX {@link org.xml.sax.ContentHandler} and {@link LexicalHandler}
* that writes to an {@link XMLStreamWriter}. * that writes to an {@link XMLStreamWriter}.
@ -42,7 +40,6 @@ class StaxStreamHandler extends AbstractStaxHandler {
public StaxStreamHandler(XMLStreamWriter streamWriter) { public StaxStreamHandler(XMLStreamWriter streamWriter) {
Assert.notNull(streamWriter, "XMLStreamWriter must not be null");
this.streamWriter = streamWriter; this.streamWriter = streamWriter;
} }

6
spring-core/src/main/java/org/springframework/util/xml/StaxStreamXMLReader.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2017 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,6 @@ import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2; import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.AttributesImpl;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
@ -61,7 +60,6 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
* @throws IllegalStateException if the reader is not at the start of a document or element * @throws IllegalStateException if the reader is not at the start of a document or element
*/ */
StaxStreamXMLReader(XMLStreamReader reader) { StaxStreamXMLReader(XMLStreamReader reader) {
Assert.notNull(reader, "'reader' must not be null");
int event = reader.getEventType(); int event = reader.getEventType();
if (!(event == XMLStreamConstants.START_DOCUMENT || event == XMLStreamConstants.START_ELEMENT)) { if (!(event == XMLStreamConstants.START_DOCUMENT || event == XMLStreamConstants.START_ELEMENT)) {
throw new IllegalStateException("XMLEventReader not at start of document or element"); throw new IllegalStateException("XMLEventReader not at start of document or element");
@ -238,7 +236,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
private void handleDtd() throws SAXException { private void handleDtd() throws SAXException {
if (getLexicalHandler() != null) { if (getLexicalHandler() != null) {
javax.xml.stream.Location location = this.reader.getLocation(); Location location = this.reader.getLocation();
getLexicalHandler().startDTD(null, location.getPublicId(), location.getSystemId()); getLexicalHandler().startDTD(null, location.getPublicId(), location.getSystemId());
} }
if (getLexicalHandler() != null) { if (getLexicalHandler() != null) {

6
spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamReader.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -92,7 +92,7 @@ class XMLEventStreamReader extends AbstractXMLStreamReader {
@Override @Override
public boolean isStandalone() { public boolean isStandalone() {
if (this.event.isStartDocument()) { if (this.event.isStartDocument()) {
return ((StartDocument) event).isStandalone(); return ((StartDocument) this.event).isStandalone();
} }
else { else {
throw new IllegalStateException(); throw new IllegalStateException();
@ -147,7 +147,7 @@ class XMLEventStreamReader extends AbstractXMLStreamReader {
@Override @Override
public String getText() { public String getText() {
if (this.event.isCharacters()) { if (this.event.isCharacters()) {
return event.asCharacters().getData(); return this.event.asCharacters().getData();
} }
else if (this.event.getEventType() == XMLEvent.COMMENT) { else if (this.event.getEventType() == XMLEvent.COMMENT) {
return ((Comment) this.event).getText(); return ((Comment) this.event).getText();

6
spring-core/src/main/java/org/springframework/util/xml/XMLEventStreamWriter.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2013 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -29,8 +29,6 @@ import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.Namespace; import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement; import javax.xml.stream.events.StartElement;
import org.springframework.util.Assert;
/** /**
* Implementation of the {@link javax.xml.stream.XMLStreamWriter} interface * Implementation of the {@link javax.xml.stream.XMLStreamWriter} interface
* that wraps an {@link XMLEventWriter}. * that wraps an {@link XMLEventWriter}.
@ -53,8 +51,6 @@ class XMLEventStreamWriter implements XMLStreamWriter {
public XMLEventStreamWriter(XMLEventWriter eventWriter, XMLEventFactory eventFactory) { public XMLEventStreamWriter(XMLEventWriter eventWriter, XMLEventFactory eventFactory) {
Assert.notNull(eventWriter, "'eventWriter' must not be null");
Assert.notNull(eventFactory, "'eventFactory' must not be null");
this.eventWriter = eventWriter; this.eventWriter = eventWriter;
this.eventFactory = eventFactory; this.eventFactory = eventFactory;
} }

Loading…
Cancel
Save