|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectextra.inpro.training.SessionData
public class SessionData
Container for all data in the current session. SessionData contains files in the file system, and smaller information chunks (in SmallFile objects). An archive (in the form of a ZIP file) may be stored on disk or sent to a server via the network.
Nested Class Summary | |
---|---|
class |
SessionData.SmallFile
keeps data bits that are not worth to write into files. |
Field Summary | |
---|---|
(package private) static java.lang.String |
BOUNDARY
the boundary between multipart message parts. |
(package private) static int |
BUFFER_SIZE
size of the buffer when piping from input buffer to output buffer |
(package private) java.util.List<SessionData.SmallFile> |
smallFiles
additional list of small information chunks to be stored in the archive |
(package private) java.util.List<java.net.URL> |
urls
the files contained in this archive |
Constructor Summary | |
---|---|
SessionData()
|
Method Summary | |
---|---|
(package private) void |
addFile(java.io.File file)
add a file to the archive |
(package private) void |
addFile(java.lang.String filename)
add a file given its filename |
void |
addFromURL(java.net.URL url)
add data that comes from a URL |
(package private) void |
addSmallFile(java.lang.String filename,
java.lang.CharSequence content)
add a short bit of information that will be added to the archive under the given name. |
(package private) void |
clear()
clear the archive of previous entries |
static void |
main(java.lang.String[] args)
for testing only. |
private static void |
pipe(java.io.InputStream in,
java.io.OutputStream out)
pipe the content of an input stream into an output stream |
(package private) java.io.InputStream |
postToServer(java.lang.String url)
|
(package private) java.io.InputStream |
postToServer(java.net.URL url)
post the archive's content (packed as a zip file) to a server. |
(package private) void |
saveToFile(java.lang.String filename)
write the archive's content to a local zip file |
(package private) void |
toOutputStream(java.io.OutputStream outStream)
write the archive's content to an output stream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
final java.util.List<java.net.URL> urls
final java.util.List<SessionData.SmallFile> smallFiles
static final java.lang.String BOUNDARY
static final int BUFFER_SIZE
Constructor Detail |
---|
public SessionData()
Method Detail |
---|
void addFile(java.io.File file)
file
- the file to addvoid addFile(java.lang.String filename)
void addSmallFile(java.lang.String filename, java.lang.CharSequence content)
filename
- the filename in the zipfilecontent
- the data to be addedpublic void addFromURL(java.net.URL url)
void clear()
private static void pipe(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
in
- the stream being drainedout
- destination of the data
java.io.IOException
- if reading or writing goes wrongvoid toOutputStream(java.io.OutputStream outStream) throws java.io.IOException
outStream
- the stream that is written to
java.io.IOException
- when errors occur on reading the files contained in the archivejava.io.InputStream postToServer(java.net.URL url) throws java.io.IOException
url
- the server's URL
java.io.IOException
java.io.InputStream postToServer(java.lang.String url) throws java.io.IOException
java.io.IOException
void saveToFile(java.lang.String filename) throws java.io.IOException
filename
- name for the zip file
java.io.IOException
- when the file cannot be written topublic static void main(java.lang.String[] args) throws java.io.IOException
args
- arguments are ignored
java.io.IOException
- when something goes wrong
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |