public abstract class BaseSample
extends java.lang.Object
If a defaults file exists in the current work directory (CASClient.properties), it will be used to load default values. The defaults file must be in "Properties" format (key/value pairs).
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULTS_FILE_NAME |
protected static java.util.ResourceBundle |
rb |
Constructor and Description |
---|
BaseSample() |
Modifier and Type | Method and Description |
---|---|
void |
argsToProperties(java.lang.String[] args,
java.util.Properties properties)
Convert the command line arguments to a Map object.
|
void |
close() |
CASClientInterface |
createCASClient()
Creates a new CASClient instance.
|
void |
createTarget() |
protected void |
doHelp() |
abstract void |
doSample() |
boolean |
getBooleanProperty(java.lang.String name) |
boolean |
getBooleanProperty(java.lang.String name,
boolean defaultValue) |
protected java.lang.String |
getClassName() |
CASClientInterface |
getClient() |
protected java.lang.Object |
getDefaultValue(java.lang.String name) |
protected HelpOption |
getHelpOption(java.lang.String name) |
abstract HelpOption[] |
getHelpOptions() |
int |
getIntegerProperty(java.lang.String name)
Gets the value of the named property as an integer value.
|
long |
getLongProperty(java.lang.String name) |
java.util.Properties |
getProperties() |
java.lang.String |
getProperty(java.lang.String name)
Gets the value of the named property.
|
java.lang.String |
getRequiredProperty(java.lang.String name)
Attempts to get a required property.
|
java.lang.String |
getResourceString(java.lang.String key)
Provides an opportunity for classes to override if a resource is not found.
|
java.lang.String[] |
getStringArrayProperty(java.lang.String name)
Gets the value of a named property as a String array.
|
void |
initialize(CASClient client)
Provides an opportunity to perform CASClient specific initialization.
|
void |
initialize(CASRestClient client)
Provides an opportunity to perform CASRestClient specific initialization.
|
void |
invokeSample(java.lang.String[] args) |
boolean |
isActionSetLoaded(java.lang.String actionSetName)
Invokes the querylib action on the server to determine if the given action set has
been loaded.
|
void |
loadActionSet(java.lang.String actionSetName)
Attempts to load the given action set if it is not already loaded.
|
protected void |
loadDefaults(java.lang.String fileName,
java.util.Properties properties) |
protected java.lang.String |
pad(java.lang.String s,
int len) |
static void |
printDisposition(CASActionResults<?> results)
Prints any performance events to stdout.
|
static void |
printEvents(CASActionResults<?> results)
Prints any result events to stdout.
|
static void |
printLog(CASActionResults<?> results)
Prints any log events to stdout.
|
static void |
printPerformance(CASActionResults<?> results)
Prints any performance events to stdout.
|
static void |
printResultValues(CASActionResults<CASValue> results)
Prints any result values to stdout.
|
static void |
printResultValues(CASActionResults<CASValue> results,
boolean csv)
Prints any result values to stdout.
|
java.lang.String[] |
propertiesToArgs(java.util.Properties properties) |
void |
setClient(CASClientInterface client) |
protected static final java.util.ResourceBundle rb
public static final java.lang.String DEFAULTS_FILE_NAME
public abstract void doSample() throws java.lang.Exception
java.lang.Exception
public abstract HelpOption[] getHelpOptions()
public void invokeSample(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception
public void createTarget() throws java.lang.Exception
java.lang.Exception
public CASClientInterface getClient()
public void setClient(CASClientInterface client)
public java.util.Properties getProperties()
public void close()
protected void doHelp()
protected java.lang.String pad(java.lang.String s, int len)
protected java.lang.String getClassName()
protected void loadDefaults(java.lang.String fileName, java.util.Properties properties) throws java.io.IOException
java.io.IOException
protected java.lang.Object getDefaultValue(java.lang.String name)
protected HelpOption getHelpOption(java.lang.String name)
public void argsToProperties(java.lang.String[] args, java.util.Properties properties)
args
- The argumentsproperties
- The target properties objectpublic java.lang.String[] propertiesToArgs(java.util.Properties properties)
public CASClientInterface createCASClient() throws CASException, java.io.IOException
CASException
java.io.IOException
public void initialize(CASClient client) throws CASException, java.io.IOException
client
- The client instanceCASException
java.io.IOException
public void initialize(CASRestClient client) throws CASException, java.io.IOException
client
- The client instanceCASException
java.io.IOException
public java.lang.String getRequiredProperty(java.lang.String name) throws CASException
name
- The property keyCASException
public java.lang.String getProperty(java.lang.String name)
name
- The property namepublic java.lang.String[] getStringArrayProperty(java.lang.String name)
name
- The property namepublic int getIntegerProperty(java.lang.String name)
name
- The property namepublic long getLongProperty(java.lang.String name)
public boolean getBooleanProperty(java.lang.String name)
public boolean getBooleanProperty(java.lang.String name, boolean defaultValue)
public static void printResultValues(CASActionResults<CASValue> results)
results
- The resultspublic static void printResultValues(CASActionResults<CASValue> results, boolean csv)
results
- The resultscsv
- if true, tables are printed in CSV formatpublic static void printEvents(CASActionResults<?> results)
results
- The resultspublic static void printLog(CASActionResults<?> results)
results
- The resultspublic static void printPerformance(CASActionResults<?> results)
results
- The resultspublic static void printDisposition(CASActionResults<?> results)
results
- The resultspublic boolean isActionSetLoaded(java.lang.String actionSetName) throws CASException, java.io.IOException
actionSetName
- The action set nameCASException
java.io.IOException
public void loadActionSet(java.lang.String actionSetName) throws CASException, java.io.IOException
actionSetName
- The action set nameCASException
java.io.IOException
public java.lang.String getResourceString(java.lang.String key)
key
- The key