# SavedState (Slick - The 2D Library)
Date: 2013-06-03

## org.newdawn.slick
Class SavedState

    java.lang.Object
      org.newdawn.slick.SavedState

    public class SavedState

extends java.lang.Object

A utility to allow game setup/state to be stored locally. This utility will adapt to the current enviornment (webstart or file based). Note that this will not currently work in an applet.

Author:
  kappaOne

Constructor Summary
`SavedState(java.lang.String fileName)` Create and Test to see if the app is running as webstart or local app and select the appropriate muffin type

Method Summary
`void` `clear()` Will delete all current data held in Score
`double` `getNumber(java.lang.String nameOfField)` Get number stored at given location
`double` `getNumber(java.lang.String nameOfField, double defaultValue)` Get number stored at given location
`java.lang.String` `getString(java.lang.String nameOfField)` Get the String at the given location
`java.lang.String` `getString(java.lang.String nameOfField, java.lang.String defaultValue)` Get the String at the given location
`void` `load()` Load the data from file/muffin
`void` `save()` Save the stored data to file/muffin
`void` `setNumber(java.lang.String nameOfField, double value)` Save the given value at the given location will overwrite any previous value at this location
`void` `setString(java.lang.String nameOfField, java.lang.String value)` Save the given value at the given location will overwrite any previous value at this location

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SavedState

    public SavedState(java.lang.String fileName)
               throws SlickException

  Create and Test to see if the app is running as webstart or local app and select the appropriate muffin type

  Parameters:
    `fileName` - name of muffin where data will be saved
  Throws:
    `SlickException` - Indicates a failure to load the stored state

Method Detail

### getNumber

    public double getNumber(java.lang.String nameOfField)

  Get number stored at given location

  Parameters:
    `nameOfField` - The name of the number to retrieve
  Returns:
    The number saved at this location

### getNumber

    public double getNumber(java.lang.String nameOfField,
                            double defaultValue)

  Get number stored at given location

  Parameters:
    `nameOfField` - The name of the number to retrieve
    `defaultValue` - The value to return if the specified value hasn't been set
  Returns:
    The number saved at this location

### setNumber

    public void setNumber(java.lang.String nameOfField,
                          double value)

  Save the given value at the given location will overwrite any previous value at this location

  Parameters:
    `nameOfField` - The name to store the value against
    `value` - The value to store

### getString

    public java.lang.String getString(java.lang.String nameOfField)

  Get the String at the given location

  Parameters:
    `nameOfField` - location of string
  Returns:
    String stored at the location given

### getString

    public java.lang.String getString(java.lang.String nameOfField,
                                      java.lang.String defaultValue)

  Get the String at the given location

  Parameters:
    `nameOfField` - location of string
    `defaultValue` - The value to return if the specified value hasn't been set
  Returns:
    String stored at the location given

### setString

    public void setString(java.lang.String nameOfField,
                          java.lang.String value)

  Save the given value at the given location will overwrite any previous value at this location

  Parameters:
    `nameOfField` - location to store int
    `value` - The value to store

### save

    public void save()
              throws java.io.IOException

  Save the stored data to file/muffin

  Throws:
    `java.io.IOException` - Indicates it wasn't possible to store the state

### load

    public void load()
              throws java.io.IOException

  Load the data from file/muffin

  Throws:
    `java.io.IOException` - Indicates it wasn't possible to load the state

### clear

    public void clear()

  Will delete all current data held in Score

Copyright © 2006 New Dawn Software. All Rights Reserved.