Package org.ametys.core.util.path
Class PathSource
java.lang.Object
org.ametys.core.util.path.PathSource
- All Implemented Interfaces:
ModifiableSource,ModifiableTraversableSource,MoveableSource,Source,TraversableSource
- Direct Known Subclasses:
SkinSource
A
ModifiableTraversableSource for path objects.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedEmpty constructorPathSource(String uri) Builds a PathSource given an URI, which doesn't necessarily have to start with "file:"PathSource(String scheme, String uri, Path path) Builds a PathSource, given an URI scheme, URI and a Path.PathSource(String scheme, Path path) Builds a PathSource, given an URI scheme and a Path. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCancel(OutputStream stream) Can the data sent to anOutputStreamreturned bygetOutputStream()be cancelled ?voidcancel(OutputStream stream) Cancel the data sent to anOutputStreamreturned bygetOutputStream().voidvoiddelete()Delete the source.booleanexists()longgetFile()Get the associated filelonggetName()Get anInputStreamwhere raw bytes can be written to.getURI()booleanvoidvoidvoidrefresh()
-
Field Details
-
_path
The file -
_scheme
The scheme -
_uri
The URI of this source -
_externalUri
The uri taking in account the final file
-
-
Constructor Details
-
PathSource
protected PathSource()Empty constructor -
PathSource
Builds a PathSource given an URI, which doesn't necessarily have to start with "file:"- Parameters:
uri- The filURI- Throws:
SourceException- If URL cannot be createdMalformedURLException- If URL is malformed
-
PathSource
Builds a PathSource, given an URI scheme and a Path.- Parameters:
scheme- The schemepath- The file- Throws:
SourceException- If url cannot be created
-
PathSource
Builds a PathSource, given an URI scheme, URI and a Path.- Parameters:
scheme- The schemeuri- the URIpath- The file
-
-
Method Details
-
getFile
Get the associated file- Returns:
- The underlying path
-
getContentLength
- Specified by:
getContentLengthin interfaceSource
-
getInputStream
- Specified by:
getInputStreamin interfaceSource- Throws:
IOExceptionSourceNotFoundException
-
getLastModified
- Specified by:
getLastModifiedin interfaceSource
-
getMimeType
- Specified by:
getMimeTypein interfaceSource
-
getScheme
-
getURI
-
getValidity
- Specified by:
getValidityin interfaceSource
-
refresh
-
exists
-
getChild
- Specified by:
getChildin interfaceTraversableSource- Throws:
SourceException
-
getChildren
- Specified by:
getChildrenin interfaceTraversableSource- Throws:
SourceException
-
getName
- Specified by:
getNamein interfaceTraversableSource
-
getParent
- Specified by:
getParentin interfaceTraversableSource- Throws:
SourceException
-
isCollection
- Specified by:
isCollectionin interfaceTraversableSource
-
getOutputStream
Get anInputStreamwhere raw bytes can be written to. The signification of these bytes is implementation-dependent and is not restricted to a serialized XML document. The output stream returned actually writes to a temp file that replaces the real one on close. This temp file is used as lock to forbid multiple simultaneous writes. The real file is updated atomically when the output stream is closed. The returned stream must be closed or cancelled by the calling code.- Specified by:
getOutputStreamin interfaceModifiableSource- Returns:
- a stream to write to
- Throws:
ConcurrentModificationException- if another thread is currently writing to this file.IOException
-
canCancel
Can the data sent to anOutputStreamreturned bygetOutputStream()be cancelled ?- Specified by:
canCancelin interfaceModifiableSource- Returns:
- true if the stream can be cancelled
-
cancel
Cancel the data sent to anOutputStreamreturned bygetOutputStream().After cancel, the stream should no more be used.
- Specified by:
cancelin interfaceModifiableSource- Throws:
SourceException
-
delete
Delete the source.- Specified by:
deletein interfaceModifiableSource- Throws:
SourceException
-
makeCollection
- Specified by:
makeCollectionin interfaceModifiableTraversableSource- Throws:
SourceException
-
copyTo
- Specified by:
copyToin interfaceMoveableSource- Throws:
SourceException
-
moveTo
- Specified by:
moveToin interfaceMoveableSource- Throws:
SourceException
-