Package g3.project.xmlIO
Class DocIO
- java.lang.Object
-
- g3.project.xmlIO.IO
-
- g3.project.xmlIO.DocIO
-
public class DocIO extends IO
- Author:
- Group 3
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
XML_FILE_NAME
Name of XML doc.-
Fields inherited from class g3.project.xmlIO.IO
allowSave, docName, imagesDirString, mediaDirString, myDoc, origZip, scriptsDirString, tempFilePrefix, tempFiles, tempPath, zipFs
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<byte[]>
addResource(java.lang.String exrPath, java.lang.String newPath)
Add a resource to the zip.java.nio.file.Path
getEmptyFile(java.lang.String loc, java.lang.String prefix, java.lang.String suffix)
Try to get an empty file in the given location, with the given prefix and suffix.void
removeResource(java.lang.String loc)
Remove a resource from the Zip.protected java.util.Optional<nu.xom.Document>
retrieveDoc(java.nio.file.FileSystem fs)
Get doc from FileSystem.void
save()
Save document to current location.void
saveAs(java.lang.String newPath)
Save document to new location.void
writeBytes(java.lang.String path, byte[] content)
Write to a given file.-
Methods inherited from class g3.project.xmlIO.IO
canSave, close, getArchive, getDoc, getInternalResource, getResource, getResourceTempPath, isUriInternal, makeFs, maybeURI, pathToUriString
-
-
-
-
Field Detail
-
XML_FILE_NAME
protected static final java.lang.String XML_FILE_NAME
Name of XML doc.- See Also:
- Constant Field Values
-
-
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 classIO
- Parameters:
fs
- FileSystem- Returns:
- Maybe Doc.
-
-