com.ap.store
Interface Store

All Known Implementing Classes:
JavaFile, MemoryStore

public interface Store

An interface for objects that are modeling the usual OS files. Here we extend the file definition by giving children and content to all of them.

Store can be actual file on hard drives, but can be ZIP files, file stored on a remote FTP server, memory data, a database...

Conformance tests are available to validate the store implementations.

The main reason for this interface is to be able to write tests that need files without having to actually write data on disk (and clean up). The interface is simple so that writing mock objects is very easy.

Author:
Jean Lazarou
See Also:
package

Method Summary
 Store add(java.lang.String name)
          Creates a new store and adds it as children
 void attach(Store store)
          reserved not yet defined
 Store child(java.lang.String name)
          Returns the child store with the given name
 java.util.Collection children()
           
 void create()
          Creates the store regarding to the persistent storage (if applicable)
 boolean delete()
          Deletes the store and its content
 void detach(Store store)
          reserved not yet defined
 boolean exists()
           
 java.lang.String getName()
           
 Store getParent()
           
 java.lang.String getType()
           
 java.io.InputStream input()
           
 java.io.OutputStream output()
           
 java.io.PrintWriter printWriter()
           
 java.io.Reader reader()
           
 boolean remove(java.lang.String name)
          Removes the child with the given name from the children list
 void setParent(Store store)
           
 void sync()
          Flushes, writes, on persistent storage data that need to be saved (if applicable)
 java.io.Writer writer()
           
 

Method Detail

getName

public java.lang.String getName()
Returns:
the name of the store

getType

public java.lang.String getType()
Returns:
the type of the content

sync

public void sync()
Flushes, writes, on persistent storage data that need to be saved (if applicable)


create

public void create()
Creates the store regarding to the persistent storage (if applicable)


exists

public boolean exists()
Returns:
true if the store exists

delete

public boolean delete()
Deletes the store and its content

Returns:
true if deletion was sucessful

input

public java.io.InputStream input()
Returns:
an InputStream representing the store's content

output

public java.io.OutputStream output()
Returns:
an OutputStream to write to the store's content

reader

public java.io.Reader reader()
Returns:
an Reader representing the store's content

writer

public java.io.Writer writer()
Returns:
an Writer to write to the store's content

printWriter

public java.io.PrintWriter printWriter()
Returns:
an PrintWriter to write to the store's content

getParent

public Store getParent()
Returns:
the parent of this store

setParent

public void setParent(Store store)
Returns:
sets the parent's store

attach

public void attach(Store store)
reserved not yet defined


detach

public void detach(Store store)
reserved not yet defined


children

public java.util.Collection children()
Returns:
all the children of this store, a Collection of Store obejcts

child

public Store child(java.lang.String name)
Returns the child store with the given name

Parameters:
name - of the child to retrieve
Returns:
the this store's child or null if no child was found

add

public Store add(java.lang.String name)
Creates a new store and adds it as children

Parameters:
name - of the new child
Returns:
the new created store object

remove

public boolean remove(java.lang.String name)
Removes the child with the given name from the children list

Parameters:
name - the name of the child to remove
Returns:
true if the children was removed