com.inxar.syntacs.util
Class StandardSession

java.lang.Object
  |
  +--com.inxar.syntacs.util.StandardSession
All Implemented Interfaces:
Session

public class StandardSession
extends Object
implements Session

Standard implementation of Session.


Constructor Summary
StandardSession()
          Constructs the Session which writes to System.out.
StandardSession(Writer out)
          Constructs the Session which writes to the given Writer.
 
Method Summary
 void close()
          To be called at the end of the session.
 boolean contains(String key)
          Returns true if an entry exists for the given key, false otherwise.
 Object get(String key)
          Returns the Object under the given key or null if no such key exists.
 boolean getBoolean(String key)
          Returns the boolean under the given key.
 boolean getBoolean(String key, boolean def)
          Returns the boolean under the given key.
 int getInt(String key)
          Returns the Object under the given key.
 int getInt(String key, int def)
          Returns the Object under the given key.
 String getString(String key)
          Returns the String under the given key or null if no such key exists.
 String getString(String key, String def)
          Returns the String under the given key or the given default if no such key exists.
 boolean isFalse(String key)
          Returns true if an extry exists for the given key and the value is either a boolean having value false, the string "false", or the string "no".
 boolean isNotFalse(String key)
          Returns true if no entry exists for the given key, the value is either a boolean having value true, or any string other than "false" or "no".
 boolean isNotTrue(String key)
          Returns true if no entry exists for the given key, the value is either a boolean having value false, or any string other than "true" or "yes".
 boolean isTrue(String key)
          Returns true if an extry exists for the given key and the value is either a boolean having value true, the string "true", or the string "yes".
 Log log(String name, Object obj)
          Registers the object with the control such that it may emit messages through the log channels.
 void put(String key, Object val)
          Stores the given value under the given key.
 Object remove(String key)
          Removes the key/value pair and returns the value or null if no such key exists.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandardSession

public StandardSession()
Constructs the Session which writes to System.out.

StandardSession

public StandardSession(Writer out)
Constructs the Session which writes to the given Writer. If the given Writer is not an instanceof BufferedWriter it will be wrapped with one.
Method Detail

log

public Log log(String name,
               Object obj)
Description copied from interface: Session
Registers the object with the control such that it may emit messages through the log channels.
Specified by:
log in interface Session

close

public void close()
Description copied from interface: Session
To be called at the end of the session.
Specified by:
close in interface Session

put

public void put(String key,
                Object val)
Description copied from interface: Session
Stores the given value under the given key.
Specified by:
put in interface Session

remove

public Object remove(String key)
Description copied from interface: Session
Removes the key/value pair and returns the value or null if no such key exists.
Specified by:
remove in interface Session

get

public Object get(String key)
Description copied from interface: Session
Returns the Object under the given key or null if no such key exists.
Specified by:
get in interface Session

getString

public String getString(String key)
Description copied from interface: Session
Returns the String under the given key or null if no such key exists.
Specified by:
getString in interface Session

getString

public String getString(String key,
                        String def)
Description copied from interface: Session
Returns the String under the given key or the given default if no such key exists.
Specified by:
getString in interface Session

getBoolean

public boolean getBoolean(String key)
Description copied from interface: Session
Returns the boolean under the given key. If no such key exists, an IllegalArgumentException will be thrown.
Specified by:
getBoolean in interface Session

getBoolean

public boolean getBoolean(String key,
                          boolean def)
Description copied from interface: Session
Returns the boolean under the given key. If no such key exists, the given default will be returned.
Specified by:
getBoolean in interface Session

getInt

public int getInt(String key)
Description copied from interface: Session
Returns the Object under the given key. If no such key exists, an IllegalArgumentException will be thrown.
Specified by:
getInt in interface Session

getInt

public int getInt(String key,
                  int def)
Description copied from interface: Session
Returns the Object under the given key. If no such key exists, the given default will be returned.
Specified by:
getInt in interface Session

contains

public boolean contains(String key)
Description copied from interface: Session
Returns true if an entry exists for the given key, false otherwise.
Specified by:
contains in interface Session

isTrue

public boolean isTrue(String key)
Description copied from interface: Session
Returns true if an extry exists for the given key and the value is either a boolean having value true, the string "true", or the string "yes". If no entry exists for the given key, false is returned.
Specified by:
isTrue in interface Session

isFalse

public boolean isFalse(String key)
Description copied from interface: Session
Returns true if an extry exists for the given key and the value is either a boolean having value false, the string "false", or the string "no". If no entry exists for the given key, false is returned.
Specified by:
isFalse in interface Session

isNotTrue

public boolean isNotTrue(String key)
Description copied from interface: Session
Returns true if no entry exists for the given key, the value is either a boolean having value false, or any string other than "true" or "yes".
Specified by:
isNotTrue in interface Session

isNotFalse

public boolean isNotFalse(String key)
Description copied from interface: Session
Returns true if no entry exists for the given key, the value is either a boolean having value true, or any string other than "false" or "no".
Specified by:
isNotFalse in interface Session