Class DocIO


  • public class DocIO
    extends IO
    Author:
    Group 3
    • Field Detail

      • XML_FILE_NAME

        protected static final java.lang.String XML_FILE_NAME
        Name of XML doc.
        See Also:
        Constant Field Values
    • Constructor Detail

      • DocIO

        public DocIO​(java.lang.String presFilePath)
        Constructor.
        Parameters:
        presFilePath - Path to pres file.
      • DocIO

        public DocIO​(java.io.InputStream presStream)
        Constructor.
        Parameters:
        presStream - Stream of pres zip.
    • Method Detail

      • save

        public void save()
                  throws java.io.IOException
        Save document to current location.
        Throws:
        java.io.IOException - bad file.
      • saveAs

        public void saveAs​(java.lang.String newPath)
                    throws java.io.IOException
        Save document to new location.
        Parameters:
        newPath - Path to save to.
        Throws:
        java.io.IOException - bad file.
      • removeResource

        public void removeResource​(java.lang.String loc)
        Remove a resource from the Zip.
        Parameters:
        loc - Location.
      • getEmptyFile

        public java.nio.file.Path getEmptyFile​(java.lang.String loc,
                                               java.lang.String prefix,
                                               java.lang.String suffix)
                                        throws java.io.IOException
        Try to get an empty file in the given location, with the given prefix and suffix.
        Parameters:
        loc - Location to create file.
        prefix - File Prefix.
        suffix - File Suffix.
        Returns:
        New File Path.
        Throws:
        java.io.IOException - Couldn't make file.
      • addResource

        public java.util.Optional<byte[]> addResource​(java.lang.String exrPath,
                                                      java.lang.String newPath)
                                               throws java.io.IOException
        Add a resource to the zip.
        Parameters:
        exrPath - Existing Resource path.
        newPath - Path within zip.
        Returns:
        Optional resource bytes.
        Throws:
        java.io.IOException - Couldn't access Path.
      • writeBytes

        public void writeBytes​(java.lang.String path,
                               byte[] content)
                        throws java.io.IOException
        Write to a given file.
        Parameters:
        path - Path to file.
        content - File Content.
        Throws:
        java.io.IOException - Couldn't access path.
      • retrieveDoc

        protected java.util.Optional<nu.xom.Document> retrieveDoc​(java.nio.file.FileSystem fs)
        Description copied from class: IO
        Get doc from FileSystem. Must be implemented by subclass!
        Specified by:
        retrieveDoc in class IO
        Parameters:
        fs - FileSystem
        Returns:
        Maybe Doc.