org.objectweb.fractal.gui
Class UserDataStorage

java.lang.Object
  extended byorg.objectweb.fractal.gui.UserDataStorage
All Implemented Interfaces:
UserData

public class UserDataStorage
extends java.lang.Object
implements UserData


Nested Class Summary
 class UserDataStorage.UFProject
           
 
Nested classes inherited from class org.objectweb.fractal.gui.UserData
UserData.FProject
 
Field Summary
 
Fields inherited from interface org.objectweb.fractal.gui.UserData
CURRENT_CONFIG, CURRENT_DEPTH, CURRENT_HEIGHT, CURRENT_WIDTH, LAST_EXEC_DIR, LAST_OPEN_CONF, LAST_OPEN_DIR, LAST_OPEN_FILE, LAST_SAVE_DIR, LAST_SAVE_FILE, MODIFIED, NB_DIR, NO_MODIFIED, START_INDEX
 
Constructor Summary
UserDataStorage()
           
 
Method Summary
 void addProject(UserData.FProject proj)
          Adds a new FProject to the project list.
 void clean()
          Clean the user's data
 int getIntData(int typ)
          get the int value for a given type.
 UserData.FProject getNewProject()
          Asks for a new FProject.
 UserData.FProject getProject(int id)
          Adds a new FProject to the project list.
 java.lang.String getStringData(int typ)
          get the int value for a given type.
 void open()
          Open the file which contains all registered User Data.
 boolean projectExists(int id)
          Adds a new FProject to the project list.
 void removeProject(int id)
          Removes the FProject with specified id from the project list.
 void save()
          Save all registered data in the file of the user.
 void setIntData(int typ, int v)
          set the value for a given type.
 void setStringData(int typ, java.lang.String s)
          set the value for a given type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UserDataStorage

public UserDataStorage()
Method Detail

open

public void open()
Open the file which contains all registered User Data. If this file doesn't exist, a new empty file is created.

Specified by:
open in interface UserData

clean

public void clean()
Clean the user's data

Specified by:
clean in interface UserData

save

public void save()
Save all registered data in the file of the user. If this file doesn't exist, a new empty file is created.

Specified by:
save in interface UserData

setIntData

public void setIntData(int typ,
                       int v)
                throws java.lang.Exception
set the value for a given type. The type must belong to the CURRENT_ family type or else an Exceptioon is thrown.

Specified by:
setIntData in interface UserData
Parameters:
typ - is the Data type.
v - is the int value for the type.
Throws:
java.lang.Exception

getIntData

public int getIntData(int typ)
               throws java.lang.Exception
get the int value for a given type. The type must belong to the CURRENT_ family type or else an Exception is thrown.

Specified by:
getIntData in interface UserData
Parameters:
typ - is the Data type.
Returns:
the int data according to the typ
Throws:
java.lang.Exception

setStringData

public void setStringData(int typ,
                          java.lang.String s)
                   throws java.lang.Exception
set the value for a given type. The type must belong to the LAST_ family type.

Specified by:
setStringData in interface UserData
Parameters:
typ - is the Data type.
s - is the String value for the type.
Throws:
java.lang.Exception

getStringData

public java.lang.String getStringData(int typ)
                               throws java.lang.Exception
get the int value for a given type. The type must belong to the LAST_ family type or else an Exception is thrown.

Specified by:
getStringData in interface UserData
Parameters:
typ - is the Data type.
Returns:
the String data according to the typ
Throws:
java.lang.Exception

projectExists

public boolean projectExists(int id)
Adds a new FProject to the project list. If the project already exists, nothing is done.

Specified by:
projectExists in interface UserData
Parameters:
id - is the Data type.
Returns:
true if the FProject exist, false otherwise.

addProject

public void addProject(UserData.FProject proj)
                throws java.lang.Exception
Adds a new FProject to the project list. If the project already exists, nothing is done. If thomething goes wrong an Exception is thrown.

Specified by:
addProject in interface UserData
Parameters:
proj - is the FProject to add.
Throws:
java.lang.Exception

removeProject

public void removeProject(int id)
Removes the FProject with specified id from the project list. If the project doesn't exist, nothing is done.

Specified by:
removeProject in interface UserData
Parameters:
id - is the FProject id to remove.

getProject

public UserData.FProject getProject(int id)
Adds a new FProject to the project list. If the project already exists, nothing is done. If thomething goes wrong an Exception is thrown.

Specified by:
getProject in interface UserData
Parameters:
id - is the FProject identifier.
Returns:
the FProject if exists or null otherwise.

getNewProject

public UserData.FProject getNewProject()
Asks for a new FProject.

Specified by:
getNewProject in interface UserData
Returns:
the new FProject