Polishing
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 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.
|
||||
@@ -51,8 +51,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
* Create a new PathResource from a Path handle.
|
||||
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
|
||||
* the given root:
|
||||
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* @param path a Path handle
|
||||
*/
|
||||
public PathResource(Path path) {
|
||||
@@ -64,8 +63,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
* Create a new PathResource from a Path handle.
|
||||
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
|
||||
* the given root:
|
||||
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* @param path a path
|
||||
* @see java.nio.file.Paths#get(String, String...)
|
||||
*/
|
||||
@@ -78,8 +76,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
* Create a new PathResource from a Path handle.
|
||||
* <p>Note: Unlike {@link FileSystemResource}, when building relative resources
|
||||
* via {@link #createRelative}, the relative path will be built <i>underneath</i>
|
||||
* the given root:
|
||||
* e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* the given root: e.g. Paths.get("C:/dir1/"), relative path "dir2" -> "C:/dir1/dir2"!
|
||||
* @see java.nio.file.Paths#get(URI)
|
||||
* @param uri a path URI
|
||||
*/
|
||||
@@ -184,7 +181,7 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
catch (UnsupportedOperationException ex) {
|
||||
// Only paths on the default file system can be converted to a File:
|
||||
// Do exception translation for cases where conversion is not possible.
|
||||
throw new FileNotFoundException(this.path + " cannot be resolved to " + "absolute file path");
|
||||
throw new FileNotFoundException(this.path + " cannot be resolved to absolute file path");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,11 +201,11 @@ public class PathResource extends AbstractResource implements WritableResource {
|
||||
public long lastModified() throws IOException {
|
||||
// We can not use the superclass method since it uses conversion to a File and
|
||||
// only a Path on the default file system can be converted to a File...
|
||||
return Files.getLastModifiedTime(path).toMillis();
|
||||
return Files.getLastModifiedTime(this.path).toMillis();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation creates a FileResource, applying the given path
|
||||
* This implementation creates a PathResource, applying the given path
|
||||
* relative to the path of the underlying file of this resource descriptor.
|
||||
* @see java.nio.file.Path#resolve(String)
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
@@ -51,17 +51,6 @@ class StaxResult extends SAXResult {
|
||||
private XMLStreamWriter streamWriter;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
|
||||
* @param streamWriter the {@code XMLStreamWriter} to write to
|
||||
*/
|
||||
public StaxResult(XMLStreamWriter streamWriter) {
|
||||
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
|
||||
super.setHandler(handler);
|
||||
super.setLexicalHandler(handler);
|
||||
this.streamWriter = streamWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLEventWriter}.
|
||||
* @param eventWriter the {@code XMLEventWriter} to write to
|
||||
@@ -73,10 +62,22 @@ class StaxResult extends SAXResult {
|
||||
this.eventWriter = eventWriter;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxResult} with the specified {@code XMLStreamWriter}.
|
||||
* @param streamWriter the {@code XMLStreamWriter} to write to
|
||||
*/
|
||||
public StaxResult(XMLStreamWriter streamWriter) {
|
||||
StaxStreamHandler handler = new StaxStreamHandler(streamWriter);
|
||||
super.setHandler(handler);
|
||||
super.setLexicalHandler(handler);
|
||||
this.streamWriter = streamWriter;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@code XMLEventWriter} used by this {@code StaxResult}. If this {@code StaxResult}
|
||||
* was created with an {@code XMLStreamWriter}, the result will be {@code null}.
|
||||
* Return the {@code XMLEventWriter} used by this {@code StaxResult}.
|
||||
* <p>If this {@code StaxResult} was created with an {@code XMLStreamWriter},
|
||||
* the result will be {@code null}.
|
||||
* @return the StAX event writer used by this result
|
||||
* @see #StaxResult(javax.xml.stream.XMLEventWriter)
|
||||
*/
|
||||
@@ -85,8 +86,9 @@ class StaxResult extends SAXResult {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code XMLStreamWriter} used by this {@code StaxResult}. If this {@code StaxResult}
|
||||
* was created with an {@code XMLEventConsumer}, the result will be {@code null}.
|
||||
* Return the {@code XMLStreamWriter} used by this {@code StaxResult}.
|
||||
* <p>If this {@code StaxResult} was created with an {@code XMLEventConsumer},
|
||||
* the result will be {@code null}.
|
||||
* @return the StAX stream writer used by this result
|
||||
* @see #StaxResult(javax.xml.stream.XMLStreamWriter)
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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.
|
||||
@@ -50,18 +50,6 @@ class StaxSource extends SAXSource {
|
||||
private XMLStreamReader streamReader;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}.
|
||||
* The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
|
||||
* {@code XMLStreamConstants.START_ELEMENT} state.
|
||||
* @param streamReader the {@code XMLStreamReader} to read from
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxSource(XMLStreamReader streamReader) {
|
||||
super(new StaxStreamXMLReader(streamReader), new InputSource());
|
||||
this.streamReader = streamReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLEventReader}.
|
||||
* The supplied event reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
|
||||
@@ -74,10 +62,23 @@ class StaxSource extends SAXSource {
|
||||
this.eventReader = eventReader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new instance of the {@code StaxSource} with the specified {@code XMLStreamReader}.
|
||||
* The supplied stream reader must be in {@code XMLStreamConstants.START_DOCUMENT} or
|
||||
* {@code XMLStreamConstants.START_ELEMENT} state.
|
||||
* @param streamReader the {@code XMLStreamReader} to read from
|
||||
* @throws IllegalStateException if the reader is not at the start of a document or element
|
||||
*/
|
||||
StaxSource(XMLStreamReader streamReader) {
|
||||
super(new StaxStreamXMLReader(streamReader), new InputSource());
|
||||
this.streamReader = streamReader;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the {@code XMLEventReader} used by this {@code StaxSource}. If this {@code StaxSource}
|
||||
* was created with an {@code XMLStreamReader}, the result will be {@code null}.
|
||||
* Return the {@code XMLEventReader} used by this {@code StaxSource}.
|
||||
* <p>If this {@code StaxSource} was created with an {@code XMLStreamReader},
|
||||
* the result will be {@code null}.
|
||||
* @return the StAX event reader used by this source
|
||||
* @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader)
|
||||
*/
|
||||
@@ -86,8 +87,9 @@ class StaxSource extends SAXSource {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@code XMLStreamReader} used by this {@code StaxSource}. If this {@code StaxSource}
|
||||
* was created with an {@code XMLEventReader}, the result will be {@code null}.
|
||||
* Return the {@code XMLStreamReader} used by this {@code StaxSource}.
|
||||
* <p>If this {@code StaxSource} was created with an {@code XMLEventReader},
|
||||
* the result will be {@code null}.
|
||||
* @return the StAX event reader used by this source
|
||||
* @see StaxSource#StaxSource(javax.xml.stream.XMLEventReader)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user