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 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.cache.jcache;
import java.util.concurrent.Callable;
import javax.cache.Cache;
import javax.cache.processor.EntryProcessor;
import javax.cache.processor.EntryProcessorException;
import javax.cache.processor.MutableEntry;
@ -36,14 +37,14 @@ import org.springframework.util.Assert; @@ -36,14 +37,14 @@ import org.springframework.util.Assert;
*/
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.
* @param jcache backing JCache Cache instance
*/
public JCacheCache(javax.cache.Cache<Object, Object> jcache) {
public JCacheCache(Cache<Object, Object> jcache) {
this(jcache, true);
}
@ -52,7 +53,7 @@ public class JCacheCache extends AbstractValueAdaptingCache { @@ -52,7 +53,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
* @param jcache backing JCache Cache instance
* @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);
Assert.notNull(jcache, "Cache must not be null");
this.cache = jcache;
@ -65,7 +66,7 @@ public class JCacheCache extends AbstractValueAdaptingCache { @@ -65,7 +66,7 @@ public class JCacheCache extends AbstractValueAdaptingCache {
}
@Override
public final javax.cache.Cache<Object, Object> getNativeCache() {
public final Cache<Object, Object> getNativeCache() {
return this.cache;
}

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

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -36,7 +36,7 @@ import org.springframework.cache.transaction.AbstractTransactionSupportingCacheM @@ -36,7 +36,7 @@ import org.springframework.cache.transaction.AbstractTransactionSupportingCacheM
*/
public class JCacheCacheManager extends AbstractTransactionSupportingCacheManager {
private javax.cache.CacheManager cacheManager;
private CacheManager cacheManager;
private boolean allowNullValues = true;
@ -60,14 +60,14 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage @@ -60,14 +60,14 @@ public class JCacheCacheManager extends AbstractTransactionSupportingCacheManage
/**
* Set the backing JCache {@link javax.cache.CacheManager}.
*/
public void setCacheManager(javax.cache.CacheManager cacheManager) {
public void setCacheManager(CacheManager cacheManager) {
this.cacheManager = cacheManager;
}
/**
* Return the backing JCache {@link javax.cache.CacheManager}.
*/
public javax.cache.CacheManager getCacheManager() {
public CacheManager getCacheManager() {
return this.cacheManager;
}

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

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -58,7 +58,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -58,7 +58,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
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<Cacheable> cacheables = AnnotatedElementUtils.getAllMergedAnnotations(ae, Cacheable.class);
@ -68,6 +68,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -68,6 +68,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parseCacheableAnnotation(ae, cachingConfig, cacheable));
}
}
Collection<CacheEvict> evicts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CacheEvict.class);
if (!evicts.isEmpty()) {
ops = lazyInit(ops);
@ -75,6 +76,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -75,6 +76,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parseEvictAnnotation(ae, cachingConfig, evict));
}
}
Collection<CachePut> puts = AnnotatedElementUtils.getAllMergedAnnotations(ae, CachePut.class);
if (!puts.isEmpty()) {
ops = lazyInit(ops);
@ -82,6 +84,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -82,6 +84,7 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
ops.add(parsePutAnnotation(ae, cachingConfig, put));
}
}
Collection<Caching> cachings = AnnotatedElementUtils.getAllMergedAnnotations(ae, Caching.class);
if (!cachings.isEmpty()) {
ops = lazyInit(ops);
@ -283,7 +286,6 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria @@ -283,7 +286,6 @@ public class SpringCacheAnnotationParser implements CacheAnnotationParser, Seria
builder.setCacheManager(this.cacheManager);
}
}
}
}

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

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -145,7 +145,7 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader { @@ -145,7 +145,7 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* Parse the StAX XML reader passed at construction-time.
* <p><b>NOTE:</b>: The given system identifier is not read, but 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
public final void parse(String ignored) throws SAXException {
@ -182,13 +182,10 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader { @@ -182,13 +182,10 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
*/
protected void startPrefixMapping(String prefix, String namespace) throws SAXException {
if (getContentHandler() != null) {
if (getContentHandler() != null && StringUtils.hasLength(namespace)) {
if (prefix == null) {
prefix = "";
}
if (!StringUtils.hasLength(namespace)) {
return;
}
if (!namespace.equals(this.namespaces.get(prefix))) {
getContentHandler().startPrefixMapping(prefix, namespace);
this.namespaces.put(prefix, namespace);
@ -201,11 +198,9 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader { @@ -201,11 +198,9 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader {
* @see org.xml.sax.ContentHandler#endPrefixMapping(String)
*/
protected void endPrefixMapping(String prefix) throws SAXException {
if (getContentHandler() != null) {
if (this.namespaces.containsKey(prefix)) {
getContentHandler().endPrefixMapping(prefix);
this.namespaces.remove(prefix);
}
if (getContentHandler() != null && this.namespaces.containsKey(prefix)) {
getContentHandler().endPrefixMapping(prefix);
this.namespaces.remove(prefix);
}
}

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

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -21,8 +21,6 @@ import javax.xml.stream.XMLStreamConstants; @@ -21,8 +21,6 @@ import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.springframework.util.Assert;
/**
* Abstract base class for {@code XMLStreamReader}s.
*
@ -34,7 +32,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader { @@ -34,7 +32,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
@Override
public String getElementText() throws XMLStreamException {
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();
StringBuilder builder = new StringBuilder();
@ -48,11 +46,11 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader { @@ -48,11 +46,11 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
// skipping
}
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());
}
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 {
throw new XMLStreamException("Unexpected event type " + eventType, getLocation());
@ -84,22 +82,21 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader { @@ -84,22 +82,21 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
return getName().getNamespaceURI();
}
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
public String getNamespaceURI(String prefix) {
Assert.notNull(prefix, "No prefix given");
return getNamespaceContext().getNamespaceURI(prefix);
}
@Override
public boolean hasText() {
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.ENTITY_REFERENCE;
eventType == XMLStreamConstants.ENTITY_REFERENCE);
}
@Override
@ -109,14 +106,14 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader { @@ -109,14 +106,14 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
return getName().getPrefix();
}
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
public boolean hasName() {
int eventType = getEventType();
return eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT;
return (eventType == XMLStreamConstants.START_ELEMENT || eventType == XMLStreamConstants.END_ELEMENT);
}
@Override
@ -174,7 +171,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader { @@ -174,7 +171,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
}
@Override
public boolean hasNext() throws XMLStreamException {
public boolean hasNext() {
return getEventType() != END_DOCUMENT;
}
@ -189,8 +186,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader { @@ -189,8 +186,7 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
}
@Override
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length)
throws XMLStreamException {
public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) {
char[] source = getTextCharacters();
length = Math.min(length, source.length);
System.arraycopy(source, sourceStart, target, targetStart, length);
@ -201,4 +197,5 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader { @@ -201,4 +197,5 @@ abstract class AbstractXMLStreamReader implements XMLStreamReader {
public int getTextLength() {
return getText().length();
}
}

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

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -27,16 +27,13 @@ import org.w3c.dom.Text; @@ -27,16 +27,13 @@ import org.w3c.dom.Text;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
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.
*
* @author Arjen Poutsma
* @see org.w3c.dom.Node
* @since 3.0
* @see org.w3c.dom.Node
*/
class DomContentHandler implements ContentHandler {
@ -46,36 +43,35 @@ class DomContentHandler implements ContentHandler { @@ -46,36 +43,35 @@ class DomContentHandler implements ContentHandler {
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
*/
DomContentHandler(Node node) {
Assert.notNull(node, "node must not be null");
this.node = node;
if (node instanceof Document) {
document = (Document) node;
this.document = (Document) node;
}
else {
document = node.getOwnerDocument();
this.document = node.getOwnerDocument();
}
Assert.notNull(document, "document must not be null");
}
private Node getParent() {
if (!elements.isEmpty()) {
return elements.get(elements.size() - 1);
if (!this.elements.isEmpty()) {
return this.elements.get(this.elements.size() - 1);
}
else {
return node;
return this.node;
}
}
@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();
Element element = document.createElementNS(uri, qName);
Element element = this.document.createElementNS(uri, qName);
for (int i = 0; i < attributes.getLength(); i++) {
String attrUri = attributes.getURI(i);
String attrQname = attributes.getQName(i);
@ -85,16 +81,16 @@ class DomContentHandler implements ContentHandler { @@ -85,16 +81,16 @@ class DomContentHandler implements ContentHandler {
}
}
element = (Element) parent.appendChild(element);
elements.add(element);
this.elements.add(element);
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
elements.remove(elements.size() - 1);
public void endElement(String uri, String localName, String qName) {
this.elements.remove(this.elements.size() - 1);
}
@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);
Node parent = getParent();
Node lastChild = parent.getLastChild();
@ -102,47 +98,47 @@ class DomContentHandler implements ContentHandler { @@ -102,47 +98,47 @@ class DomContentHandler implements ContentHandler {
((Text) lastChild).appendData(data);
}
else {
Text text = document.createTextNode(data);
Text text = this.document.createTextNode(data);
parent.appendChild(text);
}
}
@Override
public void processingInstruction(String target, String data) throws SAXException {
public void processingInstruction(String target, String data) {
Node parent = getParent();
ProcessingInstruction pi = document.createProcessingInstruction(target, data);
ProcessingInstruction pi = this.document.createProcessingInstruction(target, data);
parent.appendChild(pi);
}
/*
* Unsupported
*/
// Unsupported
@Override
public void setDocumentLocator(Locator locator) {
}
@Override
public void startDocument() throws SAXException {
public void startDocument() {
}
@Override
public void endDocument() throws SAXException {
public void endDocument() {
}
@Override
public void startPrefixMapping(String prefix, String uri) throws SAXException {
public void startPrefixMapping(String prefix, String uri) {
}
@Override
public void endPrefixMapping(String prefix) throws SAXException {
public void endPrefixMapping(String prefix) {
}
@Override
public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
public void ignorableWhitespace(char[] ch, int start, int length) {
}
@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 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -95,9 +95,9 @@ class StaxEventHandler extends AbstractStaxHandler { @@ -95,9 +95,9 @@ class StaxEventHandler extends AbstractStaxHandler {
}
private List<Namespace> getNamespaces(Map<String, String> namespaceMapping) {
List<Namespace> result = new ArrayList<Namespace>();
for (Map.Entry<String, String> entry : namespaceMapping.entrySet()) {
private List<Namespace> getNamespaces(Map<String, String> namespaceMappings) {
List<Namespace> result = new ArrayList<Namespace>(namespaceMappings.size());
for (Map.Entry<String, String> entry : namespaceMappings.entrySet()) {
String prefix = entry.getKey();
String namespaceUri = entry.getValue();
result.add(this.eventFactory.createNamespace(prefix, namespaceUri));
@ -106,8 +106,9 @@ class StaxEventHandler extends AbstractStaxHandler { @@ -106,8 +106,9 @@ class StaxEventHandler extends AbstractStaxHandler {
}
private List<Attribute> getAttributes(Attributes attributes) {
List<Attribute> result = new ArrayList<Attribute>();
for (int i = 0; i < attributes.getLength(); i++) {
int attrLength = attributes.getLength();
List<Attribute> result = new ArrayList<Attribute>(attrLength);
for (int i = 0; i < attrLength; i++) {
QName attrName = toQName(attributes.getURI(i), attributes.getQName(i));
if (!isNamespaceDeclaration(attrName)) {
result.add(this.eventFactory.createAttribute(attrName, attributes.getValue(i)));
@ -153,9 +154,8 @@ class StaxEventHandler extends AbstractStaxHandler { @@ -153,9 +154,8 @@ class StaxEventHandler extends AbstractStaxHandler {
}
// Ignored
@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 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -41,7 +41,6 @@ import org.xml.sax.SAXException; @@ -41,7 +41,6 @@ import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.AttributesImpl;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
@ -69,14 +68,13 @@ class StaxEventXMLReader extends AbstractStaxXMLReader { @@ -69,14 +68,13 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
/**
* Constructs a new instance of the {@code StaxEventXmlReader} that reads from the given
* {@code XMLEventReader}. The supplied event reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
* {@code XMLStreamConstants.START_ELEMENT} state.
* Constructs a new instance of the {@code StaxEventXmlReader} that reads from
* the given {@code XMLEventReader}. The supplied event reader must be in
* {@code XMLStreamConstants.START_DOCUMENT} or {@code XMLStreamConstants.START_ELEMENT} state.
* @param reader the {@code XMLEventReader} to read from
* @throws IllegalStateException if the reader is not at the start of a document or element
*/
StaxEventXMLReader(XMLEventReader reader) {
Assert.notNull(reader, "'reader' must not be null");
try {
XMLEvent event = reader.peek();
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; @@ -27,8 +27,6 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.ext.LexicalHandler;
import org.springframework.util.Assert;
/**
* SAX {@link org.xml.sax.ContentHandler} and {@link LexicalHandler}
* that writes to an {@link XMLStreamWriter}.
@ -42,7 +40,6 @@ class StaxStreamHandler extends AbstractStaxHandler { @@ -42,7 +40,6 @@ class StaxStreamHandler extends AbstractStaxHandler {
public StaxStreamHandler(XMLStreamWriter streamWriter) {
Assert.notNull(streamWriter, "XMLStreamWriter must not be null");
this.streamWriter = streamWriter;
}

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

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

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

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -92,7 +92,7 @@ class XMLEventStreamReader extends AbstractXMLStreamReader { @@ -92,7 +92,7 @@ class XMLEventStreamReader extends AbstractXMLStreamReader {
@Override
public boolean isStandalone() {
if (this.event.isStartDocument()) {
return ((StartDocument) event).isStandalone();
return ((StartDocument) this.event).isStandalone();
}
else {
throw new IllegalStateException();
@ -147,7 +147,7 @@ class XMLEventStreamReader extends AbstractXMLStreamReader { @@ -147,7 +147,7 @@ class XMLEventStreamReader extends AbstractXMLStreamReader {
@Override
public String getText() {
if (this.event.isCharacters()) {
return event.asCharacters().getData();
return this.event.asCharacters().getData();
}
else if (this.event.getEventType() == XMLEvent.COMMENT) {
return ((Comment) this.event).getText();

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

@ -1,5 +1,5 @@ @@ -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");
* you may not use this file except in compliance with the License.
@ -29,8 +29,6 @@ import javax.xml.stream.events.EndElement; @@ -29,8 +29,6 @@ import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
import org.springframework.util.Assert;
/**
* Implementation of the {@link javax.xml.stream.XMLStreamWriter} interface
* that wraps an {@link XMLEventWriter}.
@ -53,8 +51,6 @@ class XMLEventStreamWriter implements XMLStreamWriter { @@ -53,8 +51,6 @@ class XMLEventStreamWriter implements XMLStreamWriter {
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.eventFactory = eventFactory;
}

Loading…
Cancel
Save