Added @Override annotation to interface implementations
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
@@ -19,8 +19,6 @@ package org.springframework.xml.dom;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
@@ -31,6 +29,8 @@ import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* SAX <code>ContentHandler</code> that transforms callback calls to DOM <code>Node</code>s.
|
||||
*
|
||||
@@ -72,6 +72,7 @@ public class DomContentHandler implements ContentHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
|
||||
Node parent = getParent();
|
||||
Element element = document.createElementNS(uri, qName);
|
||||
@@ -87,10 +88,12 @@ public class DomContentHandler implements ContentHandler {
|
||||
elements.add(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, String localName, String qName) throws SAXException {
|
||||
elements.remove(elements.size() - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char ch[], int start, int length) throws SAXException {
|
||||
String data = new String(ch, start, length);
|
||||
Node parent = getParent();
|
||||
@@ -104,6 +107,7 @@ public class DomContentHandler implements ContentHandler {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processingInstruction(String target, String data) throws SAXException {
|
||||
Node parent = getParent();
|
||||
ProcessingInstruction pi = document.createProcessingInstruction(target, data);
|
||||
@@ -114,24 +118,31 @@ public class DomContentHandler implements ContentHandler {
|
||||
* Unsupported
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void setDocumentLocator(Locator locator) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDocument() throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endDocument() throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPrefixMapping(String prefix, String uri) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endPrefixMapping(String prefix) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skippedEntity(String name) throws SAXException {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2012 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -42,6 +42,7 @@ public class SimpleNamespaceContext implements NamespaceContext {
|
||||
|
||||
private Map<String, Set<String>> namespaceUriToPrefixes = new LinkedHashMap<String, Set<String>>();
|
||||
|
||||
@Override
|
||||
public String getNamespaceURI(String prefix) {
|
||||
Assert.notNull(prefix, "prefix is null");
|
||||
if (XMLConstants.XML_NS_PREFIX.equals(prefix)) {
|
||||
@@ -56,11 +57,13 @@ public class SimpleNamespaceContext implements NamespaceContext {
|
||||
return XMLConstants.NULL_NS_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(String namespaceUri) {
|
||||
Iterator<String> iterator = getPrefixes(namespaceUri);
|
||||
return iterator.hasNext() ? iterator.next() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<String> getPrefixes(String namespaceUri) {
|
||||
Set<String> prefixes = getPrefixesInternal(namespaceUri);
|
||||
prefixes = Collections.unmodifiableSet(prefixes);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2006 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
@@ -48,34 +48,42 @@ public abstract class AbstractXmlReader implements XMLReader {
|
||||
|
||||
private LexicalHandler lexicalHandler;
|
||||
|
||||
@Override
|
||||
public ContentHandler getContentHandler() {
|
||||
return contentHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentHandler(ContentHandler contentHandler) {
|
||||
this.contentHandler = contentHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDTDHandler(DTDHandler dtdHandler) {
|
||||
this.dtdHandler = dtdHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DTDHandler getDTDHandler() {
|
||||
return dtdHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityResolver getEntityResolver() {
|
||||
return entityResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEntityResolver(EntityResolver entityResolver) {
|
||||
this.entityResolver = entityResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErrorHandler getErrorHandler() {
|
||||
return errorHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setErrorHandler(ErrorHandler errorHandler) {
|
||||
this.errorHandler = errorHandler;
|
||||
}
|
||||
@@ -90,6 +98,7 @@ public abstract class AbstractXmlReader implements XMLReader {
|
||||
* @throws org.xml.sax.SAXNotRecognizedException
|
||||
* always
|
||||
*/
|
||||
@Override
|
||||
public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
throw new SAXNotRecognizedException(name);
|
||||
}
|
||||
@@ -99,6 +108,7 @@ public abstract class AbstractXmlReader implements XMLReader {
|
||||
*
|
||||
* @throws SAXNotRecognizedException always
|
||||
*/
|
||||
@Override
|
||||
public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
throw new SAXNotRecognizedException(name);
|
||||
}
|
||||
@@ -107,6 +117,7 @@ public abstract class AbstractXmlReader implements XMLReader {
|
||||
* Throws a <code>SAXNotRecognizedException</code> exception when the given property does not signify a lexical
|
||||
* handler. The property name for a lexical handler is <code>http://xml.org/sax/properties/lexical-handler</code>.
|
||||
*/
|
||||
@Override
|
||||
public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
return lexicalHandler;
|
||||
@@ -120,6 +131,7 @@ public abstract class AbstractXmlReader implements XMLReader {
|
||||
* Throws a <code>SAXNotRecognizedException</code> exception when the given property does not signify a lexical
|
||||
* handler. The property name for a lexical handler is <code>http://xml.org/sax/properties/lexical-handler</code>.
|
||||
*/
|
||||
@Override
|
||||
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
|
||||
if ("http://xml.org/sax/properties/lexical-handler".equals(name)) {
|
||||
lexicalHandler = (LexicalHandler) value;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -23,11 +23,11 @@ import javax.xml.transform.Source;
|
||||
import javax.xml.validation.Schema;
|
||||
import javax.xml.validation.Validator;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
* Internal class that uses JAXP 1.0 features to create <code>XmlValidator</code> instances.
|
||||
*
|
||||
@@ -54,10 +54,12 @@ abstract class Jaxp13ValidatorFactory {
|
||||
this.schema = schema;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAXParseException[] validate(Source source) throws IOException {
|
||||
return validate(source, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SAXParseException[] validate(Source source, ValidationErrorHandler errorHandler) throws IOException {
|
||||
if (errorHandler == null) {
|
||||
errorHandler = new DefaultValidationErrorHandler();
|
||||
@@ -79,17 +81,21 @@ abstract class Jaxp13ValidatorFactory {
|
||||
|
||||
private List<SAXParseException> errors = new ArrayList<SAXParseException>();
|
||||
|
||||
@Override
|
||||
public SAXParseException[] getErrors() {
|
||||
return errors.toArray(new SAXParseException[errors.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(SAXParseException ex) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void error(SAXParseException ex) throws SAXException {
|
||||
errors.add(ex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fatalError(SAXParseException ex) throws SAXException {
|
||||
errors.add(ex);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2014 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,13 +21,13 @@ import javax.xml.transform.Source;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
|
||||
import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.springframework.xml.transform.TransformerObjectSupport;
|
||||
|
||||
/**
|
||||
* Abstract base class for implementations of {@link XPathOperations}. Contains a namespaces property.
|
||||
*
|
||||
@@ -48,6 +48,7 @@ public abstract class AbstractXPathTemplate extends TransformerObjectSupport imp
|
||||
this.namespaces = namespaces;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void evaluate(String expression, Source context, NodeCallbackHandler callbackHandler)
|
||||
throws XPathException {
|
||||
evaluate(expression, context, new NodeCallbackHandlerNodeMapper(callbackHandler));
|
||||
@@ -62,6 +63,7 @@ public abstract class AbstractXPathTemplate extends TransformerObjectSupport imp
|
||||
this.callbackHandler = callbackHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object mapNode(Node node, int nodeNum) throws DOMException {
|
||||
callbackHandler.processNode(node);
|
||||
return null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
@@ -83,6 +83,7 @@ abstract class JaxenXPathExpressionFactory {
|
||||
this.xpath = xpath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node evaluateAsNode(Node node) {
|
||||
try {
|
||||
return (Node) xpath.selectSingleNode(node);
|
||||
@@ -92,6 +93,7 @@ abstract class JaxenXPathExpressionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluateAsBoolean(Node node) {
|
||||
try {
|
||||
return xpath.booleanValueOf(node);
|
||||
@@ -101,6 +103,7 @@ abstract class JaxenXPathExpressionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double evaluateAsNumber(Node node) {
|
||||
try {
|
||||
return xpath.numberValueOf(node).doubleValue();
|
||||
@@ -110,6 +113,7 @@ abstract class JaxenXPathExpressionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String evaluateAsString(Node node) {
|
||||
try {
|
||||
return xpath.stringValueOf(node);
|
||||
@@ -119,6 +123,7 @@ abstract class JaxenXPathExpressionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Node> evaluateAsNodeList(Node node) {
|
||||
try {
|
||||
@@ -129,6 +134,7 @@ abstract class JaxenXPathExpressionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T evaluateAsObject(Node context, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
try {
|
||||
Node result = (Node) xpath.selectSingleNode(context);
|
||||
@@ -149,6 +155,7 @@ abstract class JaxenXPathExpressionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> evaluate(Node context, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
try {
|
||||
List<?> nodes = xpath.selectNodes(context);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
@@ -40,6 +40,7 @@ import org.w3c.dom.Node;
|
||||
*/
|
||||
public class JaxenXPathTemplate extends AbstractXPathTemplate {
|
||||
|
||||
@Override
|
||||
public boolean evaluateAsBoolean(String expression, Source context) throws XPathException {
|
||||
try {
|
||||
XPath xpath = createXPath(expression);
|
||||
@@ -54,6 +55,7 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node evaluateAsNode(String expression, Source context) throws XPathException {
|
||||
try {
|
||||
XPath xpath = createXPath(expression);
|
||||
@@ -68,6 +70,7 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Node> evaluateAsNodeList(String expression, Source context) throws XPathException {
|
||||
try {
|
||||
@@ -83,6 +86,7 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double evaluateAsDouble(String expression, Source context) throws XPathException {
|
||||
try {
|
||||
XPath xpath = createXPath(expression);
|
||||
@@ -97,6 +101,7 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String evaluateAsString(String expression, Source context) throws XPathException {
|
||||
try {
|
||||
XPath xpath = createXPath(expression);
|
||||
@@ -111,6 +116,7 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T evaluateAsObject(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
try {
|
||||
XPath xpath = createXPath(expression);
|
||||
@@ -137,6 +143,7 @@ public class JaxenXPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
try {
|
||||
XPath xpath = createXPath(expression);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
@@ -25,12 +25,12 @@ import javax.xml.xpath.XPathConstants;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
|
||||
import org.springframework.xml.namespace.SimpleNamespaceContext;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import org.springframework.xml.namespace.SimpleNamespaceContext;
|
||||
|
||||
/**
|
||||
* JAXP 1.3-specific factory creating {@link XPathExpression} objects.
|
||||
*
|
||||
@@ -98,10 +98,12 @@ abstract class Jaxp13XPathExpressionFactory {
|
||||
this.xpathExpression = xpathExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String evaluateAsString(Node node) {
|
||||
return (String) evaluate(node, XPathConstants.STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Node> evaluateAsNodeList(Node node) {
|
||||
NodeList nodeList = (NodeList) evaluate(node, XPathConstants.NODESET);
|
||||
return toNodeList(nodeList);
|
||||
@@ -127,18 +129,22 @@ abstract class Jaxp13XPathExpressionFactory {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double evaluateAsNumber(Node node) {
|
||||
return (Double) evaluate(node, XPathConstants.NUMBER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluateAsBoolean(Node node) {
|
||||
return (Boolean) evaluate(node, XPathConstants.BOOLEAN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node evaluateAsNode(Node node) {
|
||||
return (Node) evaluate(node, XPathConstants.NODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T evaluateAsObject(Node node, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
Node result = (Node) evaluate(node, XPathConstants.NODE);
|
||||
if (result != null) {
|
||||
@@ -154,6 +160,7 @@ abstract class Jaxp13XPathExpressionFactory {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> evaluate(Node node, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
NodeList nodes = (NodeList) evaluate(node, XPathConstants.NODESET);
|
||||
List<T> results = new ArrayList<T>(nodes.getLength());
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2012 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -33,11 +33,6 @@ import javax.xml.xpath.XPathExpressionException;
|
||||
import javax.xml.xpath.XPathFactory;
|
||||
import javax.xml.xpath.XPathFactoryConfigurationException;
|
||||
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
import org.springframework.xml.namespace.SimpleNamespaceContext;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
import org.springframework.xml.transform.TraxUtils;
|
||||
|
||||
import org.w3c.dom.DOMException;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@@ -46,6 +41,11 @@ import org.w3c.dom.NodeList;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
import org.springframework.util.xml.StaxUtils;
|
||||
import org.springframework.xml.namespace.SimpleNamespaceContext;
|
||||
import org.springframework.xml.transform.TransformerHelper;
|
||||
import org.springframework.xml.transform.TraxUtils;
|
||||
|
||||
/**
|
||||
* Implementation of {@link XPathOperations} that uses JAXP 1.3. JAXP 1.3 is part of Java SE since 1.5.
|
||||
* <p/>
|
||||
@@ -72,15 +72,18 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean evaluateAsBoolean(String expression, Source context) throws XPathException {
|
||||
Boolean result = (Boolean) evaluate(expression, context, XPathConstants.BOOLEAN);
|
||||
return result != null && result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Node evaluateAsNode(String expression, Source context) throws XPathException {
|
||||
return (Node) evaluate(expression, context, XPathConstants.NODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Node> evaluateAsNodeList(String expression, Source context) throws XPathException {
|
||||
NodeList result = (NodeList) evaluate(expression, context, XPathConstants.NODESET);
|
||||
List<Node> nodes = new ArrayList<Node>(result.getLength());
|
||||
@@ -90,15 +93,18 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate {
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double evaluateAsDouble(String expression, Source context) throws XPathException {
|
||||
Double result = (Double) evaluate(expression, context, XPathConstants.NUMBER);
|
||||
return result != null ? result : Double.NaN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String evaluateAsString(String expression, Source context) throws XPathException {
|
||||
return (String) evaluate(expression, context, XPathConstants.STRING);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T evaluateAsObject(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
Node node = evaluateAsNode(expression, context);
|
||||
if (node != null) {
|
||||
@@ -114,6 +120,7 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> evaluate(String expression, Source context, NodeMapper<T> nodeMapper) throws XPathException {
|
||||
NodeList nodes = (NodeList) evaluate(expression, context, XPathConstants.NODESET);
|
||||
List<T> results = new ArrayList<T>(nodes.getLength());
|
||||
@@ -173,33 +180,40 @@ public class Jaxp13XPathTemplate extends AbstractXPathTemplate {
|
||||
this.returnType = returnType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void domSource(Node node) throws XPathExpressionException {
|
||||
result = xpath.evaluate(expression, node, returnType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saxSource(XMLReader reader, InputSource inputSource) throws XPathExpressionException {
|
||||
inputSource(inputSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void staxSource(XMLEventReader eventReader)
|
||||
throws XPathExpressionException, XMLStreamException, TransformerException {
|
||||
Element element = getRootElement(StaxUtils.createCustomStaxSource(eventReader));
|
||||
domSource(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void staxSource(XMLStreamReader streamReader) throws TransformerException, XPathExpressionException {
|
||||
Element element = getRootElement(StaxUtils.createCustomStaxSource(streamReader));
|
||||
domSource(element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void streamSource(InputStream inputStream) throws XPathExpressionException {
|
||||
inputSource(new InputSource(inputStream));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void streamSource(Reader reader) throws XPathExpressionException {
|
||||
inputSource(new InputSource(reader));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void source(String systemId) throws XPathExpressionException {
|
||||
inputSource(new InputSource(systemId));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2005-2010 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
@@ -51,6 +51,7 @@ public class XPathExpressionFactoryBean implements FactoryBean<XPathExpression>,
|
||||
this.namespaces = namespaces;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws IllegalStateException, XPathParseException {
|
||||
Assert.notNull(expressionString, "expression is required");
|
||||
if (CollectionUtils.isEmpty(namespaces)) {
|
||||
@@ -61,14 +62,17 @@ public class XPathExpressionFactoryBean implements FactoryBean<XPathExpression>,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public XPathExpression getObject() throws Exception {
|
||||
return expression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends XPathExpression> getObjectType() {
|
||||
return XPathExpression.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2011 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -90,14 +90,17 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean {
|
||||
this.xsdResource = xsdResource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetNamespace() {
|
||||
return schemaElement.getAttribute("targetNamespace");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source getSource() {
|
||||
return new DOMSource(schemaElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlValidator createValidator() {
|
||||
try {
|
||||
return XmlValidatorFactory.createValidator(xsdResource, XmlValidatorFactory.SCHEMA_W3C_XML);
|
||||
@@ -107,6 +110,7 @@ public class SimpleXsdSchema implements XsdSchema, InitializingBean {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws ParserConfigurationException, IOException, SAXException {
|
||||
Assert.notNull(xsdResource, "'xsd' is required");
|
||||
Assert.isTrue(this.xsdResource.exists(), "xsd '" + this.xsdResource + "' does not exist");
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2012 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -78,6 +78,7 @@ public class CommonsXsdSchema implements XsdSchema {
|
||||
this.collection = collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTargetNamespace() {
|
||||
return schema.getTargetNamespace();
|
||||
}
|
||||
@@ -87,6 +88,7 @@ public class CommonsXsdSchema implements XsdSchema {
|
||||
return result.toArray(new QName[result.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Source getSource() {
|
||||
// try to use the the package-friendly XmlSchemaSerializer first, fall back to slower stream-based version
|
||||
try {
|
||||
@@ -114,6 +116,7 @@ public class CommonsXsdSchema implements XsdSchema {
|
||||
return new StreamSource(bis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlValidator createValidator() {
|
||||
try {
|
||||
Resource resource = new UrlResource(schema.getSourceURI());
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2005-2012 the original author or authors.
|
||||
* Copyright 2005-2014 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -119,10 +119,12 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali
|
||||
this.uriResolver = uriResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResourceLoader(ResourceLoader resourceLoader) {
|
||||
this.resourceLoader = resourceLoader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws IOException {
|
||||
Assert.notEmpty(xsdResources, "'xsds' must not be empty");
|
||||
|
||||
@@ -153,6 +155,7 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public XsdSchema[] getXsdSchemas() {
|
||||
XsdSchema[] result = new XsdSchema[xmlSchemas.size()];
|
||||
for (int i = 0; i < xmlSchemas.size(); i++) {
|
||||
@@ -162,6 +165,7 @@ public class CommonsXsdSchemaCollection implements XsdSchemaCollection, Initiali
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlValidator createValidator() {
|
||||
try {
|
||||
Resource[] resources = new Resource[xmlSchemas.size()];
|
||||
|
||||
Reference in New Issue
Block a user