PenProfile 2.x

com.livescribe.storage
Interface PenletStorage


public interface PenletStorage

PenletStorage represents the storage pool for Penlets.

Example:

 PenletContext context = ...;
 PenletStorage ps = context.getInternalPenletStorage();
 InputStream in = ps.openInputStream("file.txt");
 in.read(storedState);
 in.close();
 
PenletStorage contain methods for:


Method Summary
 boolean createDir(String name)
          Create a sub-directory to a PenletStorage pool directory
 boolean delete(String name)
          Remove a PenletStorage pool item (file or directory) If the item is a directory, the directory and all its contents is removed
 boolean exists(String name)
          Check if a PenletStorage pool item (file or directory) exists.
 DataSource getDataSource(String name)
          Gets a DataSource object for the specified name.
 long getModifiedTime(String name)
          Get the modified time for the file entry passed.
 Enumeration list(String name, String filter, boolean includeHidden)
          List all the file entries within the directory name specified.
 InputStream openInputStream(String name)
          Open a PenletStorage input stream for reading.
 OutputStream openOutputStream(String name)
          Open a PenletStorage output stream for writing.
 OutputStream openOutputStream(String name, boolean append)
          Open a PenletStorage output stream for writing (appending if append is true).
 

Method Detail

openInputStream

InputStream openInputStream(String name)
                            throws IOException
Open a PenletStorage input stream for reading. Creates the storage item if it does not exist

Parameters:
name - is the name of the input stream
Returns:
An InputStream object
Throws:
IOException - if an I/O error occurs.

openOutputStream

OutputStream openOutputStream(String name)
                              throws IOException
Open a PenletStorage output stream for writing. If the item with the name name does not exist it is created. If the item exists its content will be destroyed.

Parameters:
name - is the name of the output stream
Returns:
An OutputStream object
Throws:
IOException - if an I/O error occurs.

openOutputStream

OutputStream openOutputStream(String name,
                              boolean append)
                              throws IOException
Open a PenletStorage output stream for writing (appending if append is true). If the item with the name name does not exist it is created. If the item exists and append is true, the content will be appended. If append is false, the content will be destroyed.

Parameters:
name - is the name of the output stream
append - whether to append to the stream or write to the beginning
Returns:
An OutputStream object
Throws:
IOException - if an I/O error occurs.

delete

boolean delete(String name)
               throws IOException
Remove a PenletStorage pool item (file or directory) If the item is a directory, the directory and all its contents is removed

Parameters:
name - is the name of the item to be removed
Returns:
true if operation succeeds, false otherwise
Throws:
IOException - if an I/O error occurs.

createDir

boolean createDir(String name)
                  throws IOException
Create a sub-directory to a PenletStorage pool directory

Parameters:
name - is the name of the directory to be created
Returns:
true if operation succedes, false otherwise
Throws:
IOException - if an I/O error occurs.

exists

boolean exists(String name)
               throws IOException
Check if a PenletStorage pool item (file or directory) exists.

Parameters:
name - is the name of the item
Returns:
true if operation succedes, false otherwise
Throws:
IOException - if there was an I/O error.

getModifiedTime

long getModifiedTime(String name)
                     throws IOException
Get the modified time for the file entry passed.

Parameters:
name - the file
Returns:
the modified time of the specified file.
Throws:
IOException - if there was an I/O error.

list

Enumeration list(String name,
                 String filter,
                 boolean includeHidden)
                 throws IOException
List all the file entries within the directory name specified. For example,

list("sessions", "*.dat", false)

lists all the dat files in the directory sessions.

Parameters:
name - directory name to the list the entries from
filter - a string that filters the list of entries. It supports a very basic endsWith pattern (*.xxx, endsWith xxx) and startsWith pattern (yyy.*, startsWith yyy)
includeHidden - boolean to indicate if hidden files should be included in the filtered list.
Returns:
an enumeration of the files.
Throws:
IOException - if there was an I/O error.

getDataSource

DataSource getDataSource(String name)
Gets a DataSource object for the specified name.

Parameters:
name - the data source name
Returns:
the DataSource for the specified name.

PenProfile 2.x

Copyright © 2010 Livescribe Inc. All Rights Reserved.
Confidential and subject to NDA.