Class SerializerArtifact

    • 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 artifact
        name - the name of the artifact
        ext - the extension of the artifact
        type - the type of the artifact
        serializer - the serializer to use for the content
        lastModified - the last modified date
        Throws:
        IllegalArgumentException - if the type is not suitable.
    • Method Detail

      • getSerializationType

        public SerializationType getSerializationType()
        Returns the serialization type of this artifact.
        Specified by:
        getSerializationType in interface Artifact
        Returns:
        the serialization type of this artifact.
      • spool

        public void spool​(OutputStream out)
                   throws IOException,
                          javax.jcr.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 interface Artifact
        Overrides:
        spool in class AbstractArtifact
        Parameters:
        out - the output stream to spool to
        Throws:
        IOException - if an I/O error occurs
        javax.jcr.RepositoryException - if a repository error occurs
      • getInputStream

        public InputStream getInputStream()
                                   throws IOException,
                                          javax.jcr.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 interface Artifact
        Returns:
        a input stream to the contents of this artifact.
        Throws:
        IOException - if an I/O error occurs
        javax.jcr.RepositoryException - if a repository error occurs
      • getInputSource

        public VaultInputSource getInputSource()
                                        throws IOException,
                                               javax.jcr.RepositoryException
        Returns an input source to the contents of this artifact. This is also preferred for AccessType.STREAM.
        Specified by:
        getInputSource in interface Artifact
        Returns:
        an input source.
        Throws:
        IOException - if an I/O error occurs.
        javax.jcr.RepositoryException - of a repository error occurs.
      • getContentType

        public String getContentType()
        Returns the content type of the serialized data or null if the type is not known or cannot be determined.
        Specified by:
        getContentType in interface Artifact
        Overrides:
        getContentType in class 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:
        getContentLength in interface Artifact
        Returns:
        the length or -1 if the length cannot be determined.
      • getLastModified

        public long getLastModified()
        Returns the last modified date or 0 if not known.
        Specified by:
        getLastModified in interface Artifact
        Returns:
        the last modified date or 0