com.kpro.main
Class Gio

java.lang.Object
  extended by com.kpro.main.Gio

public class Gio
extends java.lang.Object


Field Summary
private  java.util.logging.FileHandler fh
          create logger object
private  java.util.Properties genProps
          creates filehandler for logging
private static java.util.logging.Logger logger
           
private  java.util.Properties newWeights
          the loaded weights file.
private  NetworkR nr
          Policy database object
private  java.util.Properties origWeights
          holds all the property values
private  PolicyDatabase pdb
          means of interacting with the user
private  PolicyObject po
          Network Resource (community advice database)
private  UserIO userInterface
          the revised weights, following LearnAlgorithm.
 
Constructor Summary
Gio(java.lang.String[] args)
          Constructor fo gio class.
Gio(java.lang.String[] args, UserIO ui)
          A constructor permitting a user interface class to launch everything and be in control.
 
Method Summary
 void configUI()
          call the user interface's general configuration method if the userInit option is true, and a user interface exists
 boolean fileExists(java.lang.String filepath)
          GUI classes should use this to ensure the user passes valid files to load.
 CBR getCBR()
          returns the CBR to use
 double getConfLevel()
          gets the confidence level threshold from the configuration
 NetworkR getNR()
           
 PolicyDatabase getPDB()
          returns the only policy database
 PolicyObject getPO()
           
 java.util.Properties getWeights()
          returns the originally imported set of weights
 boolean isBuilding()
          returns the true if it should only build
private  void loadCLO(java.lang.String[] args)
          accepts the direct commandline options, then parses & implements them.
private  void loadCLPolicies()
          loads [additional] policies from commandline (either -p or -f)
 void loadDB()
          Loads the case history into cache.
 java.util.Properties loadFromConfig(java.lang.String fileLoc)
          Loads the general configuration file, either from provided string, or default location (./PrivacyAdviser.cfg)
 void loadPO()
          returns the policy object from the policyObject option
 java.util.Properties loadWeights()
          Loads the weights configuration file, from the provided location
private  Action parseAct(java.lang.String optionValue)
          Should parse a string to select, initialize, and return one of the actions (result of checking an object) coded.
private  CBR parseCBR(java.lang.String string)
          converts a string into a valid CBR
private  void selectPDB(java.lang.String optionValue)
          Should parse a string to select, initialize, and return one of the policy databases coded
private  void selectUI(java.lang.String optionValue)
          Should parse a string to select, initialize, and return the user interface selected
 void setGenProps(java.util.Properties genProps)
           
 void setWeights(java.util.Properties newWeightP)
          saves the new weights to a buffer variable before writing in the shutdown call
 void showDatabase()
          shows the database on the user interface, if the user interface exists and no user response is specied and there is no 'blanketAccept' option.
 void shutdown()
          closes resources and write everything to file
 java.util.logging.Logger startLogger(java.lang.String logLoc, java.lang.String logLevel)
          startLogger initializes and returns a file at logLoc with the results of logging at level logLevel.
private  void startNetwork()
          Starts the NetworkR specificied by the configuration settings.
 PolicyObject userResponse(PolicyObject n)
          Generates handles response.
private  void writePropertyFile(java.util.Properties wprops, java.lang.String wloc)
          writes a property file to disk
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static java.util.logging.Logger logger

fh

private java.util.logging.FileHandler fh
create logger object


genProps

private java.util.Properties genProps
creates filehandler for logging


origWeights

private java.util.Properties origWeights
holds all the property values


newWeights

private java.util.Properties newWeights
the loaded weights file.


userInterface

private UserIO userInterface
the revised weights, following LearnAlgorithm. written to disk by shutdown(). also used in loading weights during init()


pdb

private PolicyDatabase pdb
means of interacting with the user


nr

private NetworkR nr
Policy database object


po

private PolicyObject po
Network Resource (community advice database)

Constructor Detail

Gio

public Gio(java.lang.String[] args)
    throws java.lang.Exception
Constructor fo gio class. There should only be one. Consider this a singleton instance to call I/O messages on. Constructs and parses command line arguements as well.

Throws:
java.lang.Exception - Mostly from loadWeights, but should also happen for loadFromConfig

Gio

public Gio(java.lang.String[] args,
           UserIO ui)
    throws java.lang.Exception
A constructor permitting a user interface class to launch everything and be in control.

Parameters:
args - any commandline arguements
ui - the known UserIO object
Throws:
java.lang.Exception - Mostly from loadWeights, but should also happen for loadFromConfig
Method Detail

configUI

public void configUI()
call the user interface's general configuration method if the userInit option is true, and a user interface exists


setGenProps

public void setGenProps(java.util.Properties genProps)

loadCLO

private void loadCLO(java.lang.String[] args)
accepts the direct commandline options, then parses & implements them.

Parameters:
args -

parseCBR

private CBR parseCBR(java.lang.String string)
              throws java.lang.Exception
converts a string into a valid CBR

Parameters:
string - the string to parse
Returns:
the CBR to use
Throws:
java.lang.Exception

selectPDB

private void selectPDB(java.lang.String optionValue)
Should parse a string to select, initialize, and return one of the policy databases coded

Parameters:
optionValue - the string to parse

selectUI

private void selectUI(java.lang.String optionValue)
Should parse a string to select, initialize, and return the user interface selected

Parameters:
optionValue - the string to parse

parseAct

private Action parseAct(java.lang.String optionValue)
Should parse a string to select, initialize, and return one of the actions (result of checking an object) coded.

Parameters:
optionValue - the string to parse
Returns:
the action to apply to the new policy

loadFromConfig

public java.util.Properties loadFromConfig(java.lang.String fileLoc)
Loads the general configuration file, either from provided string, or default location (./PrivacyAdviser.cfg)

Parameters:
location - of configuration file
Returns:
properties object corresponding to given configuration file

loadWeights

public java.util.Properties loadWeights()
                                 throws java.lang.Exception
Loads the weights configuration file, from the provided location

Parameters:
location - of configuration file <---- ????
Returns:
properties object corresponding to given configuration file
Throws:
java.lang.Exception - if there's an issue reading the file (if it doesn't exist, or has an IO error)

startLogger

public java.util.logging.Logger startLogger(java.lang.String logLoc,
                                            java.lang.String logLevel)
startLogger initializes and returns a file at logLoc with the results of logging at level logLevel.

Parameters:
logLoc - location of the output log file- a string
logLevel - logging level (is parsed by level.parse())
Returns:
Logger object to log to.

loadDB

public void loadDB()
Loads the case history into cache. This is where the background database chosen.

Parameters:
dLoc - the location of the database

loadCLPolicies

private void loadCLPolicies()
loads [additional] policies from commandline (either -p or -f)


getPDB

public PolicyDatabase getPDB()
returns the only policy database

Returns:
the policy database

shutdown

public void shutdown()
closes resources and write everything to file


writePropertyFile

private void writePropertyFile(java.util.Properties wprops,
                               java.lang.String wloc)
writes a property file to disk

Parameters:
wprops - the property file to write
wloc - where to write to

userResponse

public PolicyObject userResponse(PolicyObject n)
Generates handles response. This is were we would pass stuff to cli or gui, etc

Parameters:
n - the processed policy object
Returns:
the policyObjected as accepted by user (potentially modified

loadPO

public void loadPO()
returns the policy object from the policyObject option


getPO

public PolicyObject getPO()

isBuilding

public boolean isBuilding()
returns the true if it should only build

Returns:
true if a CBR should NOT be run

setWeights

public void setWeights(java.util.Properties newWeightP)
saves the new weights to a buffer variable before writing in the shutdown call

Parameters:
newWeightP - the new weights file to save

getCBR

public CBR getCBR()
           throws java.lang.Exception
returns the CBR to use

Returns:
the cbr to use
Throws:
java.lang.Exception

getWeights

public java.util.Properties getWeights()
returns the originally imported set of weights

Returns:
the weights for policy attributes

showDatabase

public void showDatabase()
shows the database on the user interface, if the user interface exists and no user response is specied and there is no 'blanketAccept' option.


fileExists

public boolean fileExists(java.lang.String filepath)
GUI classes should use this to ensure the user passes valid files to load.

Parameters:
filepath - path of the file to check
Returns:
true if the file exists, else false

startNetwork

private void startNetwork()
                   throws java.lang.ClassNotFoundException,
                          java.lang.IllegalArgumentException,
                          java.lang.SecurityException,
                          java.lang.InstantiationException,
                          java.lang.IllegalAccessException,
                          java.lang.reflect.InvocationTargetException
Starts the NetworkR specificied by the configuration settings.

Throws:
java.lang.ClassNotFoundException
java.lang.reflect.InvocationTargetException
java.lang.IllegalAccessException
java.lang.InstantiationException
java.lang.SecurityException
java.lang.IllegalArgumentException

getNR

public NetworkR getNR()

getConfLevel

public double getConfLevel()
gets the confidence level threshold from the configuration

Returns:
the confidence threshold