Package org.apache.jackrabbit.vault.fs
Class SerializerArtifact
- java.lang.Object
-
- org.apache.jackrabbit.vault.fs.impl.AbstractArtifact
-
- org.apache.jackrabbit.vault.fs.SerializerArtifact
-
- All Implemented Interfaces:
Artifact,Dumpable,ExportArtifact
public class SerializerArtifact extends org.apache.jackrabbit.vault.fs.impl.AbstractArtifact implements ExportArtifact
Implements an output artifact that is based on a serializer, i.e. the preferred access method isAccessType.SPOOL
-
-
Constructor Summary
Constructors Constructor Description SerializerArtifact(Artifact parent, java.lang.String name, java.lang.String ext, ArtifactType type, Serializer serializer, long lastModified)Constructs a new artifact that is based on a content serializer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetContentLength()Returns the length of the serialized data if it's known without doing the actual serialization.java.lang.StringgetContentType()Returns the content type of the serialized data ornullif the type is not known or cannot be determined.VaultInputSourcegetInputSource()Returns an input source to the contents of this artifact.java.io.InputStreamgetInputStream()Returns the input stream to the contents of this artifact.longgetLastModified()Returns the last modified date or0if not known.AccessTypegetPreferredAccess()Returns the preferred access value for this artifact.SerializationTypegetSerializationType()Returns the serialization type of this artifact.voidspool(java.io.OutputStream out)Writes the content to the given output stream and closes it afterwards.-
Methods inherited from class org.apache.jackrabbit.vault.fs.impl.AbstractArtifact
dump, equals, getExtension, getPlatformPath, getRelativePath, getType, hashCode, toString
-
Methods inherited from interface org.apache.jackrabbit.vault.fs.api.Artifact
getExtension, getPlatformPath, getRelativePath, getType
-
-
-
-
Constructor Detail
-
SerializerArtifact
public SerializerArtifact(Artifact parent, java.lang.String name, java.lang.String ext, ArtifactType type, Serializer serializer, long lastModified)
Constructs a new artifact that is based on a content serializer.- Parameters:
parent- the parent artifactname- the name of the artifactext- the extension of the artifacttype- the type of the artifactserializer- the serializer to use for the contentlastModified- the last modified date- Throws:
java.lang.IllegalArgumentException- if the type is not suitable.
-
-
Method Detail
-
getPreferredAccess
public AccessType getPreferredAccess()
Returns the preferred access value for this artifact.- Specified by:
getPreferredAccessin interfaceArtifact- Returns:
- always
AccessType.SPOOL
-
getSerializationType
public SerializationType getSerializationType()
Returns the serialization type of this artifact.- Specified by:
getSerializationTypein interfaceArtifact- Returns:
- the serialization type of this artifact.
-
spool
public void spool(java.io.OutputStream out) throws java.io.IOException, RepositoryExceptionWrites the content to the given output stream and closes it afterwards. This is the preferred method to use for output-artifacts.The specified stream remains open after this method returns.
- Specified by:
spoolin interfaceArtifact- Overrides:
spoolin classorg.apache.jackrabbit.vault.fs.impl.AbstractArtifact- Parameters:
out- the output stream to spool to- Throws:
java.io.IOException- if an I/O error occursRepositoryException- if a repository error occurs
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException, RepositoryExceptionReturns the input stream to the contents of this artifact. This is the preferred method to use for input-artifacts.- Specified by:
getInputStreamin interfaceArtifact- Returns:
- a input stream to the contents of this artifact.
- Throws:
java.io.IOException- if an I/O error occursRepositoryException- if a repository error occurs
-
getInputSource
public VaultInputSource getInputSource() throws java.io.IOException, RepositoryException
Returns an input source to the contents of this artifact. This is also preferred forAccessType.STREAM.- Specified by:
getInputSourcein interfaceArtifact- Returns:
- an input source.
- Throws:
java.io.IOException- if an I/O error occurs.RepositoryException- of a repository error occurs.
-
getContentType
public java.lang.String getContentType()
Returns the content type of the serialized data ornullif the type is not known or cannot be determined.- Specified by:
getContentTypein interfaceArtifact- Overrides:
getContentTypein classorg.apache.jackrabbit.vault.fs.impl.AbstractArtifact- Returns:
- the content type or
null.
-
getContentLength
public long getContentLength()
Returns the length of the serialized data if it's known without doing the actual serialization.- Specified by:
getContentLengthin interfaceArtifact- Returns:
- the length or
-1if the length cannot be determined.
-
getLastModified
public long getLastModified()
Returns the last modified date or0if not known.- Specified by:
getLastModifiedin interfaceArtifact- Returns:
- the last modified date or
0
-
-