Class SerializerArtifact
- java.lang.Object
-
- org.apache.jackrabbit.vault.fs.impl.AbstractArtifact
-
- org.apache.jackrabbit.vault.fs.impl.SerializerArtifact
-
- All Implemented Interfaces:
Artifact
,Dumpable
,ExportArtifact
public class SerializerArtifact extends 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, String name, 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 long
getContentLength()
Returns the length of the serialized data if it's known without doing the actual serialization.String
getContentType()
Returns the content type of the serialized data ornull
if the type is not known or cannot be determined.VaultInputSource
getInputSource()
Returns an input source to the contents of this artifact.InputStream
getInputStream()
Returns the input stream to the contents of this artifact.long
getLastModified()
Returns the last modified date or0
if not known.AccessType
getPreferredAccess()
Returns the preferred access value for this artifact.SerializationType
getSerializationType()
Returns the serialization type of this artifact.void
spool(OutputStream out)
Writes the content to the given output stream.-
Methods inherited from class org.apache.jackrabbit.vault.fs.impl.AbstractArtifact
dump, equals, getExtension, getPlatformPath, getRelativePath, getType, hashCode, setContentType, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.jackrabbit.vault.fs.api.Artifact
getExtension, getPlatformPath, getRelativePath, getType
-
-
-
-
Constructor Detail
-
SerializerArtifact
public SerializerArtifact(Artifact parent, String name, 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:
IllegalArgumentException
- if the type is not suitable.
-
-
Method Detail
-
getPreferredAccess
public AccessType getPreferredAccess()
Returns the preferred access value for this artifact.- Specified by:
getPreferredAccess
in interfaceArtifact
- Returns:
- always
AccessType.SPOOL
-
getSerializationType
public SerializationType getSerializationType()
Returns the serialization type of this artifact.- Specified by:
getSerializationType
in interfaceArtifact
- Returns:
- the serialization type of this artifact.
-
spool
public void spool(OutputStream out) throws IOException, RepositoryException
Writes the content to the given output stream. This is the preferred method to use for output-artifacts.The specified stream remains open after this method returns. Provides a generic spool mechanism from the
Artifact.getInputStream()
to the provided output stream.- Specified by:
spool
in interfaceArtifact
- Overrides:
spool
in classAbstractArtifact
- Parameters:
out
- the output stream to spool to- Throws:
IOException
- if an I/O error occursRepositoryException
- if a repository error occurs
-
getInputStream
public InputStream getInputStream() throws IOException, RepositoryException
Returns the input stream to the contents of this artifact. This is the preferred method to use for input-artifacts.- Specified by:
getInputStream
in interfaceArtifact
- Returns:
- a input stream to the contents of this artifact.
- Throws:
IOException
- if an I/O error occursRepositoryException
- if a repository error occurs
-
getInputSource
public VaultInputSource getInputSource() throws IOException, RepositoryException
Returns an input source to the contents of this artifact. This is also preferred forAccessType.STREAM
.- Specified by:
getInputSource
in interfaceArtifact
- Returns:
- an input source.
- Throws:
IOException
- if an I/O error occurs.RepositoryException
- of a repository error occurs.
-
getContentType
public String getContentType()
Returns the content type of the serialized data ornull
if the type is not known or cannot be determined.- Specified by:
getContentType
in interfaceArtifact
- Overrides:
getContentType
in classAbstractArtifact
- 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:
getContentLength
in interfaceArtifact
- Returns:
- the length or
-1
if the length cannot be determined.
-
getLastModified
public long getLastModified()
Returns the last modified date or0
if not known.- Specified by:
getLastModified
in interfaceArtifact
- Returns:
- the last modified date or
0
-
-