Package org.jmol.viewer
Class FileManager
java.lang.Object
org.jmol.viewer.FileManager
- All Implemented Interfaces:
javajs.api.BytePoster
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate URLprivate Stringprivate static final Stringprivate Stringprivate Stringstatic final String(package private) JmolUtilprivate Stringprivate Stringprivate Stringprivate Stringprivate Stringstatic final Stringprivate static String[]static Stringprivate SpartanUtil -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static StringaddDirectory(String defaultDirectory, String name) (package private) voidintcacheFileByNameAdd(String fileName, boolean isAdd) (package private) voidprivate boolean(package private) voidclear()(package private) ObjectcreateAtomSeCollectionFromArrayData(javajs.util.Lst<Object> arrayData, Map<String, Object> htParams, boolean isAppend) (package private) ObjectcreateAtomSeCollectionFromStrings(String[] arrayModels, javajs.util.SB loadScript, Map<String, Object> htParams, boolean isAppend) (package private) ObjectcreateAtomSetCollectionFromFile(String name, Map<String, Object> htParams, boolean isAppend) (package private) ObjectcreateAtomSetCollectionFromFiles(String[] fileNames, Map<String, Object> htParams, boolean isAppend) (package private) ObjectcreateAtomSetCollectionFromReader(String fullPathName, String name, Object reader, Map<String, Object> htParams) not used in Jmol project -- will close reader(package private) ObjectcreateAtomSetCollectionFromString(String strModel, Map<String, Object> htParams, boolean isAppend) static StringdetermineSurfaceFileType(BufferedReader bufferedReader) Try to determine a surface file type based on its header.static StringfixDOSName(String fileName) Switch \ for / only for DOS names such as C:\temp\t.xyz, not names like http://cactus.nci.nih.gov/chemical/structure/CC/C=C\CCprivate static String(package private) String(package private) BufferedInputStreamgetBufferedInputStream(String fullPathName) getBufferedInputStreamOrErrorMessageFromName(String name, String fullName, boolean showMsg, boolean checkOnly, byte[] outputBytes, boolean allowReader, boolean allowCached) static BufferedReadergetBufferedReaderForResource(Viewer vwr, Object resourceClass, String classPath, String resourceName) getBufferedReaderOrErrorMessageFromName(String name, String[] fullPathNameReturn, boolean isBinary, boolean doSpecialLoad) private byte[]getCachedPngjBytes(String pathName) getCanonicalName(String pathName) private String[]getClassifiedName(String name, boolean isFullLoad) [0] and [2] may return same as [1] in the case of a local unsigned applet.(package private) StringgetDefaultDirectory(String name) getEmbeddedFileState(String fileName, boolean allowCached, String sptName) Get the specified SPT file of a Jmol zip collection or the embedded script for any other file that is embeddable.static StringExtract a Jmol script embedded using JC.EMBEDDED_SCRIPT_TAG.getFileAsBytes(String name, javajs.util.OC out) getFileAsMap(String name, String type, boolean asBytes) create a PNG or ZIP file and return it as a map or, optionally, as a byte[]booleangetFileDataAsString(String[] data, int nBytesMax, boolean doSpecialLoad, boolean allowBinary, boolean checkProtected) String[]getFilePath(String name, boolean addUrlPrefix, boolean asShortName) static voidgetFileReferences(String script, javajs.util.Lst<String> fileList, javajs.util.Lst<String> fileListUTF) getFullPathName(boolean orPrevious) (package private) ObjectgetFullPathNameOrError(String filename, boolean getStream, String[] ret) just check for a file as being readable.getJzu()static GenericFileInterfacegetLocalDirectory(Viewer vwr, boolean forDialog) static StringgetLocalPathForWritingFile(Viewer vwr, String file) static StringgetManifestScriptPath(String manifest) check a JmolManifest for a reference to a script file (.spt)private byte[]getPngjOrDroppedBytes(String fullName, String name) getUnzippedReaderOrStreamFromName(String name, Object bytesOrStream, boolean allowZipStream, boolean forceInputStream, boolean isTypeCheckOnly, boolean doSpecialLoad, Map<String, Object> htParams) String[]getZipDirectory(String fileName, boolean addManifest, boolean allowCached) static booleanisEmbeddable(String type) Check to see if it is possible that this file has been embedded by Jmol using JC.EMBEDDED_SCRIPT_TAG.static booleanisJmolType(String type) Check to see if this is a Jmol WRITE file type that might be or have attached a ZIP collection .static booleanisScriptType(String fname) booleanisZipStream(Object br) booleanLoad an image(package private) static javajs.util.DataReadernewDataReader(Viewer vwr, Object data) private JmolFilesReaderInterfacenewFilesReader(String[] fullPathNames, String[] namesAsGiven, String[] fileTypes, javajs.util.DataReader[] readers, Map<String, Object> htParams, boolean isAppend) postByteArray(String fileName, byte[] bytes) voidrecachePngjBytes(String fileName, byte[] bytes) (package private) voidsetAppletContext(String documentBase) (package private) voidsetAppletProxy(String appletProxy) voidsetFileInfo(String[] fileInfo) Set fullPathName, fileName, and nameAsGivenvoidsetFileType(String fileType) private voidsetLoadState(Map<String, Object> htParams) static voidsetLocalPath(Viewer vwr, String path, boolean forDialog) called by getImageFileNameFromDialog called by getOpenFileNameFromDialog called by getSaveFileNameFromDialog called by classifyName for any full file load called from the CD command currentLocalPath is set in all cases and is used specifically for dialogs as a first try defaultDirectoryLocal is set only when not from a dialog and is used only in getLocalPathForWritingFile or from an open/save dialog.(package private) StringsetPathForAllFiles(String value) static StringsetScriptFileReferences(String script, String localPath, String remotePath, String scriptPath) private static StringsetScriptFileRefs(String script, String dataPath, boolean isLocal) Sets all local file references in a script file to point to files within dataPath.An isolated class to retrieve Spartan file data from compound documents, zip files, and directoriesstatic Stringstatic StringstripTypePrefix(String fileName) Stip PDB::file://...private String
-
Field Details
-
SIMULATION_PROTOCOL
-
vwr
-
spartanDoc
-
jzu
JmolUtil jzu -
pathForAllFiles
-
nameAsGiven
-
fullPathName
-
lastFullPathName
-
lastNameAsGiven
-
fileName
-
lastFileType
-
appletDocumentBaseURL
-
appletProxy
-
DELPHI_BINARY_MAGIC_NUMBER
- See Also:
-
PMESH_BINARY_MAGIC_NUMBER
- See Also:
-
JPEG_CONTINUE_STRING
- See Also:
-
scriptFilePrefixes
-
cache
-
pngjCache
-
spardirCache
-
-
Constructor Details
-
FileManager
FileManager(Viewer vwr)
-
-
Method Details
-
spartanUtil
An isolated class to retrieve Spartan file data from compound documents, zip files, and directories- Returns:
- a SpartanUtil
-
getJzu
-
clear
void clear() -
setLoadState
-
getPathForAllFiles
-
setPathForAllFiles
-
setFileInfo
Set fullPathName, fileName, and nameAsGiven- Parameters:
fileInfo- if null, replace fullPathName and nameAsGiven with last version of such
-
getFileInfo
-
getFullPathName
-
getFileType
-
setFileType
-
getFileName
-
getAppletDocumentBase
String getAppletDocumentBase() -
setAppletContext
-
setAppletProxy
-
createAtomSetCollectionFromFile
-
createAtomSetCollectionFromFiles
-
createAtomSetCollectionFromString
-
createAtomSeCollectionFromStrings
-
createAtomSeCollectionFromArrayData
-
newDataReader
-
newFilesReader
-
createAtomSetCollectionFromReader
Object createAtomSetCollectionFromReader(String fullPathName, String name, Object reader, Map<String, Object> htParams) not used in Jmol project -- will close reader- Parameters:
fullPathName-name-reader- could be a Reader, or a BufferedInputStream or byte[]htParams-- Returns:
- fileData
-
getBufferedInputStream
-
getBufferedInputStreamOrErrorMessageFromName
-
getBufferedReaderForResource
public static BufferedReader getBufferedReaderForResource(Viewer vwr, Object resourceClass, String classPath, String resourceName) throws IOException - Throws:
IOException
-
urlEncode
-
getFullPathNameOrError
just check for a file as being readable. Do not go into a zip file- Parameters:
filename-getStream-ret-- Returns:
- String[2] where [0] is fullpathname and [1] is error message or null
-
getBufferedReaderOrErrorMessageFromName
-
getUnzippedReaderOrStreamFromName
public Object getUnzippedReaderOrStreamFromName(String name, Object bytesOrStream, boolean allowZipStream, boolean forceInputStream, boolean isTypeCheckOnly, boolean doSpecialLoad, Map<String, Object> htParams) - Parameters:
name-bytesOrStream- cached bytes or a BufferedInputStreamallowZipStream- if the file is a zip file, allow a return that is a ZipInputStreamforceInputStream- always return a raw BufferedInputStream, not a BufferedReader, and do not process PNGJ filesisTypeCheckOnly- when possibly reading a spartan file for content (doSpecialLoad == true), just return the compound document's file listdoSpecialLoad- check for a Spartan filehtParams-- Returns:
- String if error or String[] if a type check or BufferedReader or BufferedInputStream
-
getZipDirectory
- Parameters:
fileName-addManifest-allowCached-- Returns:
- [] if not a zip file;
-
getFileAsBytes
-
getFileAsMap
create a PNG or ZIP file and return it as a map or, optionally, as a byte[]- Parameters:
name-type-asBytes- true to return byte[] instead of a map- Returns:
- Map or byte[]
-
getFileDataAsString
public boolean getFileDataAsString(String[] data, int nBytesMax, boolean doSpecialLoad, boolean allowBinary, boolean checkProtected) - Parameters:
data- [0] initially path name, but returned as full path name; [1]file contents (directory listing for a ZIP/JAR file) or error stringnBytesMax- or -1doSpecialLoad-allowBinary-checkProtected- TODO- Returns:
- true if successful; false on error
-
checkSecurity
-
loadImage
Load an image- Parameters:
nameOrBytes-echoName-forceSync- TODO- Returns:
- true if asynchronous
-
getImage
-
getClassifiedName
[0] and [2] may return same as [1] in the case of a local unsigned applet.- Parameters:
name-isFullLoad- false only when just checking path- Returns:
- [0] full path name, [1] file name without path, [2] full URL
-
addDirectory
-
getDefaultDirectory
-
fixPath
-
getFilePath
-
getLocalDirectory
-
setLocalPath
called by getImageFileNameFromDialog called by getOpenFileNameFromDialog called by getSaveFileNameFromDialog called by classifyName for any full file load called from the CD command currentLocalPath is set in all cases and is used specifically for dialogs as a first try defaultDirectoryLocal is set only when not from a dialog and is used only in getLocalPathForWritingFile or from an open/save dialog. In this way, saving a file from a dialog doesn't change the "CD" directory. Neither of these is saved in the state, but- Parameters:
vwr-path-forDialog-
-
getLocalPathForWritingFile
-
fixDOSName
Switch \ for / only for DOS names such as C:\temp\t.xyz, not names like http://cactus.nci.nih.gov/chemical/structure/CC/C=C\CC- Parameters:
fileName-- Returns:
- fixed name
-
stripPath
-
isScriptType
-
determineSurfaceFileType
Try to determine a surface file type based on its header. Also identifies Menu files.- Parameters:
bufferedReader-- Returns:
- file type
-
getManifestScriptPath
check a JmolManifest for a reference to a script file (.spt)- Parameters:
manifest-- Returns:
- null, "", or a directory entry in the ZIP file
-
getFileReferences
-
setScriptFileReferences
-
setScriptFileRefs
Sets all local file references in a script file to point to files within dataPath. If a file reference contains dataPath, then the file reference is left with that RELATIVE path. Otherwise, it is changed to a relative file name within that dataPath. Only file references starting with "file://" are changed.- Parameters:
script-dataPath-isLocal-- Returns:
- revised script
-
cachePut
-
cacheGet
-
cacheClear
void cacheClear() -
cacheFileByNameAdd
-
cacheList
-
getCanonicalName
-
recachePngjBytes
-
getPngjOrDroppedBytes
-
getCachedPngjBytes
-
postByteArray
- Specified by:
postByteArrayin interfacejavajs.api.BytePoster
-
isJmolType
Check to see if this is a Jmol WRITE file type that might be or have attached a ZIP collection .- Parameters:
type- the- Returns:
- true if PNG, PNGJ, JMOL, ZIP, or ZIPALL
-
isEmbeddable
Check to see if it is possible that this file has been embedded by Jmol using JC.EMBEDDED_SCRIPT_TAG. This includes all Jmol types, JPEG images, and export types POV, POVRAY, and IDTF- Parameters:
type- raw extension or file name- Returns:
- true if this file might contain an embedded script
-
getEmbeddedFileState
Get the specified SPT file of a Jmol zip collection or the embedded script for any other file that is embeddable.- Parameters:
fileName-allowCached-sptName- state.spt, movie.spt, or null- Returns:
- embedded state.spt, movie.spt, or a script embedded using JC.EMBEDDED_SCRIPT_TAG, or "" if not found.
-
stripTypePrefix
Stip PDB::file://... from a file name- Parameters:
fileName-- Returns:
- stripped name
-
getEmbeddedScript
Extract a Jmol script embedded using JC.EMBEDDED_SCRIPT_TAG.- Parameters:
s-- Returns:
- the embedded script or null
-
isZipStream
-